找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1101|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急% \6 ~) T! j# X/ I, j+ z5 V+ U' w 3 g W) V c! N3 z+ Q
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
  L6 D3 @5 b5 `) t//  ProgramCompare.java         Provided by: DRS! L' [, C/ p; @0 A8 @, R, R& B! i
//
# L2 g) e4 z3 h$ [& P//  Program shell for Assignment 2# v3 [7 p1 m3 t& j
//
+ V5 a1 L4 E5 X! V* l//  Compares two text files line by line
" d* M+ A+ M8 f2 k% {5 G( Y6 o//*********************************************************************2 I% `9 M8 L6 L6 l3 ?7 A

2 T8 R& B. u' O$ ^import java.io.*;; v3 i. y  _! H3 ~/ l( z
7 j1 J, m% s3 L0 V  B5 f. h% E
public class ProgramCompare( `3 B4 ^% S* R& C
{8 ^# t7 _& Q9 ^
        //-----------------------------------------------------------------0 o! g7 q; v; c8 D8 p
        // Constructor
8 l+ t6 o" g4 Y. g4 l! m1 a        //-----------------------------------------------------------------
/ n- J* n3 q: G        public ProgramCompare()' T; P# i/ G& m; c1 e+ A( s3 D
        {, Y% O: Y& D: b) `; u
        }2 h8 M! y4 B5 ?* _8 X5 \" o: u0 Z

6 j# ?% S" {3 \2 m        //-----------------------------------------------------------------3 i1 q2 R2 i1 R5 s
        // Method for testing that class has been reached
4 P, c1 r$ d2 J; X: U2 u! ~5 z        //-----------------------------------------------------------------        * c) F" h' ^+ M( w' g6 H; f

2 {# s& Q+ a8 E8 t# S% l+ j# L        public boolean ProgramCompareReached()        
$ f2 U; P  i8 B; F' T8 f        {; D8 _+ s4 Z4 s) [$ w1 x! a5 O! r' J
      try
# m' n  Y. x5 Q7 J# F# d   {        
$ l) z, ~% n  L. K8 m  x+ z                        ; j4 m+ K! F3 ?# p) `* c. P
                //********************************************************************" r% f! x  S* S; _( }5 s- q
                // Try-Catch Statement is used to handle exceptions - such as file not found
: k+ x3 i  g2 z  {                // Reading the files will need to be placed inside a Try-Catch - just like this one!* I3 @3 V! W' k0 P
                // For more information see page 534 of the textbook
, U8 w( Y0 X/ Z. g+ ^, }( i. y1 L                //********************************************************************/ W" S: v/ Z0 l
                     " F. }$ X# M/ ?0 F
        }
) q9 Q, l) a6 \) J# U; M) O) B1 F             catch (Exception ex) // Exception caught here and message displayed to the screen
" \& f8 p" N& {: J* v% H          {
& y# |: `3 p# s                    ex.printStackTrace (System.err);6 U3 A) I* n2 J, Y
           System.out.println ("Error message goes here"); // Replace this error message with your own         
; z* h) n  A4 V6 ~        }
0 F. a- i+ P1 q1 N0 ~/ l                return true;3 t' K' G" f5 P$ ?: H4 J) U: B
        }0 d* _6 I4 Q) ^8 N
3 M0 I0 }1 Q' ?2 G' t
} // end of class ProgramCompare) g5 T" }& ]2 @3 [: k/ Q

# O9 R8 |3 S. c8 Q6 P//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************- a1 J1 D' k0 W7 D- y8 A
//  ProgramCompareMenu.java    Provided by: DRS
& E4 f& {# c4 O5 g; `//) e9 I* Z2 H9 r5 l5 G4 `% ^6 p  k+ A
//  Calls AuthorisedUsers.java and ProgramCompare.java
) l6 a5 o# ]; U2 @( g, n8 X//
4 N7 k! M% L7 d, X8 @( J9 t6 b! x//  Driver shell for Assignment 2.
4 n9 ?9 ?2 u0 j" E& D3 P//********************************************************************
: \- x+ P) R) T( Z) R0 I2 K
  o  m8 q" a7 s. ^% Mclass ProgramCompareMenu
  g" Z9 f: n* _! C{. \; R; `8 _& K3 s/ i) r
    public static void main (String[] args)
7 p" k, [' w- K* b! n! L            {' O2 X! J) z2 Q+ n- K7 X
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable/ t5 O" I4 u0 o& Q1 c/ V. y" p6 C
                ProgramCompare reached1 = new ProgramCompare();
4 l7 g% m9 v0 B+ E) e: H                AuthorisedUsers reached2 = new AuthorisedUsers();        , S( S0 t0 J0 q, Q. Q
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
! w, e; l$ p. T2 s                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        * z, N. ]1 r6 H# N9 Q( s
        }3 L0 K+ ^' ~3 C
}// end of class ProgramCompareMenu  }* ]4 x- [- P2 G

) h! |3 G% {2 M" O/ c: ~//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
1 W) Z$ p, x/ x) _# x! Q//          AuthorisedUsers.java          Provided by: DRS0 C2 s# z& ]6 V
//               
: [1 W1 e% S' w& {6 H//         Program shell for Assignment 2' Y$ J5 B1 G) X. q
//9 d9 \+ S1 H6 r" A* h
//         Represents facts about an AuthorisedUser
/ C/ ?2 h% w2 x//********************************************************************
, ?( z1 D- z8 A2 U- `% s, f3 Z# n* g8 l* q( p$ j& G' K
public class AuthorisedUsers
6 B- w+ x% q4 b  S: J0 s6 N( |& ~    {
$ Q/ N& I/ j5 C! a9 E' Y5 ?" L' A+ R6 m$ Z2 l
        //-----------------------------------------------------------------
/ x- {6 H; d6 Y, l: c        // Constructor
! U2 e8 p3 C) k& K& A        //-----------------------------------------------------------------) H' L) W) e, `# v' ]( g6 e* ^

1 G* ^# F/ S. j0 N1 X; N! Z        public AuthorisedUsers()
; y+ X3 J3 ?0 Q! n; L5 j" W8 U+ _2 J- ^( o8 M                {# U  I4 S$ o* f3 S+ U; w
                }
) s5 G3 B4 o$ E0 r( v9 ^
2 R6 h$ F3 T# U        //-----------------------------------------------------------------8 d* Z6 E# D% p' z& c) w; Q
        // Method for testing that class has been reached
: V* c* F5 h& T8 i& _" B        //-----------------------------------------------------------------        & J  f" O, N$ u* f8 J4 f; d: R
        public boolean AuthorisedUsersReached()
) Z' \& y; P/ Y9 m; B. j8 h                {/ B( B( n) d# h
                        return true;                       
) A+ S) S& b. C- A0 J% y                }
7 A$ ?9 D+ K- Z" u9 H' N               
9 y2 H: N3 T# i6 m) u4 A- A  I    } // end of class AuthorisedUsers, q3 {, |: {7 @: U) H6 N
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
# q/ E  c* K: Q+ \/ `/ I6 E8 oShanghai - 2007
+ y4 p/ o1 i9 [7 cAssignment 2
$ {% m0 Y2 T- A# s0 G3 N5 R3 Z+ aDeadline 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)6 _- l% W- P% o0 C& 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.- W; K0 F& [( X8 R! n& L! l+ C
The staff must be able to:5 Y2 I. ^- D% O% \& |$ _( c
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
& M" q" Z  K4 y* ~8 R. 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.$ f7 g/ R6 d8 |# g
 The interface should provide a menu so that the staff can:
' O% G8 c1 L. t; _' k) W/ L' Ea) Enter the names of the two Java program files to be compared
  q2 T, j( t% A For this assignment, it will be assumed that the two Java program files are in the same folder as your program.. x& O& N8 m1 `2 i" O
** 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).: D3 ]6 |  D& t5 [/ H
BSA104 Business Programming – 2007: Assignment 2
' W! Y4 Y9 r, u4 K9 mPage 2 of 52 ]5 W. V' U6 G
b) Print out to the screen all the lines of code that are the same
6 o" R8 \5 a) n Include the name of the file and the line number of the code being printed for each of the two files9 B& T/ O" Z5 T% C
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
: _4 E. }( C0 A5 ^! z0 e# } the name, username and department of the user
+ z% z, d% Y# e  T; A0 P8 d the statistics of the comparison( B+ b7 R0 q3 I& Q/ }1 e: t
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different( Y+ V7 |0 |, l4 h
 the recommendation for further checking
8 A. Z; u7 S* n3 k+ B$ @/ 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 closely
( ]& L) n0 c, K( v, D9 O the names of the two files compared
+ a6 D* y; x, \# h. k  Qd) Leave the program (exit)6 k$ b% Q* A4 H
The ProgramCompare class: (Total maximum 20 marks available)) A8 W1 x" T3 T: V4 L" d
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)+ m1 F2 x' f+ ]# P! |6 T
a) provide an error message if the files are not found or there is a problem opening them- E& D/ k1 }. \6 ~2 E. {
b) compare each line of code6 \# u1 S! u" i, p& y; }- d7 @
c) print out the lines that are the same/ R% F4 G+ V/ y0 M$ A7 I
d) count the number of lines compared / lines the same
1 Y: Y$ d- V8 ~The AuthorisedUsers class: (Total maximum 20 marks available)! o9 w$ Y) s' |5 {9 f8 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)# \3 X' x+ Y2 d  F
4. Provide methods to:
3 ~) X# G1 v8 l) aa) 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
( W& K6 e) s& wb) return the name of the authorised user
2 @. j; g4 q: [c) return the name of the department of the authorised user, q( ]% m2 d1 r  r( R+ o: @4 w
Individual Data (Maximum 20 marks available)
% i# ^/ ?3 _) z2 u" 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.8 h. N  N$ b* a2 n$ w7 R1 c  V, Z
Documentation (Maximum 10 marks available)
7 a& a, n% Z! Y& s. c+ r6. 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.
5 V+ Y% L& b1 b4 KBSA104 Business Programming – 2007: Assignment 23 x5 ^, _0 u9 k* G
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
. p) h  D# b9 U$ ]/ ?7 V不过你要翻JAVA的类库说明。你有下载没有?& Z: n$ D9 D5 V5 @, `
查询关于对比的函数。貌似关键字是contrast,还有compare
) `; s: v5 S5 n2 M, U" _9 z- h; R7 _# G6 N1 ]' _. {9 }0 T
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
# M% a! \9 z, V9 _; h痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。' T0 \/ V: g/ w: l/ `/ Y
可以下载到的 是 jdk-1_X_0-doc
5 j  F5 V8 d% E: H5 a5 |' T' F5 t6 x! S( N' H3 V
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-3-8 06:58

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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