找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1254|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急8 h' u& @+ h: \& A- d) x: E- Q 6 J+ w2 w' _& h/ J+ a! v- Y; [0 Q& ^! k
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************1 i8 o: x! d: z; H
//  ProgramCompare.java         Provided by: DRS  ~  G2 e9 U! z! f( n1 m" c
//
, o! G  d# _, s* L//  Program shell for Assignment 2: X6 l; B; ^, b; b- z$ w9 H
//
7 g) E! `" }  i/ y+ J( v//  Compares two text files line by line& D6 Y3 G/ |4 @* m2 P  Z- j8 ~1 X
//*********************************************************************0 q8 ~  h7 e: `3 H6 t: y

$ F( e& J$ w, |import java.io.*;' r* ]: o) t# k5 Z" f  f: }2 `

! K0 U/ R# W1 n# z0 N5 Jpublic class ProgramCompare1 e: \' \! y6 \: q3 n
{
! ^4 ^$ s5 v4 \3 E9 A, Y, b6 `        //-----------------------------------------------------------------
# e& ]+ Y" |+ t! n4 F% O7 i% E! v        // Constructor
# S1 R  k. [' P6 `4 E. W1 n        //-----------------------------------------------------------------
& [, r3 X' s; Z# }" y        public ProgramCompare()# ?2 a+ W( U% \) J  X/ q% j
        {
* [3 A0 N/ l$ m        }
7 \8 _: h, P( I4 S' c
9 L; s: c" j( E8 T2 m  u        //-----------------------------------------------------------------) _. W" {5 E6 X! X! {1 Q
        // Method for testing that class has been reached! v4 g- Q2 }) F" O/ n) }5 j0 p
        //-----------------------------------------------------------------       
1 }7 f8 {/ V' P8 I  P( o
; }2 K8 I" P5 n) ]/ @5 m        public boolean ProgramCompareReached()         $ p1 s  q0 p  x. Z" T  `
        {+ V) j9 |0 z1 b4 E
      try
; W- o1 c( @% P  F( I9 w   {        
1 c( r& u6 _+ \0 K, [$ N" W; N                       
2 y8 i& ^+ D2 S+ m. A% \; I                //********************************************************************
) t( g( R# i! ]4 p3 i, T* E                // Try-Catch Statement is used to handle exceptions - such as file not found ! O; x0 Q2 g; E
                // Reading the files will need to be placed inside a Try-Catch - just like this one!- u; Y& x! A! y0 |4 p
                // For more information see page 534 of the textbook
' K" J( |: w5 h0 W0 H; u                //********************************************************************
8 c; K' B' O# [( p" l                     5 u5 S! u+ Q* _+ z, u5 r5 G: z; H- Z5 n
        }  k0 L& C; B$ W8 Z6 _# a3 }. K
             catch (Exception ex) // Exception caught here and message displayed to the screen
! i  x4 M  q# V9 o! A# C# ]) M5 z4 H          {
! |8 J5 e: r6 y8 I                    ex.printStackTrace (System.err);! d3 y+ z1 C+ ]. Z% a* u5 U
           System.out.println ("Error message goes here"); // Replace this error message with your own          & S6 G# _9 P, c5 B
        }5 O. g; k2 @+ D9 G$ M1 B8 K
                return true;8 F, ~1 }* K" H6 d( c4 r* Y5 o
        }0 O  d5 \9 ]; {* t, ?0 d

7 A1 {- |! F- W} // end of class ProgramCompare
% ^) j; ^3 V' q  n8 i; L6 l& m, [, k3 I4 `3 w
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************3 f) o+ p6 a( N5 U! I
//  ProgramCompareMenu.java    Provided by: DRS
7 X# x6 ^8 u* w1 x# A; `) K//
+ @1 ^- l; r" B- r! K* j0 K# b//  Calls AuthorisedUsers.java and ProgramCompare.java
3 L' Z; {. T. S  m//
9 w% h8 g# i8 l" h1 b1 i4 L//  Driver shell for Assignment 2.- c/ A0 A; {2 [1 @$ H# d( r
//********************************************************************$ e7 p; \7 a0 `! j3 f
5 y7 ~& l& c, }9 u
class ProgramCompareMenu
* @; |' D% h5 \; M{
& H" y' u1 F: ~+ C7 C% K. z    public static void main (String[] args)5 d8 @  j# r9 T! H
            {2 z+ {) r" v1 T, M" r$ e+ A
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
; g5 k4 U; ]/ m                ProgramCompare reached1 = new ProgramCompare();
) j7 k, ], ]5 L( H3 h0 T5 i                AuthorisedUsers reached2 = new AuthorisedUsers();       
& D. a2 r# r; D% I+ {" o                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
  s7 m  r2 Z% W2 `* b6 w- t                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
7 o/ v; B% @' M+ a/ Q        }
/ Z' i, m" U& G' c}// end of class ProgramCompareMenu: g% [7 o/ Z9 O* V) S5 M3 w

" n) {8 T0 g: h2 o7 P, l//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************# C) ~! s% ~( S3 N3 m$ j8 Q' N" m
//          AuthorisedUsers.java          Provided by: DRS& j* O# l6 K9 U6 Z/ F) d7 G
//                / p) W: ]& h7 m  K* w
//         Program shell for Assignment 2
2 L& G/ T0 Z' r( V//
8 Q4 K/ m" r* R) L0 P//         Represents facts about an AuthorisedUser
8 N: l0 F0 o3 }4 _; y//********************************************************************
  U! l  m$ q; g( z
4 c# M1 E1 `4 e3 p2 [7 X6 I/ Kpublic class AuthorisedUsers0 B: }; m* n& l- |" [7 L
    {
1 h5 S8 E% Z) m$ h& ~
* R9 i. r" l$ b, ]" Z        //-----------------------------------------------------------------( x  P- `+ Y8 m0 k$ N9 J0 f0 w
        // Constructor# |1 }1 C6 F1 p. Y3 z" Z
        //-----------------------------------------------------------------4 Y2 c" C2 |4 Y0 l$ b

, T: L! f- A  U1 O! T: C8 K        public AuthorisedUsers()9 Z" P0 j2 Z" i7 X/ y
                {& C: L) K' v, Z) n8 {0 C, J" h
                }
' \" e3 k% P; X& Q7 i2 @! s! Y  U+ E
        //-----------------------------------------------------------------
7 l* F6 H: Z4 y; {7 B        // Method for testing that class has been reached
; B9 O  t* s0 X% e0 B        //-----------------------------------------------------------------        ( Z1 j1 _  k# `( N( V; N' ]3 U7 X/ y
        public boolean AuthorisedUsersReached()
0 \$ L  t# n  C% C                {
: e  I6 j6 S$ F; u2 ?1 x! v/ t                        return true;                       
: j; X/ K1 R+ D# c; u+ i4 U; D                }- V$ u' r% a4 b5 T8 q1 z
                6 C9 W! V! E& W$ X; g$ m1 S
    } // end of class AuthorisedUsers2 Z( q+ \% a, |  X0 D  E$ s# k; M
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming: p4 ?; s# r  b
Shanghai - 2007" n+ H) i% ]1 x  E2 R
Assignment 24 D5 C1 _8 J8 q; J! L8 [
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)
7 j8 s( y7 c, B0 w# j, a/ m# _8 T1. 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.
; X3 ^/ F+ J) ]- C: kThe staff must be able to:
( L3 t- @. W2 C; q# N. ?  I/ q Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **./ ^! |& s. h/ v" k9 {
1. 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.
4 N: f0 J, w  O0 J) b" }( g' W The interface should provide a menu so that the staff can:  a+ ?8 k  N+ \: I' h" K
a) Enter the names of the two Java program files to be compared. G4 E# ?" K1 f6 U  ^, g- `
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.) W. r' E& u5 `, j$ p1 }7 q6 X8 |* g
** 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).
$ r- Y' a( l+ k9 r; G! {1 y9 @: PBSA104 Business Programming – 2007: Assignment 2% }/ M/ p) B% [5 C. U+ r, n3 S
Page 2 of 54 Y/ I; z3 X0 \% Q3 A1 {
b) Print out to the screen all the lines of code that are the same4 h  M5 B* n5 v' K0 ]% V, E
 Include the name of the file and the line number of the code being printed for each of the two files+ v; E- J9 ]( V
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared3 @+ W8 y7 T6 c: C# R  r
 the name, username and department of the user$ O4 H) R% Y1 h4 U' t  X& I9 a
 the statistics of the comparison1 r- @, J6 @- K/ @: I
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
" Y2 K' A  c0 }  n  V! d the recommendation for further checking8 B, n2 G' U+ y) f  V. G* t/ i) @+ 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$ u+ A# b( }8 [; f: A( g
 the names of the two files compared
, G( |: f3 Q# Vd) Leave the program (exit)" t, H# ^2 M  [& C
The ProgramCompare class: (Total maximum 20 marks available)* Z  F  o  q: e! u
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)
( h% r- J1 {5 `- Z- w) q1 D# ja) provide an error message if the files are not found or there is a problem opening them. E2 d" G$ V* b/ H
b) compare each line of code
1 Z7 @2 q) M- \( @' ec) print out the lines that are the same" }  P7 X& _7 i/ D) f
d) count the number of lines compared / lines the same
) G2 Q7 t& D. k# n1 FThe AuthorisedUsers class: (Total maximum 20 marks available), y* j1 e& V# N  v$ K5 {6 {* D
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)' L! {' l0 v$ B, ^4 N
4. Provide methods to:; h) }3 {4 X, S( o" R- 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
& E9 Z8 f2 S$ U; \( G- g! [% Mb) return the name of the authorised user
( G6 W3 R' q5 U& q: h: t( Pc) return the name of the department of the authorised user
7 s& `2 N. x7 q* ?7 sIndividual Data (Maximum 20 marks available)* \, R; @. T6 `' V9 l* d
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.
$ P' ^: m1 G! l8 LDocumentation (Maximum 10 marks available)
3 I' Y/ ?- \* V- u; p! 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.
7 I% f2 {# S% g) ^9 b9 S2 l+ |BSA104 Business Programming – 2007: Assignment 2! d0 B8 p, l( U  ?, U" Z
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
6 Y$ j5 D. a  X. \  a- }不过你要翻JAVA的类库说明。你有下载没有?* k# S+ D, @9 o) z  J1 ?
查询关于对比的函数。貌似关键字是contrast,还有compare" y& N& Z( k2 e3 h0 ]
+ K0 ~" U0 J7 G8 E: I! C- t
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -: W) z' U% G. r& h% A
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
& n: e+ C% f( s$ p可以下载到的 是 jdk-1_X_0-doc' R  p3 H- B; l4 E" y6 Q6 t

) X& p0 a8 ?2 o  d& s% q6 t[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-8 15:19

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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