找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1630|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 1 c0 A# }8 w3 W3 b: [' ?2 i. F; f& B$ d! e8 F, A% x& e$ @9 K
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
& S& y: n* {( W" g0 y/ [5 ^//  ProgramCompare.java         Provided by: DRS
. `' {8 q1 ~1 {" x, c$ h- t//$ W% X6 X  u2 i5 l/ l% J! |
//  Program shell for Assignment 2
& Z& b+ D: e; ?# r$ `5 [9 _$ q: w//
+ ~- ~! @1 \7 L$ {  f: ^8 b//  Compares two text files line by line
1 f9 H7 P  S6 O% ~3 Z+ R: D0 N; b! v. M//*********************************************************************
( k/ n8 \( I4 }8 G, H6 ^! R& N
" t5 ?$ E  w( U9 a8 U. Ximport java.io.*;2 |9 i. `. g* o4 A

; K9 d8 @) L! y) `9 |, wpublic class ProgramCompare
3 Z0 \2 c# @4 b6 F% P{
3 s7 U8 c, |) w        //-----------------------------------------------------------------
( |' z" L# h0 f  F" V* X3 T        // Constructor: m9 P% E8 A1 p) Z# F5 W; r9 _
        //-----------------------------------------------------------------
( L7 J$ ~$ r/ `% ?# e        public ProgramCompare()
+ ?+ k. R' Z  c- k% @        {  t. e5 `# n' b! }7 e7 z1 m, y
        }8 F3 ~8 r( L7 ^+ k' z1 t. V+ H. X( m

$ K  m' O9 \% D: i2 o. `        //-----------------------------------------------------------------' ?* x- K) r0 O! h* W$ b
        // Method for testing that class has been reached
1 \( v) ]7 `* _& Y# _9 n) T        //-----------------------------------------------------------------        ) I  a1 [0 x8 n" a
! U5 s+ ~7 {, X+ {- w
        public boolean ProgramCompareReached()           u# i  G8 k9 j3 J" Q! y
        {6 }0 T) Z4 ?% @
      try
$ W7 I3 ^! N% n   {         6 I6 f9 f9 _7 h; _4 U, I; ^( o( \
                       
% D# o7 Y& M# c, l: p/ @: R                //********************************************************************0 |& ^. k9 D  M( [  K# v
                // Try-Catch Statement is used to handle exceptions - such as file not found
& b& m# \8 Y3 G1 L, h7 \! d                // Reading the files will need to be placed inside a Try-Catch - just like this one!) F8 l" Q! ]  s
                // For more information see page 534 of the textbook1 I: Y8 h' q7 O
                //********************************************************************; n2 }7 Z9 W- ?- C3 N9 o" s
                     5 ?& K) T! s# V: R+ `
        }
+ k" U! f! L6 P5 g# X             catch (Exception ex) // Exception caught here and message displayed to the screen
% y0 e! u$ L  A          {
/ O  e9 D& g1 ^5 [                    ex.printStackTrace (System.err);0 E7 |9 c( S, [8 r& D
           System.out.println ("Error message goes here"); // Replace this error message with your own         
, G/ p1 o! z! }        }+ @- D4 y2 H$ R. m
                return true;7 I! t1 `  R4 n% b
        }+ y- K) i$ J( i- d  z! x- K4 D

4 S5 E$ H5 P* r} // end of class ProgramCompare% Q% u/ A& s9 |  F

0 M' e. ^# ~) q0 E1 F2 S  B//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************0 S  Q0 o! f7 A7 p
//  ProgramCompareMenu.java    Provided by: DRS, X/ W6 ^( c/ f) D$ E
//) S. H+ U, Z6 ?7 N! @6 Y
//  Calls AuthorisedUsers.java and ProgramCompare.java
4 Y5 Y  x5 g$ f  ]! l4 [//3 o+ d  I5 ^' T$ K+ j. l
//  Driver shell for Assignment 2.
9 z2 A8 p' }% a( `, ]//********************************************************************! ?. V/ V& y7 J0 F! Y4 Z* L

1 k: h% j+ g# y! yclass ProgramCompareMenu7 o8 p# @2 d; e! w4 c/ H4 d
{
: t. [/ Q& C2 w, Z' ], M    public static void main (String[] args)
2 Z  \2 ?/ D; w            {- F  ?& ?- o5 b2 X
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable( E$ I( z2 s* t( \5 k. ]' Y
                ProgramCompare reached1 = new ProgramCompare();
  o! X& e  [- d2 ?' W                AuthorisedUsers reached2 = new AuthorisedUsers();        ' R- {1 s( B" L9 b; }
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
+ T; ^7 A; t; S' ~* b+ S7 T                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
+ y- a! v. E% N, ]        }" }% }# u3 P6 E- \: O: Y9 w& o8 Y
}// end of class ProgramCompareMenu; @! q1 u: J7 K( ]7 Q
* o. O$ o7 N$ K* {/ u% m
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
: b/ t1 u1 ^2 L/ l1 w6 |7 m+ U//          AuthorisedUsers.java          Provided by: DRS" N: f* z2 y4 U5 M; ?* _4 G, A
//                  X; ^; J1 J6 w& W6 ^% z$ X% g0 B
//         Program shell for Assignment 2- g- h$ L' ^) \, P7 }9 L5 R6 y
//) S& u3 H; I' ]& k, F0 E
//         Represents facts about an AuthorisedUser& B7 H# S/ J+ t& C8 [* S
//********************************************************************: Q8 [7 d0 B0 x& X7 k
% l) f7 g) x  {) q
public class AuthorisedUsers
3 @, H* Y& o7 k* C( a6 L    {% m' Z0 g% C  c4 p0 W

3 m) `$ x  T4 b2 E' \; G5 e        //-----------------------------------------------------------------
0 Y  h+ }& d1 h. h4 w( s        // Constructor/ @! D1 z" `; @
        //-----------------------------------------------------------------( V4 M! r" u4 o- _  f- g" N% K! q

; x$ E# i) R- o  x* w% c* |        public AuthorisedUsers()' K+ W0 d3 H' S, `
                {+ H: H* ^1 R( \! k5 n  @! B& m
                }
& i# F: _0 P" n- N$ Z6 d! l' N  S( b' M& O
        //-----------------------------------------------------------------: h6 p5 N8 ?( E6 F: q" H
        // Method for testing that class has been reached! E! u8 |/ `/ _4 h1 g$ R7 N
        //-----------------------------------------------------------------       
8 f3 N3 y6 r4 L        public boolean AuthorisedUsersReached()
9 c  A6 E4 J& D* e                {" w! _! \6 z, @! V+ D1 x
                        return true;                        0 B7 {6 p5 H2 k: j# P
                }# a% h( q! U4 s# }" X1 \
                + N/ z0 _8 Z) N0 y
    } // end of class AuthorisedUsers* o: h3 Y  I: z- W* m  M
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming+ J  L! j1 q8 F: F6 U2 c1 d  `% E
Shanghai - 2007/ e9 `& i2 A8 T7 y
Assignment 2
% Y4 m3 {2 x  V  g$ xDeadline 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)" O, c# z2 L3 b2 \6 ^
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.' w% g. z9 C! [( M8 z, F
The staff must be able to:& Z* p+ G/ p7 V& S
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **., K0 ]1 b; U! g. n. P
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.
) x+ q; L" S% U: c The interface should provide a menu so that the staff can:5 t& o6 r$ g2 t
a) Enter the names of the two Java program files to be compared
: [' m  A5 ]' D5 T# W  Q! m For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
8 Z; `& k! W5 B" e& F! V: x3 i- u/ 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).5 @/ U/ Y4 A' U9 R
BSA104 Business Programming – 2007: Assignment 2
. q, |) q# Z; j8 n3 N! ~Page 2 of 58 Z1 g4 j; W8 j' V' j
b) Print out to the screen all the lines of code that are the same0 d6 Y) Q/ q& V
 Include the name of the file and the line number of the code being printed for each of the two files
* c; B: x) v6 S; o* O" Jc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared" `8 }8 x5 V0 X1 C
 the name, username and department of the user
6 M) U0 \5 e5 A) D' S* f2 n" D the statistics of the comparison3 ]2 b  O4 k& i2 a" K& k! R* s5 M0 {
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
: r' E: S+ n7 ? the recommendation for further checking
; B2 t, a$ u4 m& I" S) T0 L- 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 \5 B) M, G3 L! O+ w4 d/ Y
 the names of the two files compared
: \7 Z) [9 H9 E+ L% Z$ Cd) Leave the program (exit)5 E; z+ f6 U( A$ C
The ProgramCompare class: (Total maximum 20 marks available)
" t/ y) y4 {3 E2. 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)6 r" K# L9 {0 R7 B6 s% \
a) provide an error message if the files are not found or there is a problem opening them
# C# Z. Y& z( }# gb) compare each line of code& ^$ w4 F* ~: Z4 ?$ ?7 A! L
c) print out the lines that are the same
4 x1 |. g5 C' P% Rd) count the number of lines compared / lines the same, O% {$ \. l. R. k
The AuthorisedUsers class: (Total maximum 20 marks available)$ P/ {) V# C9 j0 `6 O) {, b3 o& k$ P- 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)1 Q8 B8 e( A9 p5 ]
4. Provide methods to:
8 Z2 `5 x; e# K( 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; s- {, P/ ^/ ]: t1 ]+ p
b) return the name of the authorised user
3 z- h8 }1 m1 [0 Jc) return the name of the department of the authorised user. G; U& F9 s9 O0 Z8 t4 O8 k! l
Individual Data (Maximum 20 marks available)
/ I1 C) L8 N) Y$ ^/ e5. 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.
" W( J+ X3 E: r/ K5 LDocumentation (Maximum 10 marks available)
3 i4 V5 c% G$ M% Q6. 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.
6 q9 _: C3 V2 y2 E, tBSA104 Business Programming – 2007: Assignment 2, u. H& h3 ]$ u: @( P
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
" B5 l3 `4 I, X7 M不过你要翻JAVA的类库说明。你有下载没有?
. u" P; R" V" {7 T查询关于对比的函数。貌似关键字是contrast,还有compare
6 X1 M8 ], S7 F( @/ X9 A7 r* {) Y, p2 P( h  k1 o8 e
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
4 [& Y$ i# {( [0 B" ~7 u2 t痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
: m  v' w5 q; e8 h1 N- u可以下载到的 是 jdk-1_X_0-doc! t8 L. h6 @) \3 k
' j5 ?8 N. k; }- a/ i8 c6 ^
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-15 18:55

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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