找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1110|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 3 }6 X' O) B: o+ t3 N . ^8 c: ]2 h- W5 Z
回复

使用道具 举报

 楼主| 发表于 2007-5-9 13:57:40 | 显示全部楼层
没人懂吗?
回复

使用道具 举报

发表于 2007-5-9 13:58:19 | 显示全部楼层
偶懂一点点点
回复

使用道具 举报

 楼主| 发表于 2007-5-9 13:58:55 | 显示全部楼层
我在做作业啊...遇到不会的问下你..
回复

使用道具 举报

发表于 2007-5-9 14:00:01 | 显示全部楼层
还给老师了
回复

使用道具 举报

发表于 2007-5-9 14:00:25 | 显示全部楼层
我晕到,做JAVA的作业啊  ,你学啥子的
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:00:46 | 显示全部楼层
问下,如果有两个.java的文件,这两个文件有相似性...我们的要求是写一个另外的java程序,然后可以载如 这两个java文件,进行code的逐行对比,然后列出相似的行和相似内容,应该用什么类
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:11 | 显示全部楼层
//*********************************************************************) E, q& X- n2 j* n
//  ProgramCompare.java         Provided by: DRS
! b, X% s7 c$ X8 e$ k; s4 d//9 t& U) j+ s# o5 `8 I8 f
//  Program shell for Assignment 2
1 h* r! ]  _0 y. |3 e//
) }& q* S  c+ C/ j& }' r. D//  Compares two text files line by line
* l1 {/ m5 K: x, S//*********************************************************************
7 p; L. Q( ~* H4 X: {7 D6 H( J( E: @6 B7 g0 M$ A% M# p
import java.io.*;! r. Q! T1 ]5 ]

; p1 ]8 [: x$ M3 `, ipublic class ProgramCompare
% b5 S5 j5 [, c0 e{
2 [$ e0 e5 ]; a+ H: J        //-----------------------------------------------------------------
0 B/ ^" B8 g7 H; b        // Constructor
9 Y* U7 D( p/ T" L        //-----------------------------------------------------------------
/ C# ^& S1 a# n2 a4 y        public ProgramCompare()
' H7 B" [' `0 P        {5 \  X- G6 @- x! C  O( u! B5 W; T
        }
* H* I! o' C3 o- I6 @8 g3 V& C! N7 F! Q/ p, Z
        //-----------------------------------------------------------------0 e. D5 y  M: x5 M/ ?  e* b6 U
        // Method for testing that class has been reached3 }# {( Y  s4 Q
        //-----------------------------------------------------------------       
1 z: i8 q! W! S3 t
$ N" x( R8 _# o% U% v        public boolean ProgramCompareReached()         . N( z6 b0 v% C# C, y3 u
        {3 s" G) V5 e9 b& }, j& R( a3 M# p
      try * H  T# f& J9 j( ?  M+ M
   {         7 T* D9 T8 S2 m5 ]
                        ) J3 \' U" u* n# R/ q7 _7 a4 D
                //********************************************************************1 @1 B. a% H6 B. f2 \$ _; V
                // Try-Catch Statement is used to handle exceptions - such as file not found ! g9 }8 ^' c3 |) J2 Q- o/ M
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
! I& i$ A" g* L) u7 ~) V- L, c                // For more information see page 534 of the textbook
- Z1 m; i* ^& q" ~9 n                //********************************************************************
  g* c- i. ^0 P% c: k                     7 y( H+ P: \6 i* a  c
        }- m) `& Q, S( s2 [
             catch (Exception ex) // Exception caught here and message displayed to the screen , c3 _. O+ p/ Q" S4 f  R
          {
/ i4 e# s! L( ]                    ex.printStackTrace (System.err);; R# P! m& @$ f8 D1 f: T# c9 @
           System.out.println ("Error message goes here"); // Replace this error message with your own         
" O+ Q( |; Q: a- z; }        }
9 g" C" q" u5 C                return true;
# S; c# x% n: V9 ~7 k% u        }& u2 Z% ?4 }6 R. |4 f- n  e' w
9 ^1 b( q8 x3 X' f8 P
} // end of class ProgramCompare
- z* M6 |: N$ B& v" l9 S7 L9 C
# B. J  d+ N/ u0 I! X& z  ]7 g//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************4 d5 u- R$ L6 D* N! d
//  ProgramCompareMenu.java    Provided by: DRS
" r' e6 A; U( Y7 b8 b( a//8 R/ _) ?* N" i6 j, S( o
//  Calls AuthorisedUsers.java and ProgramCompare.java
/ F4 c7 o' y" u- L' G6 q//' |: m4 E- t: ?
//  Driver shell for Assignment 2./ i+ P5 Y! k- N# P7 y+ S
//********************************************************************
: ]8 a2 d# U( k& t3 I
+ y' X/ u) X# g; x( \# }3 Z; Z2 [class ProgramCompareMenu
9 m2 k# N  v2 P+ _5 k6 A{
4 `- _2 b# i& W3 P0 U6 i    public static void main (String[] args)
* g$ q8 H" M8 i7 b0 m) Y            {
( c# @$ t: h' y. T7 c  D                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
/ K1 G6 w$ R1 A7 }& {                ProgramCompare reached1 = new ProgramCompare(); 2 b/ W5 v) i1 \
                AuthorisedUsers reached2 = new AuthorisedUsers();       
6 V7 ]! I& P- ~$ _" B0 ^                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
% [% j3 H6 `% |3 f                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        9 w. R4 |) n  P; Q5 ?
        }
' R, I1 ~8 x4 Y& E* T. @- t3 n}// end of class ProgramCompareMenu
! K$ r- ]: R( E' x. S9 {6 x# j0 a& c
8 b- s& m3 M+ h//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
7 \' }0 {/ z  n1 g+ A3 L2 E//          AuthorisedUsers.java          Provided by: DRS
; y4 I+ C! L5 h! T6 _& C/ w//               
* \7 v" w/ ~! _! r8 m//         Program shell for Assignment 2
. n( |4 |3 f& H5 M' n/ ^9 B//
! W" T4 {# P9 E: a; t# [+ i( ?# a3 |//         Represents facts about an AuthorisedUser
1 m$ m0 i7 q: v; f2 r5 v//********************************************************************' j2 [& y( s# h1 t$ U

# K' u3 f7 v$ }9 U0 Ppublic class AuthorisedUsers. u4 ~7 n* v7 b  B9 S
    {* S" f# r. m, K4 K0 O8 z
% D0 E8 @5 `4 O; F+ z5 R' X) {( f) F4 a
        //-----------------------------------------------------------------) S& g2 S+ T- i" K
        // Constructor' Q  L  {  C- g# J
        //-----------------------------------------------------------------6 i2 L- o6 ^0 D) m2 a

+ j) b9 t( L; \; g; i" l6 \: C6 `        public AuthorisedUsers()
8 \% H& a6 X$ w* d                {
/ R" P' N3 S" U* Z. S9 X                }
& b6 V5 {) T/ P4 Q1 i4 N7 R0 [5 I! p
9 {3 X, e$ Q/ @8 D. H        //-----------------------------------------------------------------
  v0 }5 e9 v6 k, _" {1 f7 U        // Method for testing that class has been reached
' X+ a$ V/ N: O1 q' j1 [: \        //-----------------------------------------------------------------       
$ K; ~  g1 |( d4 x! o        public boolean AuthorisedUsersReached()
4 c3 j. V' `2 w! |                {
$ n( ]" y/ ?( f! r                        return true;                        7 H+ r7 }* D+ H" ^
                }
' |, K' U' ?5 k               
- B$ ]8 r) ^1 X% G& k    } // end of class AuthorisedUsers
, m. V' g) K- v: I# ]//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming; n! Z/ a  F% z' G+ [, D
Shanghai - 2007
7 Q+ Q8 G9 x7 i7 VAssignment 29 N' ^& a8 g. w/ {# g* r1 C! K* I
Deadline for Submission: 10:00 pm (Shanghai time), Tuesday 15th May 2007 Assessment Weighting: 20% of the total assessment for BSA104 Assignment Type: Individual Scenario: The teaching staff at a nearby university are concerned that some of their students are submitting other students‟ work. They need a simple Java program that will compare the text of two other Java programs, line by line, for equality, and then print out the results, and a recommendation. Requirements: Consider the three Java Classes: ProgramCompareMenu.java, ProgramCompare.java and AuthorisedUsers.java, available from the Assignment 2 page on Vista. You are required to perform the following tasks: The ProgramCompareMenu class: (Total maximum 20 marks available)3 Q! x% s5 G3 `' j2 O# r. n+ ?
1. Provide a basic text-based menu interface to the ProgramCompare class so that it can be used by two staff members to determine if the two supplied Java programs are the same or similar.- Z  D* p* J7 d% M
The staff must be able to:2 p. Y' b) x7 g* c( b$ u8 C( S
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
3 l1 a! C+ x( e1. The user should not be able to use the „system‟ until they have provided the correct user name and PIN combination. You should give them a second or third chance to get it right before shutting the „system‟ down.8 l5 J& k" y: t4 ~+ E
 The interface should provide a menu so that the staff can:
; R! H# t8 {, }a) Enter the names of the two Java program files to be compared
* e% `/ [, w$ w- \ For this assignment, it will be assumed that the two Java program files are in the same folder as your program.+ H2 U! U! T, @$ c8 c: a
** You must use the two user names and PINs provided in your individual data available from the Assignment 2 page on Vista (see requirement 5 below). The user names and PINs should be included in your code, and the output to the screen should prompt the user with the user names and passwords (for marking purposes).; K# F$ E$ s5 o4 l
BSA104 Business Programming – 2007: Assignment 26 T- o# _$ Q+ B3 C, c/ p7 m
Page 2 of 5. r4 O( C) A* [" a
b) Print out to the screen all the lines of code that are the same- t* t% B2 Q( l
 Include the name of the file and the line number of the code being printed for each of the two files0 v$ w0 |, l* V
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
* K) C: R. X0 p# R0 Y. j. x! u the name, username and department of the user0 }% M7 m" p: ?; g  p3 [5 N, B
 the statistics of the comparison6 L+ A  u. l% k
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
; n7 z$ z$ P$ w' J. h$ z( H the recommendation for further checking. b8 ?; ~2 j% V0 S" `/ T1 G3 b
- For example: if more than 5 (five) lines of code are the same in each Java program file, then print a recommendation to the screen that the staff member check the files more closely+ u; |& f& \1 G2 H6 V
 the names of the two files compared- M) h% _- X5 R  O. f# k4 ?
d) Leave the program (exit)
. p; {7 O5 E# {The ProgramCompare class: (Total maximum 20 marks available)
* e: b6 \- ]% e% E# _3 Y, S# A2. Provide a method/s to read in each line of code from the two files identified by the user: (assumed that the two Java program files are in the same folder as your program)) B5 @% t* ]0 W3 q/ [! {7 M
a) provide an error message if the files are not found or there is a problem opening them% ^; g: k/ v' x- s) r$ g
b) compare each line of code
* {/ r4 i+ S0 o; G' Y9 a: ?c) print out the lines that are the same
) s. B+ g; M% hd) count the number of lines compared / lines the same
1 Q; [3 t, T9 F& XThe AuthorisedUsers class: (Total maximum 20 marks available)9 h5 D5 B& ?- s0 ^# g; Q5 A
3. Provide an object that contains the name, username, PIN, and Department of the authorised users of the program (user names and PINs as provided in your individual data - see requirement 5 below)
: J* o7 R8 U! S5 f4 W; ]: W4. Provide methods to:
# J+ W9 o: X) Za) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match7 t6 F  P6 d" D( F
b) return the name of the authorised user+ y  q  C; t! F7 w8 Q
c) return the name of the department of the authorised user- S0 i+ F1 `7 q1 ]# C3 M
Individual Data (Maximum 20 marks available)
) R) U' Y7 ^6 u" D  f5. You will be given two staff member names, usernames, PINs, and department name, plus a set of two Java program files to compare using your program. You will need to log onto the BSA104 Assignment 2 page on Vista to generate your individual data and instructions for this requirement. You will need to use your University of Tasmania (UTas) student number.6 m7 D4 |- C3 ?- B
Documentation (Maximum 10 marks available)5 a" G) R4 q1 {; ?0 c  N) V2 W- Z2 }: A
6. Your program files should be fully documented, at least to the same standard as demonstrated in the textbook. This includes in-code comments, descriptions, and where appropriate, explanations for each new constructor, method and variable.+ x& T4 \6 B, _* n; }7 m9 N" Y
BSA104 Business Programming – 2007: Assignment 2
* K7 {2 T% X% c9 _* S* VPage 3 of 5
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:53 | 显示全部楼层
上面是作业要求,然后前三个是给的java程序,要求自己修改- -
回复

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
( @% _6 r) d! D# I" @! z# j  B0 |不过你要翻JAVA的类库说明。你有下载没有?
* t7 l0 z* c3 Z0 F8 X7 V查询关于对比的函数。貌似关键字是contrast,还有compare$ K0 C7 X* D+ w

; R% I) C* S6 v5 H[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -, B- t4 }9 Y, N  @, v0 _
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。) L4 }0 b! e) N6 @  V
可以下载到的 是 jdk-1_X_0-doc
: [! {( w3 F! O& N$ @% I/ k1 |" ~: f& R9 C& F; B# T6 w2 Q
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|=|HERO|=战队 ( 皖ICP备19020640号 )|网站地图

GMT+8, 2026-3-14 01:18

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表