找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1474|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ) C/ C9 D. ~/ [' U/ Z( v* h R) X# y `
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************; f0 d& |5 A* S  ?) M
//  ProgramCompare.java         Provided by: DRS
4 j% L  n6 T- x% l  |//# y) V) X) s. K9 y$ L; u' D
//  Program shell for Assignment 23 Y- m) S  G8 F9 o  j4 T8 s
//
2 r- k6 B1 {1 O//  Compares two text files line by line
3 R, R4 E: A! u0 O3 X$ g//*********************************************************************
6 S( h" M/ b2 n/ @0 {8 A5 k7 M
, _) T0 _. h  {5 C8 ]7 z- |import java.io.*;4 H( H: Y8 p! y1 _( ?+ G' _

2 w; V8 m( y* n2 Npublic class ProgramCompare
" C' f) e! r9 d, W0 g{
, e5 g' ]: X- \) r  m+ [        //-----------------------------------------------------------------
6 U. g/ J, H6 |1 Z! ~1 [/ o        // Constructor
/ S: Q2 Q; w* s3 E7 [        //-----------------------------------------------------------------
. p1 j3 H- Y5 Y& F; _: g; B        public ProgramCompare()4 n, {+ `/ B5 W( s; B3 q& u
        {! p$ N: @) V  Y  [) s& C7 z3 g
        }+ D/ P5 f) K+ T% s
0 T4 x+ ~* H% t( l( D( ~8 K
        //-----------------------------------------------------------------1 I$ w5 T+ j# F$ y
        // Method for testing that class has been reached' N8 a! H6 B& D: a
        //-----------------------------------------------------------------       
. G3 O4 {& d" f
; W& t2 ^% P( M, D        public boolean ProgramCompareReached()        
. e% }- v, @* Q& b( n- [        {
: g5 F, T$ _, }9 V/ q" I) a      try
( }. |( ^2 p9 l5 T9 A- P   {        
! p; g4 y* J' i3 }                       
4 v8 f0 ^5 a" X/ y+ Q( V                //********************************************************************+ s  D) s" [8 `$ d) F4 m1 E
                // Try-Catch Statement is used to handle exceptions - such as file not found
6 m! f5 z: J' \! ~: W( Y. c                // Reading the files will need to be placed inside a Try-Catch - just like this one!
5 w5 b8 {: l; B                // For more information see page 534 of the textbook
! _. M5 j, O! P; {* B                //********************************************************************8 x7 f* r" ?/ n6 W
                    
/ i% c& N0 A$ {# e4 y        }
9 E' H) V( t- R7 h             catch (Exception ex) // Exception caught here and message displayed to the screen
0 _2 ]( j0 N- o5 W" a* O          {
, i' b0 S: b8 A% i3 M+ j* Z0 C7 `                    ex.printStackTrace (System.err);4 \4 R" X- Q9 c6 N- `/ F& p
           System.out.println ("Error message goes here"); // Replace this error message with your own         
: T/ F! d  k/ i! W        }
, x$ d" I  t) m6 n  ?                return true;5 V" S+ Y! e( T
        }
; v+ k, M- [  x) y
: ~/ N& ?& O4 N. C3 |: r8 \} // end of class ProgramCompare
1 `# u8 u; e7 C
. R" j- f* E' L2 ^: d+ U3 @/ i//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
- [* D4 f* y3 j5 I7 V//  ProgramCompareMenu.java    Provided by: DRS
% R5 D5 I- v- Y9 k& |//
  w5 [! }; m- F  L0 U/ `//  Calls AuthorisedUsers.java and ProgramCompare.java
5 O0 P0 K' i/ Q//, `. Z7 q) i, x! `
//  Driver shell for Assignment 2.
( N! c& l8 K4 T  K/ A* T//********************************************************************
7 ]' Z; U# R' [" a% O# M
! K) \; Z2 w5 t: U( m. r; p! ^class ProgramCompareMenu  \' f  |" Y. f* j
{
8 T1 T* c) ?) Q! `- C5 P, j    public static void main (String[] args): r4 i) Z8 ~- R7 i/ s& [- g% `
            {2 N: ~6 ~6 L1 j+ x  W
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable3 R: V6 w% j; _, J7 c1 J, a
                ProgramCompare reached1 = new ProgramCompare(); - p# S, x' U% |
                AuthorisedUsers reached2 = new AuthorisedUsers();       
# B" b. m9 {! l/ c( H5 i* l                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
+ t6 i) |5 [  h: l. f1 p                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
) K) r3 V* N5 s# G; ]" u        }% \' w( g& V1 v) |* g
}// end of class ProgramCompareMenu3 ~  h+ i/ \. f- H2 A& w

9 T" _% ]$ l& i! g9 z3 {9 P//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
- Q+ a6 C& f: S) J//          AuthorisedUsers.java          Provided by: DRS
  ?3 X, Z" u# C, u//               
( F; B7 K" b7 K; X//         Program shell for Assignment 2
0 H# [8 v7 h5 j/ m0 ?8 t* J+ P//! \$ w' H  v/ h& r3 x- f; k
//         Represents facts about an AuthorisedUser
+ B! e- n% q: P$ ^5 x# i//********************************************************************0 O2 V8 Y' Y5 x) a; r3 D( ?4 x
' U- B! k+ M$ P# |0 r+ Y! ^* `
public class AuthorisedUsers" c0 M$ ~0 d# |& B( G+ O
    {
% M3 S- Z) F& l$ K( e
* n8 O5 X7 ^( E4 H, f! G! T5 |        //-----------------------------------------------------------------
5 x: P1 |3 F1 f5 R: c        // Constructor
8 v' c5 d7 b) G0 ^        //-----------------------------------------------------------------
. R2 |+ E8 u, w$ W; h- K( ?4 }, d% R- R3 H: M- D' f
        public AuthorisedUsers()4 s! ?, `4 i/ W9 ?% l9 N0 F
                {+ ]& @& T" o4 c" f" N0 i% O
                }
9 s" x! @. X# x0 X( z$ B4 X' V! }/ ?- P
        //-----------------------------------------------------------------9 R4 N/ B4 S$ w  e# j3 W" I7 M
        // Method for testing that class has been reached+ {* m6 i/ K" x5 f, t2 _
        //-----------------------------------------------------------------        : J/ P: `5 h0 _1 c0 J& w' O
        public boolean AuthorisedUsersReached()  c! T3 O8 J* Q) z9 V8 L- x+ V
                {* X: t! J  n0 ~
                        return true;                       
( }* M8 A8 H* [2 |- g                }9 c( B# M+ f! Z% d' J1 r2 {
               
2 }+ E0 y; A% `    } // end of class AuthorisedUsers
: }+ B0 O, z$ o# m4 R1 o//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming' }7 m3 d) A3 a
Shanghai - 2007: u+ S& s9 c% {/ r
Assignment 2/ O: u3 M  u0 }7 T3 L
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)2 U% G/ M% D2 M5 g# S( w: L
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.& C" b( B  w" s3 u0 [
The staff must be able to:
4 O6 {& b- Q% N Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
; M. |9 b% K5 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.
8 J1 H! I# b7 ?3 H% }+ A) d7 \ The interface should provide a menu so that the staff can:1 |- M" v$ E7 K+ w& u+ s2 H, ?
a) Enter the names of the two Java program files to be compared
2 T9 m4 o4 J" t For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
* q4 g2 S+ C- C- h7 w4 d6 \8 t** 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).0 |' B/ @! b0 P$ ?4 N4 A5 B5 \+ ~) t
BSA104 Business Programming – 2007: Assignment 2  X0 P; G2 n1 I9 i% ]7 s: K1 W, t
Page 2 of 5
( {& G. v; |; i0 R( Wb) Print out to the screen all the lines of code that are the same- O+ v- K  z* e/ J  ]  W
 Include the name of the file and the line number of the code being printed for each of the two files
! N+ F' @5 G' M) o* D7 Yc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
/ Q( t$ H* W: J6 b) [2 [ the name, username and department of the user
$ w! [( i6 {! g& y) o5 Q the statistics of the comparison6 k0 q- T) `- @
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different( H0 F/ l' `- s
 the recommendation for further checking$ @7 `) l/ x) o7 j  i
- 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
2 ]1 L& S$ \! f; C the names of the two files compared
5 P; H" ~) g$ V1 E$ N& n, j5 ud) Leave the program (exit)
1 }3 }  y$ @$ D( O" HThe ProgramCompare class: (Total maximum 20 marks available)
; O- M6 B+ Z. U9 d. h( Z: }, ~3 F8 |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)
" a2 W* w( {9 j0 m- O4 E4 va) provide an error message if the files are not found or there is a problem opening them
9 @+ V0 G3 U0 i, L9 |/ m6 k& ub) compare each line of code
6 P! V) i: g+ r: J7 Zc) print out the lines that are the same
7 z. ]3 o' `/ p8 f8 s: K' wd) count the number of lines compared / lines the same
0 \  A. y. s7 y+ i5 _" l+ JThe AuthorisedUsers class: (Total maximum 20 marks available)$ x6 Y/ G: _4 I; h, L: g  R1 d& b) S
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)
- X* }5 p& q. o, P1 I' F4. Provide methods to:
, e8 l) Y2 L! `3 C" o9 [" ^) ka) 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- x# X' e( `) v- ~
b) return the name of the authorised user( I0 W; R- D  m% R6 O  O/ ^
c) return the name of the department of the authorised user
) L# u: Z* Z, b1 UIndividual Data (Maximum 20 marks available)
9 V. ]. U, |4 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.; W# m4 Q+ ]2 ]& ]& Z0 T
Documentation (Maximum 10 marks available)
7 O( v3 S4 o- r/ 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.4 n- j4 ^9 s6 e# i* c; K& m
BSA104 Business Programming – 2007: Assignment 2( N% D. i9 s- b  x& K8 {3 Y- ^1 b+ x' V
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
% t( F& l1 c& y  G3 S不过你要翻JAVA的类库说明。你有下载没有?
6 n, A1 U- E- ~  g查询关于对比的函数。貌似关键字是contrast,还有compare
  x& H4 D! L  @
( z6 X+ K6 P9 @  r, F" ~[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
+ |1 {& ~2 u6 f" b: u0 T可以下载到的 是 jdk-1_X_0-doc
4 s) Z5 e$ i0 X& c9 D0 B4 Z
# K. U# v/ E7 X  z[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-22 12:16

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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