找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1549|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 + n6 t+ E- R5 _8 @9 | R% F ' ~0 P v! r- R9 N
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************$ ~6 C$ y) ~  o2 Y
//  ProgramCompare.java         Provided by: DRS8 h) W+ |7 i4 G
//
8 |; U4 b, n/ a//  Program shell for Assignment 24 Y0 h4 J$ O0 m- a6 E% d
//
6 N( x) t& X" ]7 i//  Compares two text files line by line0 h& i8 J( @5 \0 @4 f
//*********************************************************************
' G4 {( E. b' V+ h- j
& a: l) K  R* I0 L# o/ g- c( Wimport java.io.*;
( p5 e+ x9 ]9 O; G* f
9 n# a3 H3 T( s. {0 Qpublic class ProgramCompare
& u& w9 ^7 z  m4 e) J2 F( l* c{% m- [% u. N3 V7 I; b& u
        //-----------------------------------------------------------------7 ~" x5 J3 o3 C) H- u
        // Constructor
. \! L: o! N' T5 @8 C; |. s. V- v        //-----------------------------------------------------------------
5 ]  A& z: O3 @. W        public ProgramCompare()
% c: ~: T, V9 P1 E9 V        {  j2 c+ T" e. S( t( y
        }* L' a; F: ]; v) t" u- o/ w

7 H# s$ S3 u$ X+ q& E5 J# }$ B        //-----------------------------------------------------------------
$ J# h: C8 _, y7 x: _5 Q        // Method for testing that class has been reached) I3 D% g$ z9 i# O
        //-----------------------------------------------------------------        2 Z$ F6 l. Z; R3 V
2 x' g9 T( h7 X: D9 u: q4 P+ r2 i! N8 y
        public boolean ProgramCompareReached()        
7 v* @  S  J$ T1 J' v/ c! C4 |        {$ ?2 m' Q: |) n$ A
      try
' y7 ]: u6 F6 X  }3 _' w/ Q' Z   {        
5 x. I6 y) w. C- Z; _                        ; O, ]$ m  T5 u
                //********************************************************************
# y! r& S7 F1 O/ ^- o                // Try-Catch Statement is used to handle exceptions - such as file not found
% Y$ b$ I8 u+ F: p                // Reading the files will need to be placed inside a Try-Catch - just like this one!% t" s" ?) F* S
                // For more information see page 534 of the textbook/ P- ]0 R0 w7 F+ D1 F% X3 H
                //********************************************************************
2 Z8 Y0 p% K2 L" i! _0 J( y3 K                     ) S3 r# X( y( N% B, G, A' c  O6 D
        }
, i. J/ a0 N, |4 {$ n             catch (Exception ex) // Exception caught here and message displayed to the screen
8 x, w% @9 S' f2 O          {$ \1 f' }$ W' W. n
                    ex.printStackTrace (System.err);
9 @* `7 C) |4 ^/ A           System.out.println ("Error message goes here"); // Replace this error message with your own          6 N0 H$ B  X- d
        }) |2 N9 v' [; {+ g% X
                return true;
1 U* r3 m, @  B6 ~( E6 k' @        }
( k* }) g$ ]' H1 w3 E0 ?: Z2 r' O5 a& Q
} // end of class ProgramCompare
% e; \) Q  v- W: W0 o0 S  N
+ @* l8 @, Q/ S6 s& b//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
3 }5 d" b6 Z2 _+ [) x$ z$ G//  ProgramCompareMenu.java    Provided by: DRS5 E+ X5 I& r* B+ Q, {; p
//
- v% _2 ^' m" o- v. s, b//  Calls AuthorisedUsers.java and ProgramCompare.java
* |% t+ O* B8 h& g2 k5 `//6 P" S+ d1 g7 y. c. M0 B
//  Driver shell for Assignment 2.
7 M: j3 L) v0 N" S& R" w//********************************************************************
+ s  ~  _2 N2 t7 y, w
+ O% y, u3 @. E- e& [. sclass ProgramCompareMenu% F$ P/ C/ A' n
{
6 G# h6 b: f( \# V: D/ I+ L    public static void main (String[] args)
: e# a: ]* e2 n! s& _" b6 n            {
- C* J4 v* ]' B" l) I  u# k6 a                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
* B/ M4 @) D6 T/ k8 @& [" n                ProgramCompare reached1 = new ProgramCompare();   b! |& N+ W( s8 O& g2 F) @
                AuthorisedUsers reached2 = new AuthorisedUsers();       
7 `3 \9 n% W: s" H1 ^2 v1 r                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());3 u  B: Q/ H8 q) L6 t: z
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
4 M# l8 Z6 h, C. R' |        }  o+ f0 p- ~# U
}// end of class ProgramCompareMenu( {, }$ G" Y6 ]6 w) \% z& {
& w& B) S; m# j
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
6 P! C7 P" A9 [3 U3 _& E7 C+ K//          AuthorisedUsers.java          Provided by: DRS
6 Q- b6 p' D5 O/ v8 Q//               
# X( d0 z9 u- @4 B* d//         Program shell for Assignment 2
3 q5 K1 O/ V  O! c# s# i//1 M& b9 l5 B8 z
//         Represents facts about an AuthorisedUser
7 ]8 Y. P0 w7 d* [2 y# j' Z//********************************************************************
$ E, f# G5 W$ g. Y7 i9 l# F' l9 j9 e6 A( z
public class AuthorisedUsers& p: u& y$ H6 R" `5 R7 n
    {
0 }* o7 H4 F( R9 l7 B3 l3 x2 g
  r- t  ?) @0 k        //-----------------------------------------------------------------  \* P% {2 r* x% M" f
        // Constructor9 W0 ]8 U+ {- ?3 s+ q; z, T: s0 {
        //-----------------------------------------------------------------
) [9 L3 C  p9 f, C) F& P! }/ i
9 y' c9 j% r9 g  }2 U2 N        public AuthorisedUsers()
# o- N9 U* T  s' m" E                {- t5 M- _+ q$ e" E
                }
& J# H6 Y% y2 f+ L5 N; F
, y1 s( {! ~$ I& ~0 q        //-----------------------------------------------------------------
  W6 p7 u) E: M        // Method for testing that class has been reached# j5 o4 K! o. O) {
        //-----------------------------------------------------------------        , O, f* g3 Z$ b9 s: u& I( S+ u
        public boolean AuthorisedUsersReached()0 d8 E7 R" ?: ~' [+ _0 B, G
                {
- b: e; t' F2 C9 U                        return true;                       
& x) X! y, V& N7 A$ X( r7 P# M                }
9 c7 m' i8 D. N. _+ [  t                9 E# o" c3 \  L/ R
    } // end of class AuthorisedUsers
3 ~' F8 E+ a0 A0 v//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming1 X+ x4 i0 u: Y) Z7 I9 j
Shanghai - 2007
2 D8 B9 y7 p9 c, N9 oAssignment 25 X8 H( f- Z, p5 A' N
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)
3 D/ @# n5 f% g1. 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.6 Q& |) [1 e$ |$ G4 X
The staff must be able to:
1 O- F: {3 L6 J; D  T% z' q: T Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.! |5 T$ s/ {& d
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.7 e2 B& c' O$ R, c  w
 The interface should provide a menu so that the staff can:
- W* l: k" w8 j) Za) Enter the names of the two Java program files to be compared
& f7 a, ^9 e) y4 T* {( r For this assignment, it will be assumed that the two Java program files are in the same folder as your program.3 @( X5 K  S8 B  ]9 {. G$ B0 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).- @+ Y* d# u2 q6 f" a% Y2 S8 l
BSA104 Business Programming – 2007: Assignment 2
5 a. H* w) Q, [$ M& N* gPage 2 of 50 D! V# t$ ~# e
b) Print out to the screen all the lines of code that are the same  T' ?$ t+ ]1 M) j4 c1 G
 Include the name of the file and the line number of the code being printed for each of the two files
4 ^) t  E8 h, n& Ic) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared) C( ]  Y  B% X! H
 the name, username and department of the user4 i  |' X, W, a" o' w# u0 t
 the statistics of the comparison; W' D+ V; X: K5 l# f7 F, h6 K* F* I
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different8 y9 G( E, ?, L+ g4 l
 the recommendation for further checking
* p5 G3 k: z! N8 O- 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
; ?: b# N/ U3 v' r% s/ [ the names of the two files compared. b0 k  \( I' U7 w9 R- S
d) Leave the program (exit); Q! i: l* z! R7 I9 u* K9 @
The ProgramCompare class: (Total maximum 20 marks available)
0 k  K5 V2 x3 M' q! G5 Y2 \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)9 n2 k7 ^# |4 f# p7 B" S$ n
a) provide an error message if the files are not found or there is a problem opening them
# e: L7 ~* L1 n5 bb) compare each line of code+ l& w0 m6 W( n# y- k8 O% X8 J
c) print out the lines that are the same2 _$ e* }7 s' P
d) count the number of lines compared / lines the same
: E$ W2 v3 `9 D6 `# }The AuthorisedUsers class: (Total maximum 20 marks available)
. U  M- \. U9 e3. 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)) h" N7 T$ P! \9 R( i( J
4. Provide methods to:
6 ]+ V- R( H! _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 match0 y. q/ B4 ]* j9 v0 r9 k0 d
b) return the name of the authorised user0 t( ~6 c! a2 _$ w( c7 x
c) return the name of the department of the authorised user) {7 J3 T  y  M8 c9 K
Individual Data (Maximum 20 marks available)5 J6 T; r9 n& g/ a, }/ Z% y9 {8 C
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.. i% o, j: U- G
Documentation (Maximum 10 marks available)
' ?6 s5 j. D7 @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.8 x$ d( T# Y/ j
BSA104 Business Programming – 2007: Assignment 22 c' i( A. F+ v% a# {- e
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
0 d: I- |0 n  y9 X: W) x不过你要翻JAVA的类库说明。你有下载没有?
0 @: Z# `$ |9 w9 i7 O查询关于对比的函数。貌似关键字是contrast,还有compare, C" d2 s( Y! {
' V6 `2 T7 {* y
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -4 ^) }' ^2 C! ]+ C1 r. K2 E
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。' I2 q# {( |4 B2 n( F
可以下载到的 是 jdk-1_X_0-doc
) ?& j) J* y$ W/ P# t5 ^$ G2 e! [2 `, D2 J
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-18 17:56

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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