找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1196|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ( ?9 n1 G; e6 ~) F7 a 6 z/ V' R V$ j% l. |2 X
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//********************************************************************** Q. G2 s9 ~- J' k. O2 U
//  ProgramCompare.java         Provided by: DRS
  N5 x! A- o6 ?; P2 s//
0 V4 t  E1 U" @3 i( Z$ J5 c//  Program shell for Assignment 2
5 N5 C4 h" c3 t1 U* N2 B+ m5 x' \" Z//
8 H& C# v; ?6 |6 W: N5 S( E//  Compares two text files line by line
$ X0 b* _0 H/ W# X$ k9 i2 K//*********************************************************************
, A0 W- d+ U. ?' h& |( M/ B  c+ M
3 Z& E$ G$ j% c' P  uimport java.io.*;2 L6 v- [8 p) Q! [4 s# G

+ N% o! u" ?+ U+ `/ v' Ppublic class ProgramCompare
+ l4 s  \1 T; Q6 l{! ~, H$ @/ t( `; }
        //-----------------------------------------------------------------
% x/ Y# _  J' s2 S* F% p6 z        // Constructor
7 x, E" p% X0 d% _        //-----------------------------------------------------------------
( ^/ G3 {" G7 P) j  q        public ProgramCompare()- i$ s3 @5 n. t5 Y( k" q) d
        {. f' r8 q  H7 ~4 D$ o
        }
* ^0 [- O9 I% Z" g4 n( D. \. V% ]
; q6 r, Z  Z7 ?8 f4 H! e( |        //-----------------------------------------------------------------
# w( D( _9 n( B        // Method for testing that class has been reached
$ x. u/ }7 b9 i0 `5 C3 C+ E        //-----------------------------------------------------------------       
# q# i, g) n8 _, q/ T: n; I$ E
# k' [3 \- d" ^( W/ ]8 Y' Y; ~# Y        public boolean ProgramCompareReached()         5 t8 {; @% j* S- J
        {
3 o7 g7 F! ]0 N& E      try
8 I5 a$ R, b4 A+ Y  [   {         : C9 f& [) M: ?, Z( a- Y) w
                        ! h3 `9 V$ V/ n5 W& b1 `
                //********************************************************************7 N6 V0 }' }) Z5 H# U/ Q) H
                // Try-Catch Statement is used to handle exceptions - such as file not found - B. |: q4 B% p5 U
                // Reading the files will need to be placed inside a Try-Catch - just like this one!2 ^* k: g7 Y. w/ f# N. z. @
                // For more information see page 534 of the textbook
/ L5 J1 [( g' _6 g                //********************************************************************
' v6 d; y7 S8 s, }8 |: `                     # D# E, q, d! e- i2 v' d2 ]) X
        }# x% y* H% A$ G( r; H
             catch (Exception ex) // Exception caught here and message displayed to the screen + g/ {! G% U3 K. n6 u
          {1 g9 [) `" G4 n: A: ^' q7 [/ U
                    ex.printStackTrace (System.err);
, ?( ]1 G6 }7 P6 {           System.out.println ("Error message goes here"); // Replace this error message with your own          3 s, D6 S/ L' y4 S5 b' ?
        }
0 X: U# }4 L5 U                return true;1 V, @" A3 _: A
        }
1 G1 z: Z% @' j1 |; [/ q* p9 {6 l+ n2 i1 I
} // end of class ProgramCompare
' W( n9 r* o; S' p
: q) I/ `1 U/ C//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
7 J  g0 v, Y0 L! @//  ProgramCompareMenu.java    Provided by: DRS" l) A. G/ _/ _  r* I8 P& x
//
2 a+ h' R/ `: T9 x//  Calls AuthorisedUsers.java and ProgramCompare.java
' K0 |% e. d( H" |//3 C+ }! n( s8 P$ Y
//  Driver shell for Assignment 2.
7 s; [4 d! Y. M" Q* P6 ]: r6 }//********************************************************************' ~, r: ?- f& h5 j3 p
6 ~. o" A; ]% }3 Z. d4 y6 y
class ProgramCompareMenu
. M% p' J- U5 }" |& X+ _0 w: w{
% w6 U- Y) S0 i/ k; z9 l! k    public static void main (String[] args)
  D2 b5 F, w' F8 @6 X' n9 B% K            {
1 q' L6 [8 K' H% S4 i. \! N                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
& J* u  J! m/ F$ ^- o' I3 ^, r                ProgramCompare reached1 = new ProgramCompare();
" g3 p) Y8 o( k; S                AuthorisedUsers reached2 = new AuthorisedUsers();        9 j, q' T1 a: O! s  ]8 V& Y
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
6 @1 u  J5 j* Q3 Z' ]6 B/ W; J                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
1 |4 u& q- J8 F# U/ y& H        }
, ?- N/ [* Q8 j! O4 z4 }+ [}// end of class ProgramCompareMenu
6 k) |/ S* N6 c4 @. H
- r/ F8 |1 O1 }7 _3 _; i. O- _//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************" r, t4 Q& X5 R. A5 @" [0 d2 C
//          AuthorisedUsers.java          Provided by: DRS5 x& J, q( R2 f4 H4 U$ W4 p: V: a
//               
! W; i+ R* p4 {2 o9 J7 ?( h- ^, B//         Program shell for Assignment 2
  x0 }5 a* U/ r+ q$ |+ R* f8 g//
/ ]: `, s2 Z. f, X6 \//         Represents facts about an AuthorisedUser. h! f8 Y: V6 S* o, X7 @
//********************************************************************; a3 ]) j1 f+ k$ F: P+ {% |

9 L# m, U/ ~  D( ~7 o/ {* Spublic class AuthorisedUsers
" E- K* J  a* O" o) N5 x9 U: p0 B3 Z    {$ Q! B1 J0 Q, L2 L- {7 A5 j4 k

0 l. s7 W* P  }- e3 r: ^- f! i        //-----------------------------------------------------------------" t2 k' @) G6 K6 j2 T3 b% L
        // Constructor4 ?  k& A! ^( S6 |" v- V
        //-----------------------------------------------------------------0 |. y  w3 e# s0 I) P
( o/ p4 [+ w5 ~1 }# h
        public AuthorisedUsers()5 p8 k: S9 [1 t/ r* n
                {+ b& q% O, {, M+ V  c; S9 G
                }' }" ^4 F+ g* @' E5 R0 o" _5 J
! }3 e$ R" x6 Y
        //-----------------------------------------------------------------3 j) O, i7 {5 }3 H
        // Method for testing that class has been reached# m1 e+ @" \/ L8 }7 e
        //-----------------------------------------------------------------        8 j0 x1 R6 s3 X( Y0 c1 }
        public boolean AuthorisedUsersReached()
5 o5 A) e+ y* f  @) _7 q                {
2 N+ S$ J8 V, W' l! C; J1 W6 I" B                        return true;                       
8 n2 z8 Q- Y: Y. |7 D                }
$ K2 Y* N/ }7 s& E               
( U% X. J' [, N- {7 s0 v' A% T. Y/ G" Y    } // end of class AuthorisedUsers3 C7 L; H1 |% e0 v
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
: G2 O6 y0 J: |, O5 `( v4 M  NShanghai - 2007
9 z1 ^1 ~" P; G. g1 uAssignment 2
0 H& j( s* K9 E2 p4 ]: uDeadline 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): L* D" _% C7 w5 x% t& y
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.4 R: ]5 N" V/ f4 `1 E5 j: r
The staff must be able to:! O+ B3 N5 p2 @5 @" o
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **." a9 y5 ~7 w+ L" M* O( j
1. 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 b% \/ h. g  ^* S4 t2 ?4 j; h  o The interface should provide a menu so that the staff can:4 j0 O# g9 m* @$ A( |
a) Enter the names of the two Java program files to be compared1 I3 p3 h$ M, m! R3 G% S
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
2 n/ @$ x+ V2 _1 `. y# @** 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 U0 U# F: |' C8 L
BSA104 Business Programming – 2007: Assignment 2
  A) w8 U0 R* q8 f. x+ d5 x* l2 IPage 2 of 5
3 M" [! P. C* ib) Print out to the screen all the lines of code that are the same
5 U& N9 _/ [& X Include the name of the file and the line number of the code being printed for each of the two files5 D+ N! N/ b6 O5 |8 ^6 f8 \, V
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
; B+ M- D) s/ H! m, _ the name, username and department of the user5 ]' q' L- G! ^& V+ A
 the statistics of the comparison
0 x2 V$ H4 G0 n7 i) Y+ ^3 \- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
" D3 T1 x( ~# l( b1 b) w2 E' @ the recommendation for further checking! Z* T! T# I6 G
- 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! f2 b: P0 M  a+ @' M4 x2 j; g7 R
 the names of the two files compared% x- z( I# p/ A2 C. `
d) Leave the program (exit)
' m) m* L3 X/ E, i- a. x0 P0 OThe ProgramCompare class: (Total maximum 20 marks available)6 W& S  T/ {6 C! q( c, Y$ 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)
9 \2 r7 ?" k2 Za) provide an error message if the files are not found or there is a problem opening them2 c, U* k, G2 Z; I0 M0 B
b) compare each line of code
, `2 ]# a8 G  Ac) print out the lines that are the same, c. L! n: {! k2 n8 l' m
d) count the number of lines compared / lines the same
6 s* J$ [8 l* L& VThe AuthorisedUsers class: (Total maximum 20 marks available)
* t* I4 u% L2 b1 M" V9 y' [* L/ t- u! c: l3. 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)
* H  `# \# T1 u" R4. Provide methods to:* B& K# s1 o7 f6 {. [7 k
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. n. i, [; v. ?' ?; F" I
b) return the name of the authorised user) K7 j- g/ u( O1 ]; E: f" {6 {
c) return the name of the department of the authorised user$ a! `" R/ D* t; n
Individual Data (Maximum 20 marks available)
' t' u+ V/ A0 O% c2 j; ?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.
+ N* \4 V+ \7 X+ lDocumentation (Maximum 10 marks available)" l2 i4 h# z1 ?* H8 @: E5 I7 x
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.; g6 D# P# ~' t0 w6 n9 L
BSA104 Business Programming – 2007: Assignment 2
/ g; u2 ?, o6 l6 F/ H9 @Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了9 l3 f9 g, F9 `/ ~* ~6 t4 h( C
不过你要翻JAVA的类库说明。你有下载没有?
) C& i. u% Z: n2 w  X查询关于对比的函数。貌似关键字是contrast,还有compare5 B$ V+ R$ L! K2 w/ \  {

) \+ k& C, X$ [5 P3 I3 p+ s/ f. b[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -2 `  n6 g( [2 _
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。% j. A8 J" ^5 f1 W# D( n; Q5 y$ r% ^
可以下载到的 是 jdk-1_X_0-doc
7 _. h8 w; d) v% q  B1 C4 p: q, [$ |( T- f' {
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-15 11:02

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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