找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1731|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 : ?: b! x$ { t4 T : I+ G e6 q6 T4 e
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
. Y* j3 G  [! c/ `/ d//  ProgramCompare.java         Provided by: DRS: J( Q8 S6 a" C; _; e/ }5 f6 y
//
1 `4 E; D3 a( j4 r. M! k0 ^//  Program shell for Assignment 29 J4 R& x) {! ~4 s/ a/ u
//
- @. e9 F  C* U. u' H6 z//  Compares two text files line by line
0 N6 `' t0 P1 c& s% g0 [//*********************************************************************
( Y6 W* M! ?( {9 w' t: H" ?- D$ ?' @5 z8 P9 G- Q8 }
import java.io.*;7 K! T1 y5 x" L

) m( w, |& r& ]  r3 L, ]public class ProgramCompare
1 p8 u. @6 a% S3 t5 Q( F{
. s! ]: H; r, S( w        //-----------------------------------------------------------------
- [% e4 i0 K( s9 r& b# P0 h        // Constructor
3 V$ q1 `! y; s6 ?        //-----------------------------------------------------------------( }2 ]" [7 n( \6 C
        public ProgramCompare()
! f7 W4 ?; c0 j. E. ]( D6 u; Q6 O        {2 ?* a+ b. i3 m5 A9 B
        }$ f% B( O4 p( @+ V
0 X, E! H' ]$ K  E
        //-----------------------------------------------------------------2 G( {1 E0 B) c( O
        // Method for testing that class has been reached9 y' a9 u. [: M/ r  l; u! s0 ?
        //-----------------------------------------------------------------        3 q- J6 M2 l+ L# C- m& v

8 K% \0 C; B& ^& x% ]        public boolean ProgramCompareReached()         ( d8 `- L  z. B5 n
        {  X* n- Z2 {* _7 F& d9 w
      try
6 j9 k; N3 c, o' A" V# b8 S   {        
0 b, a0 t7 \7 }+ f3 \# b- }: ^' Q                       
8 w4 \0 ^- {1 {" {# V                //********************************************************************# l3 R2 A/ `8 \7 Q. K
                // Try-Catch Statement is used to handle exceptions - such as file not found ( |( G+ P. F5 ]; w! n7 `: a
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
4 t; _; ]3 E/ B# ]/ s3 ~" k                // For more information see page 534 of the textbook
0 }3 L* @  G/ q& [3 \                //********************************************************************
8 ~' `5 ?: j2 H* l                     ; B- A: f7 C" }0 N! Y
        }
/ v1 X/ F9 e* O) ^5 u% ?             catch (Exception ex) // Exception caught here and message displayed to the screen % x5 F& K3 o& f
          {! v1 A. u0 Q6 X5 Q
                    ex.printStackTrace (System.err);8 ?$ V7 [9 ]3 ~, ~  v
           System.out.println ("Error message goes here"); // Replace this error message with your own          2 ~: q% h7 h$ ]! v6 h% p
        }
4 H! v8 J5 r7 d( F: E9 g/ V                return true;8 ~& J+ e5 _3 ]4 W2 M7 Z5 R; @
        }. Y: H0 F0 O" e$ ~# ^# V/ p/ N$ V
0 q; y& g4 A3 V! R% k3 H
} // end of class ProgramCompare
" K/ u$ I4 _/ c: X
& f" i/ @* j( N% T//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************) s6 p* a5 f4 D! S9 D" o" s
//  ProgramCompareMenu.java    Provided by: DRS
$ T5 d( C3 x; \4 H: J//+ k* t3 F# f- m, e. {
//  Calls AuthorisedUsers.java and ProgramCompare.java1 n6 R8 W  S' M" Z, ~4 |) Q( N
//
% L8 `$ d- W3 g: f//  Driver shell for Assignment 2.
- D: v6 v" o5 m3 z6 G9 O4 Q//********************************************************************
6 l9 V, X& V" n. U$ B: l8 }# [! S' U
$ L; A* X% \  L( a/ k9 ?  Tclass ProgramCompareMenu
- O9 Z+ I4 P. R) w  o4 \4 t2 Y/ K7 R{8 e) A# C& S/ I) O6 T2 M
    public static void main (String[] args)( i  ~$ r) r' e* X+ {: _
            {& B& d; B5 h% K4 k( G+ q
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable, E- b& M3 r$ D% v
                ProgramCompare reached1 = new ProgramCompare();
, \1 j6 d6 J, a9 B, j8 Q                AuthorisedUsers reached2 = new AuthorisedUsers();        ) p9 U: u" U9 o; v2 k
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());% [) i0 }( t0 w" f2 e6 ~; I
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        0 U) g" S% X- p! [: T$ Z
        }9 Q) X: d3 ^! i  y
}// end of class ProgramCompareMenu% Z0 H" L5 z- U7 b1 c/ H% R2 E, V/ g+ k
  }9 ^4 E" ?- j5 \( G& D
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
5 Z/ S( K6 o5 q8 A  `: u5 f/ R8 h* \//          AuthorisedUsers.java          Provided by: DRS2 \2 j+ ^( W8 V- D
//                  }/ P$ U8 H0 @% q! C
//         Program shell for Assignment 2
/ D3 {# s: S- ]; S//" c2 [5 i8 g6 }0 [. u
//         Represents facts about an AuthorisedUser9 B  m0 F4 W& d8 I
//********************************************************************8 ?4 ?2 A- W2 [! T. V! Q) r
+ h+ K5 i' g8 S$ o- U! |
public class AuthorisedUsers
' ]) d" J$ ?# ^9 ]1 t5 d    {
! N; ~- a! R" J' h  B8 w) K+ `
6 Z; V4 D+ \! [; j( `" N        //-----------------------------------------------------------------
5 k0 x; s) ~' ~. h        // Constructor
; b' q) k7 d; N        //-----------------------------------------------------------------0 ^7 u" L4 p  `6 u
4 H' h! }+ l2 ~
        public AuthorisedUsers()
3 c+ ^2 B: h! u1 S                {
4 |/ O2 x, v2 C- l  l; H. X+ v                }9 b) W  E; J" `
% j; [* ^9 O0 p5 r  w
        //-----------------------------------------------------------------& S$ C4 l! ]( T0 b; F
        // Method for testing that class has been reached
, e6 x6 U/ Y! \3 k5 y6 W0 N        //-----------------------------------------------------------------        2 n' X- X. ?7 v; f- x8 W
        public boolean AuthorisedUsersReached()+ E, }" |2 Z3 u; A% ^. o
                {
/ y2 m, n) F3 m$ v" d! u4 f                        return true;                       
. z7 q8 s: b8 K0 H/ K: x8 Y                }
. X1 B8 z$ j% R+ k( U% f# T) l) t               
7 i$ ]5 Y8 X% {5 ]% o    } // end of class AuthorisedUsers
, s9 E9 n+ m# e0 x//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
4 R- j) [9 ?. ?# g6 N$ A& |Shanghai - 2007
! ]3 h) q9 C' E1 TAssignment 2$ t" U1 Y* I4 D5 \
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)
# M8 o: S$ m. m% u, H: L: l! P, A1. 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.
% t4 H8 _- g4 e9 G0 ^% YThe staff must be able to:* W( Q2 o8 {. V+ s! a1 R
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
3 B1 P7 Q- ~9 c$ ?% I) g, L# E! H1. 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.
, Y+ n0 l3 j( ~4 [2 @. n7 H The interface should provide a menu so that the staff can:6 s0 P7 B2 T0 T1 n1 z# M; o; B; W
a) Enter the names of the two Java program files to be compared8 O* |# P1 f, [+ J2 r2 e: o
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
; O* {6 }& _3 ~) ~** 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).$ I. i6 \1 W7 G9 n! b; F
BSA104 Business Programming – 2007: Assignment 21 G% l+ F, o' o3 Y
Page 2 of 5
) K7 F7 ]! x6 J3 V6 Lb) Print out to the screen all the lines of code that are the same
6 ~& R& Y2 d( J0 F5 u5 p3 u" k Include the name of the file and the line number of the code being printed for each of the two files
, N$ U- E7 D! e/ }! Y( Y, d3 ec) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
5 N! E4 K2 M2 y4 \( \0 c the name, username and department of the user
7 b" f! z# Z- t. [* L the statistics of the comparison
! S# l# B9 ^) n- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
' u0 T) J4 K7 F+ p$ n the recommendation for further checking& ]6 C' C" X) m3 @+ y4 E* P
- 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 closely7 H5 f4 N, S9 P! D7 W
 the names of the two files compared) V. T! A9 C) _2 `9 m5 B& L! {
d) Leave the program (exit)$ z, i* y( @9 d/ D4 q+ k3 }
The ProgramCompare class: (Total maximum 20 marks available)6 x! L7 y" e4 z; i
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)4 E% |& [) s$ O
a) provide an error message if the files are not found or there is a problem opening them2 R2 V6 e- U" X2 q
b) compare each line of code  G! Y3 @/ i2 E8 D* p. n, O
c) print out the lines that are the same( i* r% \$ t: \1 b) ]" s$ Z
d) count the number of lines compared / lines the same
4 W/ S& {: x$ U) B. oThe AuthorisedUsers class: (Total maximum 20 marks available)
7 w8 l$ X7 ~, x: n3. 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), ?( I7 X, z3 `$ F+ T8 `. l8 ?. {
4. Provide methods to:
) H/ h* v6 ~; F- B# E# la) 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
, z2 E8 [% i5 f# L$ r" gb) return the name of the authorised user
/ o* s& q: j. G( j! Lc) return the name of the department of the authorised user
% s2 f9 U& {. x* u& M" t0 cIndividual Data (Maximum 20 marks available)0 a" e5 s* c6 F! U2 B
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.
( d! u2 j2 j9 }  D; x, cDocumentation (Maximum 10 marks available)
/ m; q) X. X+ A9 x3 O6. 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.
- L5 q% b7 {" E  U6 |9 h7 eBSA104 Business Programming – 2007: Assignment 2
0 s' F7 ~& O8 U$ E0 jPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了/ H: S- E3 K$ t4 `
不过你要翻JAVA的类库说明。你有下载没有?! R$ z$ h( v3 O7 t+ p( t7 I
查询关于对比的函数。貌似关键字是contrast,还有compare
; ]7 }$ y0 d# g9 _+ P
* o& e; o8 x1 K5 _[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。6 p0 E5 A) `% J/ C( R
可以下载到的 是 jdk-1_X_0-doc, A( s7 m$ c/ ^. ]% \
8 s7 u7 @. J( l2 O
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-17 20:43

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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