找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1421|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ; w0 F$ N3 s9 h1 O1 R! b" ` 6 L' B9 l% o, g" T* C; s% ?
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
& `' g" W4 |+ _2 V, A+ N//  ProgramCompare.java         Provided by: DRS$ m2 V) g% G/ B$ F$ W* s
//
4 {6 Y9 C9 q9 V5 {0 Q& Q( ]//  Program shell for Assignment 26 b8 A9 v& \0 x; B
//
" U( X! b$ a& X+ l/ f- \//  Compares two text files line by line
) b: M: X3 F& S3 ]0 o  f: o, `& N//*********************************************************************( O: D: k- V5 Y: ^

  K) f+ b# V6 `. p7 \) T+ yimport java.io.*;- r: u$ R0 [9 T$ I' h+ }0 r$ F; v

$ |* G+ M2 K2 `2 ]4 _. y" Xpublic class ProgramCompare
( e' }5 ^+ d, c' b  c% o! W{
& L: ~2 ~" r- Y: T2 X+ L        //-----------------------------------------------------------------
0 x$ k. A; r  Y& M7 K# J$ e        // Constructor
* S; a: b- v$ J6 u+ V        //-----------------------------------------------------------------2 z% [2 i3 K  I  K& C4 k9 H; c2 t' ~
        public ProgramCompare()
4 t$ E! v9 S" S/ n2 v% v        {) B6 t. d$ Z' L* c. |
        }
! g2 x6 F% s- m+ S- n0 ~
5 h5 Z3 n9 p% s% W        //-----------------------------------------------------------------, Q0 u1 p) n, H
        // Method for testing that class has been reached
+ T8 ^0 |9 c( ^9 l5 C% ?. c        //-----------------------------------------------------------------       
" J2 l- e( {- Q4 [4 |
; \1 m* Z: A) y+ Z- a        public boolean ProgramCompareReached()        
0 g! a1 b) g# ?& o        {
; o; Q! P4 {; Q$ o' I      try
& `* V2 M) I+ F8 @& z8 w# e% {+ M6 V   {        
6 c' l9 V4 z5 f4 u0 o                       
8 c9 n5 U0 k  w' v; \+ |* u- V  n                //********************************************************************1 R! W( l# Y9 _* `
                // Try-Catch Statement is used to handle exceptions - such as file not found 8 I8 v1 m: d3 U9 s- e0 X8 L
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
) ?# f+ J: r# {                // For more information see page 534 of the textbook: a. h$ F( k2 Y2 w% z
                //********************************************************************
5 F# \) s9 }+ A1 o                    
4 C8 o6 k  A( L/ V7 L        }
' b  I2 b& P+ u7 f             catch (Exception ex) // Exception caught here and message displayed to the screen
) l4 [" ^. X- l% `& L9 R          {) W/ s* X. N7 \6 Y, U5 K2 y
                    ex.printStackTrace (System.err);1 J$ @* r! e+ z/ ~2 d0 v
           System.out.println ("Error message goes here"); // Replace this error message with your own          ) {) j  U9 L" C8 I, ?3 E
        }
1 L8 Z. ^! H$ `+ d3 _& h) N                return true;
+ y2 G. v' F/ H+ H3 H2 g        }
3 f6 Q/ N2 @  a' }9 E. o
5 j( S# N: x% z+ d, O} // end of class ProgramCompare
# X" l3 f& H# B9 m5 W4 \' k
2 Q0 Y  H9 U* p# _//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************" c6 P: Q; A; ~7 C5 {" z
//  ProgramCompareMenu.java    Provided by: DRS
$ h. i% [: C1 Q) ?- y& B; }, p1 G& C//
+ L* `. c% G# m4 \5 d//  Calls AuthorisedUsers.java and ProgramCompare.java0 a; k; f$ ^4 l9 Y8 z8 g
//6 ?# j& k0 B# V9 F
//  Driver shell for Assignment 2.
0 R) L6 d% A' ~5 I+ R//********************************************************************/ a' I2 |! i" A- v
% D/ ]) R2 u3 f' s
class ProgramCompareMenu
: c7 S; z- D& K; h$ m. J+ C. u3 x  F. `{
/ _0 @' }: |4 w* m! b+ h5 ]) V( s    public static void main (String[] args)" v9 }! C3 i% i- e
            {& e) [9 ?! x! v
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable  n' A; |8 Z6 o7 C) N5 j+ M
                ProgramCompare reached1 = new ProgramCompare();
; w- O/ I1 m' e- @* q+ o                AuthorisedUsers reached2 = new AuthorisedUsers();       
9 N! A: r  H/ `2 ~                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());( j+ d+ g% ?( {
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        * C) E% L3 b; y/ Z' S$ g8 K3 V
        }3 x$ A& k9 S) _3 c( n& {! s
}// end of class ProgramCompareMenu; r0 s! A( F3 L

9 k! C; X& @, V; }1 O+ ]//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
  C) R; l4 z# a: d; ]- X  X//          AuthorisedUsers.java          Provided by: DRS3 A( O# z, e$ R5 }8 B% v. X/ R
//               
9 p- K8 W7 K, E. c9 `//         Program shell for Assignment 2
; M% H. N' R1 Z) |9 G2 g/ f//
; z# Y4 U% {9 l& l2 H( @+ V//         Represents facts about an AuthorisedUser( o2 c; y1 c2 O- b. m
//********************************************************************; n3 n! Q' p* N7 f7 [, j- `
" m, P% p1 E4 D$ y0 ?" {
public class AuthorisedUsers
1 G; W0 m0 k: E. l    {4 O! o) c3 E7 ^: x  v9 q0 v+ c

" f: L# J$ X( ]' c% g9 N/ L        //-----------------------------------------------------------------6 H  Z- k5 c3 T8 b# p. |
        // Constructor
- o! D! Y7 B& z        //-----------------------------------------------------------------
9 Z8 a# Y$ S: `3 [" k$ b: b  O( @# O- `* O1 _
        public AuthorisedUsers()& T# n; V$ B/ u5 \; v
                {
9 F. K7 @0 }2 {                }
7 i/ X# _" H. A3 [: z8 \
5 y6 Q: q1 y& i- D        //-----------------------------------------------------------------1 U% q" o' V1 q: i
        // Method for testing that class has been reached
; Y/ e: l& u8 C; e        //-----------------------------------------------------------------       
0 ?  \: @! p# V+ ]  N" ]$ p        public boolean AuthorisedUsersReached()
1 u6 v' _. y7 O" `                {# h- @5 o% I5 H4 P8 O! ^( C
                        return true;                       
/ @2 O: _$ @, b$ P, x% R" b                }7 {0 W1 i" R7 k$ c. m
                . s6 U, Y) r# u! g
    } // end of class AuthorisedUsers8 N" F1 W1 u6 l8 H# q* i  X
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming, d' y" W2 s: S2 n( V7 c8 T
Shanghai - 2007) x/ f( O7 O2 }8 N6 w7 U
Assignment 2
" @4 j/ o( v3 L4 t& e0 C% D$ k8 gDeadline 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)+ c/ Q* s9 R) W0 L7 D: K  z
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., {# ]* {; U' F0 F& i/ l+ O+ ]3 `
The staff must be able to:$ `$ J9 U0 ]5 j! c& y1 v# b$ @5 Z
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
9 W' A8 B7 V8 ]. F1. 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.
, N. T& z" v7 K8 i# C* H The interface should provide a menu so that the staff can:
! _0 B2 d( s. u: D0 ca) Enter the names of the two Java program files to be compared
; R& |) l& D+ @3 o" l2 w  Z2 `( r- F For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
$ t3 b  u* _9 u$ |' Y. L** 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).
' {( g9 o/ i" @) T" QBSA104 Business Programming – 2007: Assignment 22 u! I, s9 q+ x6 V( h
Page 2 of 54 s+ s' b; O+ n/ A$ F  {
b) Print out to the screen all the lines of code that are the same0 k$ z  g4 j4 e4 \! T  ]
 Include the name of the file and the line number of the code being printed for each of the two files: P4 G7 k+ R6 Y4 {# q
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
- g8 w, r5 e. g1 d, c3 ` the name, username and department of the user2 P$ ?2 J: x( n% S2 t4 y% l$ B
 the statistics of the comparison
% R3 ?% u" a& M$ y- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
0 Y  i" U% h( \4 I# w the recommendation for further checking
. g2 V' H0 J4 y0 N- 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) o! _; z. Z3 v. [
 the names of the two files compared
( Y  c8 b, \/ U" `& m. {d) Leave the program (exit)4 v! \; |. n" z/ u! P7 k) ~; r
The ProgramCompare class: (Total maximum 20 marks available)# z3 v1 H( ]2 _( N) R5 p4 a
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)
  e5 }/ Q' D3 d! o" F- j! j0 ba) provide an error message if the files are not found or there is a problem opening them, B1 g( {8 L8 F/ R6 S
b) compare each line of code
, Y+ ^$ G3 N, C! S; S$ c3 F6 gc) print out the lines that are the same! V% e9 I& ^/ G/ \4 a
d) count the number of lines compared / lines the same/ P6 B3 `% W( h% |3 H
The AuthorisedUsers class: (Total maximum 20 marks available): V9 j' U3 i9 o7 U* Y
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)
# g0 |& N* p6 ?+ U: y* c; {1 n4. Provide methods to:6 t! J9 x- l. m- g
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 match4 F4 C: `' m# i+ `( z0 Z% e
b) return the name of the authorised user
/ M3 H7 C/ O9 b' t  U& R) u) Zc) return the name of the department of the authorised user, h+ x8 ]: [# W' Q
Individual Data (Maximum 20 marks available)
" r/ b% F1 D# F- ]' H# W0 B5. 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.' l' k- G: Q/ a, ?! Y5 b8 I
Documentation (Maximum 10 marks available)
: j0 E6 Y7 J! z& M$ v% _8 \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.& X9 ]4 S5 l2 }
BSA104 Business Programming – 2007: Assignment 26 j2 s0 o/ H) ?- a6 V. G
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
- A4 d* n/ m5 y$ O- Z% |% X: D, L; {不过你要翻JAVA的类库说明。你有下载没有?- K3 C; ^1 d! m+ a4 z
查询关于对比的函数。貌似关键字是contrast,还有compare
  P2 o) r2 v8 \! p* P- u
6 J7 r% H/ i( h4 }* I+ P6 _[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -! g" s. D% j1 {
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
% l' N5 K" Z  Q; L可以下载到的 是 jdk-1_X_0-doc2 t8 e6 d( D3 M
! j' U5 ~& U! k9 W; j  n' y$ M
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-28 16:26

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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