找回密码
 注册

QQ登录

只需一步,快速开始

查看: 827|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 s* c4 w# |/ c. Z, o/ x# r ; ]1 `& y+ g; y [' }& Y u
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************# k# w0 C3 v1 k: Q) J
//  ProgramCompare.java         Provided by: DRS
7 H- T, ~! [: m2 u8 B' K4 j2 X* e//: d0 l( i# _% Q9 Y- G( V, L; p
//  Program shell for Assignment 2$ S+ P- U8 `# F4 h9 p0 a! d5 q
//" W! G5 b' v( Z. H& Y, O$ l
//  Compares two text files line by line
& I+ i8 p/ {% i- z% @/ {//*********************************************************************# ]7 y# }) F2 J& A7 j& }
1 v' q2 d6 B0 e* h$ h/ x
import java.io.*;* g" H& N. P3 X  C/ }  g8 ~
  w2 Y9 \% E1 X, v! n
public class ProgramCompare
6 d; F8 Q- `9 ~{7 e- I" o- P! G8 |+ `
        //-----------------------------------------------------------------4 N7 B8 Z' b4 V2 D
        // Constructor
( U* a  i& G6 H, S        //-----------------------------------------------------------------# U$ r8 Y( q; `; }3 a: Q5 v
        public ProgramCompare()
9 c( O: P! ?, D# T6 w* R        {
8 J: e2 o3 a- O% E9 X# F, K        }
4 e! H2 f) F# u, n+ X3 R: ?! D+ H2 @" y
        //-----------------------------------------------------------------" f) |/ z# B3 X
        // Method for testing that class has been reached
3 L. X2 b7 g. d+ U2 p1 Z% T1 G        //-----------------------------------------------------------------       
2 J. b# v# ?. c0 c6 t7 r# O
! R- I9 T- t2 J- S9 h) X3 x        public boolean ProgramCompareReached()        
% U/ ^' ^  [) {! t; `! J$ j+ z" S- W2 Q        {+ N) e0 G5 w- c1 h0 ~# ^9 `6 E
      try
2 C1 x9 x, @" k1 G6 J$ h3 c/ m   {        
0 x- {4 \9 c  c& T                        ; x+ Z3 o/ e  K
                //********************************************************************# {" f8 A7 H6 O: q
                // Try-Catch Statement is used to handle exceptions - such as file not found
( |6 C6 g% X) y* q& }3 O                // Reading the files will need to be placed inside a Try-Catch - just like this one!. Y! z- A/ V# L7 T) r' t; |
                // For more information see page 534 of the textbook" G& ?; Y3 A  W+ E+ }
                //********************************************************************
+ l$ B& V5 P& w7 n- q& p8 m* ~                     2 X& D7 C: G9 t. T9 P2 J- l
        }( |2 P3 b7 P$ L$ {( \  i$ z4 r
             catch (Exception ex) // Exception caught here and message displayed to the screen ) c$ U, N8 B9 Y2 |9 R3 ^; Q* c
          {
$ s/ B  y8 a+ @6 B0 Y6 }3 z                    ex.printStackTrace (System.err);: ^' @3 I9 }1 a' F- F, N
           System.out.println ("Error message goes here"); // Replace this error message with your own         
4 z; ]5 n9 M& ?6 D5 e4 S; _        }
* t3 a+ J% ^) `+ @% d- O/ T4 l& B6 k7 j                return true;1 z! k9 `3 t- R0 k
        }
0 J4 i! R: b1 N! U. R4 e9 Z+ H) E
} // end of class ProgramCompare
4 ^3 e, K8 v. V9 m" n% T9 V$ A; e/ p* p* c4 ]8 @/ T
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
4 u6 E% T2 o5 r7 R- W; [6 [7 S//  ProgramCompareMenu.java    Provided by: DRS$ o1 K% G3 x9 _" l6 `
//
' o+ L: z9 I- \* O//  Calls AuthorisedUsers.java and ProgramCompare.java
( Q; s' z( j; L' i//" n3 o' O3 c1 b7 B/ \
//  Driver shell for Assignment 2.. U, w8 y# f2 ]! W( W& m! C0 C; V
//********************************************************************% |" |4 Z) f1 Y% `

. V- W( L/ N& N$ h5 Rclass ProgramCompareMenu
. C' j5 d- E4 J1 m9 `" p  q{  O/ k% `% L9 H, d' R: G
    public static void main (String[] args)
. f. ?8 Q" ]) l            {
* |: I! f, m: B/ H+ g                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable) v8 o. ]* g5 n/ d- k( o
                ProgramCompare reached1 = new ProgramCompare(); 5 u/ Q/ k) u  W! }9 W
                AuthorisedUsers reached2 = new AuthorisedUsers();       
. b1 D$ b% x4 r1 f" L2 w5 ?$ I/ z                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
7 ]( T1 A* K9 K  y" n                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        , |* ?, P, R. W1 y* _( d4 I
        }
, d4 {# y8 P8 P7 R/ H}// end of class ProgramCompareMenu/ S: u# O" u9 I9 K1 U& q* y

4 o3 u2 m  r! l8 f//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
- K2 j' l8 b% A# K//          AuthorisedUsers.java          Provided by: DRS
# J3 n0 T# I1 _. l//                ( U" }6 g! n- B( A& g0 X0 S
//         Program shell for Assignment 2+ Z0 h5 [4 ], p3 ~& m; `
//
4 R9 f& C( r: e# n//         Represents facts about an AuthorisedUser! B( U1 |6 T6 E4 C1 z
//********************************************************************
3 k1 W9 D0 X# F8 r4 w& d/ V1 n& r( z2 e; A- ?. \5 x2 N  }+ T
public class AuthorisedUsers% Y' u5 D5 Y2 U' a% P; o
    {
. q5 s8 v0 k( Q. E+ t
$ R  V% Q" r! D$ H% x        //-----------------------------------------------------------------/ b, {. |! t' `) u) n5 R: x
        // Constructor, A, q! [1 \, K8 s
        //-----------------------------------------------------------------' d5 ^! ], |/ S- Z

1 X1 W7 Z$ a% H7 H( E- m        public AuthorisedUsers()
! y# H3 n) d, M5 T) r                {/ D- s2 \+ B1 \" y# I! x
                }
6 C) m5 m1 s4 K2 i5 D
; C! r0 p: D, v3 f; R% l7 Z3 M        //-----------------------------------------------------------------3 E9 |) {% Q4 K" t
        // Method for testing that class has been reached
& j" O- I% O$ K) K+ I" ~) R. }        //-----------------------------------------------------------------       
, {. v5 D8 s5 v8 e- }' y- j# x        public boolean AuthorisedUsersReached()
, |9 _" I/ ?# r" D! U                {; t1 u9 X! I* v. E5 a
                        return true;                       
6 N1 U; z  E  D7 E8 n% j                }
0 u' t! Y  h' w                : c" z$ B: C' W4 w, M, x
    } // end of class AuthorisedUsers
$ L0 Q" T- a( u  Z0 P7 N//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
# |' o& n- ]$ U9 P. N- `6 O+ ^Shanghai - 2007% x/ ~0 C. q4 C0 F
Assignment 2
' l5 n6 a: Z3 n! A! {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)
4 T2 \' y% @3 m# H, C' k+ i+ U1. 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.. e* V+ `5 T4 }# v/ j, c
The staff must be able to:  t, Z0 x1 o( n. y) H0 S( E  H
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
( s9 o: f6 S8 c% J/ {4 D2 A; 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.+ e) D* W" j; Z; D
 The interface should provide a menu so that the staff can:) P$ x% s. S/ K# w- b
a) Enter the names of the two Java program files to be compared
, ]8 G3 [( Y9 s! y% k1 h$ ` For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
6 z. k6 K8 y+ 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).
8 A+ m: q, l. F: w0 j& E7 HBSA104 Business Programming – 2007: Assignment 2
) d3 a& J! r  p6 z/ e2 U# e3 IPage 2 of 51 Z  O8 d, z3 l
b) Print out to the screen all the lines of code that are the same8 _" E, n1 H& G+ C0 G& P: U! y
 Include the name of the file and the line number of the code being printed for each of the two files5 A& A2 C' X) H, ?; A
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared; L# w" d/ W# W# {4 M; B
 the name, username and department of the user
$ N# j2 P  u- p5 Y, \6 w the statistics of the comparison3 O2 W* @+ g  z2 X
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different9 e6 B5 l; S3 c9 N+ c: b
 the recommendation for further checking$ x% j; {7 d" b( y4 `8 {% a" v
- 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 closely9 L4 ~$ R" F6 ~+ X: t& c) v" Y
 the names of the two files compared
; N- X0 }1 o; b5 Nd) Leave the program (exit)
8 n6 A  R* e2 l6 v* ~The ProgramCompare class: (Total maximum 20 marks available)
3 K3 q+ D. e2 ~! C- b& T5 o2. 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)
. n, j$ Q' X8 M# F$ ^$ t$ Oa) provide an error message if the files are not found or there is a problem opening them; R% k# |2 O8 }: E. A/ y# Z; y" D
b) compare each line of code
) i3 ]% B2 W4 H  y+ cc) print out the lines that are the same" v  Z1 w5 z1 b
d) count the number of lines compared / lines the same
, B7 n$ |7 c9 b: qThe AuthorisedUsers class: (Total maximum 20 marks available)
5 P. B3 f2 f8 F7 C" ?; L; B! ?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)
& Z9 R2 U& q% H1 z! \  c; _6 z( l/ B4. Provide methods to:# N, n" Q$ r1 |" Q! C
a) 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
! j& L$ l& s" u; G6 s  {% @b) return the name of the authorised user
' G% R7 v6 @2 m3 Ec) return the name of the department of the authorised user
" g9 p. C: [5 YIndividual Data (Maximum 20 marks available)( N4 f4 J0 @4 p
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., C7 q# a+ a7 d4 U+ s4 J+ p
Documentation (Maximum 10 marks available)
; Q4 b0 Z/ }$ r2 f6. 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.' }- z, A# h1 ]* I0 L
BSA104 Business Programming – 2007: Assignment 2
/ O% }9 p0 {; u- E* K# F1 `' d$ XPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
* l& P, z" a2 F6 d不过你要翻JAVA的类库说明。你有下载没有?
  B  ]9 g+ |- R查询关于对比的函数。貌似关键字是contrast,还有compare
/ b9 d  Q- I; F, Z9 p) K
& @2 z; B$ g0 K% c[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -& q8 i& }1 \/ |/ H+ H$ z
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
8 `' R8 B) u. i7 m8 a  l* ^可以下载到的 是 jdk-1_X_0-doc
0 R1 }" A3 b9 I" d5 d, o  U" @" B: S# _* R0 d
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-7-12 09:56

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

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