找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1314|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 4 ?. w$ M. q( [( H+ A& |3 M0 V: }) r$ w6 \& m
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
: ^* `8 i5 }* A( ~//  ProgramCompare.java         Provided by: DRS
% z) b6 O4 h5 q& ~//0 J* n7 d' ~: e3 s- x2 P
//  Program shell for Assignment 2# \+ Q6 D4 Z3 j* I' W1 {
//, u" ^2 ?; L% g; K6 s. k" M  h
//  Compares two text files line by line
0 ]/ n+ o5 X  [5 I2 c8 @" H( J//********************************************************************** ]& K  V* S& K  m

* c7 ?3 p3 ]- V* ?. z' h5 W9 eimport java.io.*;2 B& n6 Z% F) k) `5 s0 u/ s' p6 q

6 D- w3 a" I) y8 S, `public class ProgramCompare5 @" ~* ^6 ?8 ?, D) L
{! B2 b7 \, n/ ^
        //-----------------------------------------------------------------4 D- q: r- d. j  i/ ?+ u, M; @
        // Constructor
( D* f6 n# [, [/ G  ?; V) p  ^        //-----------------------------------------------------------------
7 @- b6 T; ]2 e2 A        public ProgramCompare()
* N: C1 G) [8 h2 J4 ]$ i- }) `        {& x% q9 z7 f5 J9 B+ F
        }
# l$ Y' t; ~8 m) K3 S( G' ~2 f6 x$ m- y
        //-----------------------------------------------------------------9 |0 [* d% ?$ I; A
        // Method for testing that class has been reached
: J" z8 t( t# G5 d/ z# L        //-----------------------------------------------------------------       
- E: L- @  f8 G: Z) p1 W0 A' e, {+ J2 ]0 \& Q8 @6 X( f! S' J
        public boolean ProgramCompareReached()        
* F: w: Y0 r: ^$ n2 k+ V1 ~3 U        {, T9 e. y& B! @; K# y: Y
      try
: p3 A. @; \- s8 B   {        
5 v+ Y" }. n3 i. V                        ) d2 _8 Y; W0 S
                //********************************************************************/ R% u$ K6 T1 i6 X- Z5 f
                // Try-Catch Statement is used to handle exceptions - such as file not found
' u- D1 \) R+ x6 H' y5 Z) t                // Reading the files will need to be placed inside a Try-Catch - just like this one!+ \6 P8 W+ F6 W* x! n( [
                // For more information see page 534 of the textbook! m. }4 A  o* g% j6 Y, S- U7 `
                //********************************************************************0 }- x! u$ w) g
                     3 d- R7 ^/ D2 ?: ^
        }
, k7 p: q( b8 `! h1 s( Z3 e5 \* C             catch (Exception ex) // Exception caught here and message displayed to the screen
! v9 @& y0 h0 Q' T+ Y; E          {2 n& Q  @' I$ \- L
                    ex.printStackTrace (System.err);
) \, k/ d6 W+ I           System.out.println ("Error message goes here"); // Replace this error message with your own         
* ^3 O& l7 \" s9 ~        }
2 |: J1 j6 `! k2 e! K  u3 R1 \                return true;
2 h4 a# v& \' B1 x; F1 }        }
1 e( Y5 P& d9 \  N5 G8 Q( A$ C% v/ [) A5 {& O
} // end of class ProgramCompare
* w+ S/ f' ~9 ^: K
9 Q) q/ e" _; r$ \0 E' k//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
2 B1 d2 |' j. z5 U3 l7 S//  ProgramCompareMenu.java    Provided by: DRS
: n0 b2 N* o: X  U& k& G: r//
  w6 j5 U; I2 `( C- ?. f; ?! |* M//  Calls AuthorisedUsers.java and ProgramCompare.java
% ]9 x/ z( T2 H3 ~7 a3 R7 o//0 H; _' E& W0 w% b+ ?7 r
//  Driver shell for Assignment 2.
2 G6 k+ B7 E% {% r5 s//********************************************************************
& H' h! C3 d& d9 B/ T) }2 n5 i6 j9 E! L) j( @
class ProgramCompareMenu- {1 J/ D: ^- l0 _
{. H% b( z7 Y4 ]$ W9 a3 @
    public static void main (String[] args)/ L4 |* x9 g2 l0 J- J- R% D$ Q8 P
            {) x: q* I$ S0 i. j" R
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable8 a) Y; v' `1 ^/ W' |7 W7 N
                ProgramCompare reached1 = new ProgramCompare(); ) g; V7 }/ ~2 V. x! M" p
                AuthorisedUsers reached2 = new AuthorisedUsers();       
1 {4 E& q7 h8 e5 g                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
9 J- R  B2 w" Y2 @* Y- x                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        * V9 b% C; w( O/ U! c/ i- k
        }4 n3 t4 Z/ i# l% [  [/ ^4 b8 g  ~
}// end of class ProgramCompareMenu% X2 a& h2 g) j  l

3 S: s4 I( c9 A# J' o( y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************6 z( k# W! ]# Q$ B5 S2 r
//          AuthorisedUsers.java          Provided by: DRS
7 e6 l& u, ?5 v5 |' t6 q, R9 }. _//               
6 i) R. P+ l, x' r% w! C/ R//         Program shell for Assignment 2/ w( O- g) w' T  \
//
) w; Z% Y/ m' d" U5 Z; ^9 f//         Represents facts about an AuthorisedUser  }0 _- l6 j: _- A2 @! ]! U
//********************************************************************' q* ]+ D7 C. b& S7 e

' n1 _: a7 q/ m& |  hpublic class AuthorisedUsers) z  T. I8 l0 V1 x. R
    {) x3 w. Z$ q9 W6 x/ |" i& f

3 o2 a2 H0 O0 ~) u, a        //-----------------------------------------------------------------
6 a! g  G$ A" Q% p  R        // Constructor
) T  u2 [5 ~. j2 l        //-----------------------------------------------------------------
$ M9 j- I# C) D/ q$ h0 G5 H3 S8 Z" d0 s2 Q" ]
        public AuthorisedUsers()
" i3 t) B9 a4 P! _  r                {( M; t7 y( Q, {6 s
                }
. |- L4 H: ~5 E( P+ Y6 V0 I: ]% \
        //-----------------------------------------------------------------
  D5 n+ Y4 K3 ]5 O* h$ x7 W' {        // Method for testing that class has been reached* y' a: A$ y( F6 W
        //-----------------------------------------------------------------        4 V7 J9 e7 A* M) \8 f2 [
        public boolean AuthorisedUsersReached()
4 S2 v# O/ F6 [                {  ?( Z% C6 g/ d: F
                        return true;                       
/ u3 S" \8 B  w# V0 |                }' f+ X! m2 d$ v; Z5 a$ o
               
) I% O5 G. X; J    } // end of class AuthorisedUsers
& h9 R9 _' e/ a/ K: x8 }0 Z2 C- _0 y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming9 C# U  }# ^  l8 d! }1 j
Shanghai - 2007- i& }+ N2 Y5 E- i
Assignment 2
8 Y2 I- V% w" B. iDeadline 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 h- F- o9 u0 j
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.
0 P4 h, _+ A4 x3 [The staff must be able to:
/ K$ e, M& X- }! k0 G8 Y# _6 l Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
. `: }% K& ^% k( ?" H6 |5 `  _' c1. 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.
9 Y6 P7 A* X' G The interface should provide a menu so that the staff can:
* ^& Q$ G$ i3 N7 `  ja) Enter the names of the two Java program files to be compared: [  {  \; b8 t6 X6 ], l
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
$ ^# ~7 `9 `# {# M. }** 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).
4 V# l1 ?2 D/ Q( @+ f% jBSA104 Business Programming – 2007: Assignment 2
7 c- R' u* K( ~& J+ ]/ M( rPage 2 of 5$ E* s/ C, N) k) J
b) Print out to the screen all the lines of code that are the same! k& U( {9 E' E/ C7 U/ w
 Include the name of the file and the line number of the code being printed for each of the two files; C, Y; X- L+ E/ s
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
4 B* n; }- p' V5 x* M+ g the name, username and department of the user
* f) t) L3 X  J# P( U9 p3 J1 B5 e the statistics of the comparison" \8 Y+ f' j. N/ p% T9 r
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
( x' M+ b& c% ~" a the recommendation for further checking
% f; W- A# _7 g$ n& E- 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" \: c% P" A% |: D
 the names of the two files compared* E/ w8 I7 O3 O( W1 b% H
d) Leave the program (exit)' z( q) O* I7 K% N6 X
The ProgramCompare class: (Total maximum 20 marks available)5 O! s; D7 R7 _) C1 W
2. 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); k2 L/ ~1 N9 i* D" ~% e" L
a) provide an error message if the files are not found or there is a problem opening them2 L5 Q9 j* L  C6 p2 c4 b. }. K
b) compare each line of code9 x" y6 T6 k: m1 d$ v; u
c) print out the lines that are the same
; v, a0 A. W8 c& Yd) count the number of lines compared / lines the same
8 n3 L7 B- \( s& z& C. L. Q2 r" f4 aThe AuthorisedUsers class: (Total maximum 20 marks available)
+ g9 m/ Q3 M0 @# }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)  s5 p% o* Q9 M8 g
4. Provide methods to:
% L2 n# s; a" x- o  e. E' Ha) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match
- A( x6 C% r2 F; O/ y" vb) return the name of the authorised user: F# n- u0 r0 z1 P& b" N+ D
c) return the name of the department of the authorised user
4 t: W5 i# B" s: `# LIndividual Data (Maximum 20 marks available)$ H$ N! h- n6 u3 v
5. 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.. f# P; q% C: ]: |; X% d+ I
Documentation (Maximum 10 marks available)! J/ B( \+ H* E0 _' w$ A4 E: K
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.
& I4 Y/ W. |1 n8 y2 C3 [BSA104 Business Programming – 2007: Assignment 2" f: Z' l5 x: ?+ o  L3 y
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了  q# t; A) h" X+ ?
不过你要翻JAVA的类库说明。你有下载没有?
# |- e( d+ ~" f+ c+ r' n6 F查询关于对比的函数。貌似关键字是contrast,还有compare9 j5 e1 T% ]/ d! Q# l2 ?
; ~: T+ V3 Y2 w  n
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
' n8 j8 |) Q8 {7 P5 d! P6 {8 a痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
& J/ t1 {- f# _# [: O: E可以下载到的 是 jdk-1_X_0-doc4 m  V2 [+ l% `

- @. v. X7 ]4 o- R) l% _) s[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-26 12:01

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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