找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1210|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 / n4 D4 V R2 n. J" K 4 M2 z( {* c2 ~5 Z" h
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************4 A* p4 B1 D( j
//  ProgramCompare.java         Provided by: DRS
1 n3 D1 |+ F: Z0 n7 a! S# z5 v//2 l0 ~0 \# x# L" R
//  Program shell for Assignment 2' X& t, F, H5 P8 n; G
//8 b( R& ]. s6 b, W4 D
//  Compares two text files line by line
4 c3 B5 V! C# }* t0 ^//*********************************************************************
" }3 ~5 n6 b$ V2 k6 M) f1 D5 M# u
2 s: o( W1 H! Pimport java.io.*;) ]1 b9 V' I* i* z
  G1 I4 x: h! M7 p$ R4 g
public class ProgramCompare
+ b" Q9 e/ E. q& Q- ~- A+ m# q) F{9 X5 e* B0 i+ Q$ b4 J2 p% g
        //-----------------------------------------------------------------
! n+ I3 s& s2 ~1 r5 v( J5 r        // Constructor' o$ L/ o' b& o
        //-----------------------------------------------------------------
# I* u# Q3 e& v- O* w& U- c; Y        public ProgramCompare()
( W4 W& u5 O. u        {( K9 B' o) b7 ^$ Q( {8 i; ]
        }5 C3 O9 k3 x$ |

( S- v7 m9 r( ~7 \( J        //-----------------------------------------------------------------
4 W" Q9 Q1 i  V: l9 ^7 l" `: @        // Method for testing that class has been reached1 ]* z0 }8 d8 L4 I4 R
        //-----------------------------------------------------------------       
( j. J5 S; G6 b
8 v. J5 z" ?4 G% j& I4 R7 q        public boolean ProgramCompareReached()         7 A  E* p; @- A. b. X0 T: e! _9 Q$ E
        {, b% E: {* ~  T
      try - a" t) z7 S+ a  ~0 Z6 B2 ~
   {        
3 p0 |9 F8 w  f3 x5 A# s& }                       
6 D: k- i5 k4 ?/ V- m1 m- x% R( p                //********************************************************************
1 Q$ X' V4 ?2 Z, Z3 `. ?1 S                // Try-Catch Statement is used to handle exceptions - such as file not found
4 R" O( J, p, q/ Q. Y5 c                // Reading the files will need to be placed inside a Try-Catch - just like this one!, Q+ U. M) `! o5 J4 p- `
                // For more information see page 534 of the textbook
! V5 E5 O! K' C, {9 A                //********************************************************************; S& |: x6 `5 w7 d3 V
                    
. T5 g1 s+ X" @; \+ G        }
  `' b# @, O0 f$ h/ m             catch (Exception ex) // Exception caught here and message displayed to the screen - s: Y5 ]1 L1 g9 L
          {+ S( ]( ]' _: _  k& h. S2 l
                    ex.printStackTrace (System.err);
. `+ p) C& S+ V% k           System.out.println ("Error message goes here"); // Replace this error message with your own         
2 y, A& h8 [4 P9 a8 `        }4 V" T' X: U+ J8 k
                return true;
0 x) b$ L7 x" M' e& v6 n2 R) B        }
) y4 l( X) x/ h8 r. ~6 }- A6 e; j2 k" @/ N+ ?9 [
} // end of class ProgramCompare3 |6 l, Y- L7 U' N3 Z

3 m, u, R0 h9 f) K( D) h. A//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
/ x# `8 z3 e) c3 d//  ProgramCompareMenu.java    Provided by: DRS
6 y2 w# l4 n6 l! f6 w3 o  w//  F6 E: O$ o, y% d, @
//  Calls AuthorisedUsers.java and ProgramCompare.java
' r( ^; S' ]% R# ^//5 P3 R4 J0 B, V) H5 Z* l; w3 x
//  Driver shell for Assignment 2.
$ @( S4 |) J# d9 o( f7 H& |0 J//********************************************************************
- x* z# s0 z" w9 u! M" X- Z* D
) r4 G, O2 t4 P9 C* U- Z9 U% }& b( ]class ProgramCompareMenu
/ F! `. P% F  `$ Z{
6 \: n$ |5 n$ L/ r$ l! V9 G/ z, a    public static void main (String[] args)1 T9 y8 A# f- E% U; r
            {
5 [, u3 {+ A  H" N- t  j                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
$ ^$ o2 P, V% K( h6 \' l/ c                ProgramCompare reached1 = new ProgramCompare();
% a& F) m2 p9 j1 W1 X2 f                AuthorisedUsers reached2 = new AuthorisedUsers();        + H. q* @% u! ]. ?$ `
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());7 C- n7 J+ [- }8 C# X! Z
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
1 l3 k1 y. z  X( {5 Q        }' `5 T5 X' c0 c! q
}// end of class ProgramCompareMenu" o3 Q8 g+ ?1 ?0 ~6 m+ o7 t
$ U/ q  Z" z% m( o4 [
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
2 N0 u/ h; d( M& \' N//          AuthorisedUsers.java          Provided by: DRS
. z- y, m0 [& k0 f1 O3 G9 ^( `7 w, c9 z//               
! `$ p3 n) Q2 ^& ^6 H9 {//         Program shell for Assignment 20 h- }# i- E( P2 @8 L2 C8 @
//+ H0 D0 f8 B9 N& v7 B9 [
//         Represents facts about an AuthorisedUser
% J  B8 e) Q2 B9 \6 t//********************************************************************
& Y# V1 z4 _- o1 m1 z6 D0 H! J7 H* N- V0 P: w) T% e6 O. U& _
public class AuthorisedUsers
4 @1 s4 n* W% G9 T) Z    {
+ R( a1 [5 ]  }, W+ s* `. E5 E* Q" `8 Q( u' q/ ^- ~! w/ _( {
        //-----------------------------------------------------------------3 J5 L# n0 A' g7 }
        // Constructor+ {% e! d+ |% u; U# Z: l* k" K* d
        //-----------------------------------------------------------------
  ]& ?7 e" r( g; B3 J. J3 t1 r
; c7 w5 q2 C8 ]4 a2 D        public AuthorisedUsers()1 Q9 V' T9 w2 C5 C
                {
& z2 O6 [7 P6 S' p                }' r* E" S4 A/ J$ a6 _: J" R
) S. i  ~4 H2 R, Z1 m
        //-----------------------------------------------------------------
. k: F, V8 v3 ?4 k. D        // Method for testing that class has been reached
! t5 v$ t( I* d% G$ G        //-----------------------------------------------------------------       
: ]2 x- q" _* w. c2 o        public boolean AuthorisedUsersReached()
' v; X2 I+ X0 e0 a) ^$ X* [9 j                {: g4 N+ M6 k9 O
                        return true;                        " g/ c" y  ^1 j% U' [# ]/ @
                }# V) U  T- z3 {4 {+ I- n
               
& X; u5 V1 R2 ~/ ~5 m# B. {3 w7 F# e- @    } // end of class AuthorisedUsers4 q4 J0 o* k( ?" O" W! O
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming) F( ~: z# d& U) d) i, M4 ]
Shanghai - 2007
) D7 d- ^; {4 j1 P4 iAssignment 28 n1 k  S7 W3 ?) Y: ^3 F
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): Q% h4 c& |3 v/ E% f4 S: }8 R
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.5 [! h6 u8 D& V4 D8 j9 L% x
The staff must be able to:1 C8 t' `) ]. _
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
2 N" O8 `- \" S% C1 z1. 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.
% M$ n( J* O7 ~, v The interface should provide a menu so that the staff can:' x( I1 U. b: V$ {- {
a) Enter the names of the two Java program files to be compared, p' m3 N6 I( [! C) }, s$ s
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
+ o. G7 H; T: ]* U# j** 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).
- `% X! m. _; h7 D2 A1 HBSA104 Business Programming – 2007: Assignment 21 E+ W# u( ~' v' E$ ]& \* k
Page 2 of 5
- l5 l) M* A" R* r$ K+ @; Bb) Print out to the screen all the lines of code that are the same
" D' j) n& ~/ z6 W  | Include the name of the file and the line number of the code being printed for each of the two files( ^- l: Z6 x8 N9 F
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared( `, u! A2 q; w3 R
 the name, username and department of the user. ]+ f# ^' M8 ?% o
 the statistics of the comparison
* a4 J8 `$ B- ]# E$ g! v- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different& D, ~, H' j, o# X
 the recommendation for further checking
. o( S" C# D9 K: P* c6 S- 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
4 ?) \) f: o6 u4 `9 @6 ~ the names of the two files compared- x3 ~7 ^8 Y6 B; b. h) g2 w, f
d) Leave the program (exit)
2 P: _/ A+ X" v5 m& e0 u& lThe ProgramCompare class: (Total maximum 20 marks available)  g4 f( W5 t! S* k$ b/ e
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)
/ n/ Z0 l& R0 `3 Va) provide an error message if the files are not found or there is a problem opening them
$ _5 m4 b7 W! J3 P. Kb) compare each line of code
# a1 |3 a- y7 s2 ^c) print out the lines that are the same' Q3 O1 P; D, P5 d. y
d) count the number of lines compared / lines the same
; h. S1 s& z; l" x* \; r9 r% IThe AuthorisedUsers class: (Total maximum 20 marks available)
8 T. s9 f: q9 ]4 M3 {( z( G3. 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)
* z+ w1 k& |5 ~2 O) d4. Provide methods to:$ i9 I3 G( r# h% R) J: p
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' I" P  s6 ?- v: h; j( z" Z, [
b) return the name of the authorised user
8 U( t0 R! f; s8 ?c) return the name of the department of the authorised user- d. l# b) l3 }9 @/ @6 D
Individual Data (Maximum 20 marks available)/ \3 l) R/ H2 w  F, J7 M
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.
, T* M! P) O8 L1 R2 }) M; E& |Documentation (Maximum 10 marks available)0 J  S7 H: ~$ U* Q- @
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.
: m) t) l! J6 ~9 b9 G) G4 fBSA104 Business Programming – 2007: Assignment 20 H) A; z7 a* y' y: p1 y
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
3 M) W3 R0 S3 ~; W- `不过你要翻JAVA的类库说明。你有下载没有?
; ~* G, X2 }5 R1 a$ c$ H查询关于对比的函数。貌似关键字是contrast,还有compare
; A5 W* K5 Q  ]; U9 c9 C1 I/ L# ?( \* n- {
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -3 o6 `/ l- ^# A7 V/ e6 T$ U
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。6 K1 Z' P/ X4 j
可以下载到的 是 jdk-1_X_0-doc
5 L9 Z* y1 h2 |6 e) c0 r
* E- H+ V7 r6 P$ ][ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-18 16:20

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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