找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1315|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 2 L/ }1 k" d9 t, E& V1 l. P2 ?1 O1 X% P! z! D3 O
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
4 U. E* y" S3 `0 E$ z//  ProgramCompare.java         Provided by: DRS1 d5 f  s7 N# @3 e$ E
//
9 s) r( m$ _% H3 t' |/ Y//  Program shell for Assignment 2: g. Z  A+ L. U2 t
//
9 g. W# V; ^8 @- m, m9 M: z//  Compares two text files line by line
% l4 k: m  N# t, B$ ^6 d% |//*********************************************************************6 J! ~& C  g6 Y" w3 K

: R0 |0 e5 Y) w/ z4 Z& \import java.io.*;
3 b. @" E; t0 g$ }% H
5 ?# b, M8 O  m8 {9 e" Q3 _public class ProgramCompare
& Y8 ~  c, U; \  v: D' {: s{9 D8 R0 P4 A: S4 c" j/ Y
        //-----------------------------------------------------------------
; W! |0 Z6 n( j1 Z. \1 c4 m        // Constructor
) Q& h" Z. c$ G2 T        //-----------------------------------------------------------------
1 j2 @$ X  H: z: A0 [8 j        public ProgramCompare()
6 q. ?7 \9 E8 l0 f0 e7 R        {
/ t& V% }  G: D% z7 L# Z        }  Z3 E/ E) J/ N# }% B
9 M$ k5 V& [& H9 y( _) R/ @( ]. w
        //-----------------------------------------------------------------
+ T& I: N$ g& v. W( b/ W        // Method for testing that class has been reached) y! B+ r4 z3 \
        //-----------------------------------------------------------------        0 x5 }# y/ S2 X0 L* y8 z5 U0 {6 |* ^
$ L7 c( y; x8 m1 V
        public boolean ProgramCompareReached()         7 h. k3 `6 m  T. x: R
        {
9 ]( _/ A/ N6 c  H      try
% i- c  e* a0 t' }1 b# [   {         " V+ F# d* A3 e. q
                       
5 f- r/ U( q. y: [  h$ ~8 }                //********************************************************************( W' d* s3 T8 [3 D0 K
                // Try-Catch Statement is used to handle exceptions - such as file not found / J& O% a# D/ [& q/ W4 A
                // Reading the files will need to be placed inside a Try-Catch - just like this one!" x) C9 \$ @0 N. Z8 M; C% a! F5 g
                // For more information see page 534 of the textbook
2 D5 c* N/ y+ k                //********************************************************************
, S6 i; ]; r3 T8 N1 `! O                     6 l2 Q: o; _6 n. X% o
        }, e! f% Z. [5 @8 v3 r7 h
             catch (Exception ex) // Exception caught here and message displayed to the screen
& r- @1 m  @, V' p& |2 y          {, Q; f# p  T# y! I2 I% a8 U
                    ex.printStackTrace (System.err);' W, \. j* i6 j, D) G& Y
           System.out.println ("Error message goes here"); // Replace this error message with your own          : E- V' J  _' i9 T% j3 k$ \5 n
        }$ P& k6 V! W7 s
                return true;/ R1 j9 Q% N2 k$ r- ^
        }
8 t2 ]) D6 A+ h1 Q* V1 }+ K1 F" V4 R
} // end of class ProgramCompare& s5 Q0 D2 H& z3 ]8 a
2 A; \4 j" i# @- }+ B; ?7 q
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************. g1 l8 B) u" z' U" \3 d# ~
//  ProgramCompareMenu.java    Provided by: DRS/ c- G. f: X+ M( ~% p! i  A
//
4 |# \4 u6 s6 d5 J/ `2 d1 I0 Z//  Calls AuthorisedUsers.java and ProgramCompare.java
- d$ B( d) a4 [! l& d; N//
5 V" v; v  N" I- \0 p& {//  Driver shell for Assignment 2.3 S1 D, O; ]7 {2 E
//********************************************************************
/ c5 x$ ]( ~) {! y3 V  C4 p3 |7 @7 p. L
class ProgramCompareMenu
* W" [3 A9 M1 ]& R. ]- k! i% x{
# V6 ~- I+ P( l) ^' S+ A/ }' N    public static void main (String[] args)( O" o8 |2 X: J& j" j$ Z* q
            {3 E- p: Y# l; y
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
; L- [/ S1 d5 c                ProgramCompare reached1 = new ProgramCompare(); 7 `3 c8 z& w* e) l
                AuthorisedUsers reached2 = new AuthorisedUsers();       
& p" b* j# V! T# U' r, \9 c                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());3 F! s3 n; m" H1 ?
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ' u# S; {- o" p8 M
        }" O. k; k& ]  E0 N! R. n" J
}// end of class ProgramCompareMenu7 Z( b+ W! @5 Q/ w8 n

, Z' u' s- b$ ]//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
, q4 q6 u* d5 K& u//          AuthorisedUsers.java          Provided by: DRS( ]) y) L* m2 O* B& V5 ]
//               
- ^! o( f8 [, ~  }. i, G7 m; {//         Program shell for Assignment 2. R% s: j5 |6 b" H" T2 m2 `
//; z" H9 \& i7 u8 ~! B' ~0 m
//         Represents facts about an AuthorisedUser7 v1 T3 g' Q) L" k  E5 Q8 J3 z& w3 }
//********************************************************************
' u0 h' c' L  h. k5 z* u6 s  N* T( \  Z, K0 _5 U
public class AuthorisedUsers) r, k/ N+ B" i$ \  ~: ^9 s
    {
& @/ T" z9 \# F7 c; n
0 l6 X: H. z' k3 S# n/ n4 F        //-----------------------------------------------------------------
: b# g/ t; I) [        // Constructor8 [3 H+ X' z( R4 Y: M0 l! i2 m
        //-----------------------------------------------------------------
! w% ^8 l. j: \' b, q; s
' r1 {7 m) H, H+ l* Z2 ]0 _        public AuthorisedUsers(), t9 o+ ~$ d/ t. G& B2 b4 `
                {' }: {  ]  L, q$ d- q
                }
- c+ A( s$ O9 @" T0 D9 Y
# m* |3 x0 j- ]2 ^7 B; o        //-----------------------------------------------------------------
$ b4 @! G2 ?, M1 d8 [        // Method for testing that class has been reached
% j! n4 v" {9 k% U) z+ Q        //-----------------------------------------------------------------        8 M) v( Y0 b2 J
        public boolean AuthorisedUsersReached()0 p9 |! k( V$ d- {% V, [$ j, ]
                {9 i/ @7 [+ F& u5 r" f
                        return true;                       
5 Z5 a, }& j3 t$ Z% E/ B                }
/ j6 d0 M; D5 g) ?2 k/ N               
5 `) h! w! K8 l/ w$ U    } // end of class AuthorisedUsers( b7 }; c+ M  T" i2 G
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
8 l- H0 B# a1 uShanghai - 2007/ T9 }6 c3 }+ U2 Y0 j8 w
Assignment 2' e! G- s: o7 t, G) }. k
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)
& S- ~- H( P. ]  _2 }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.  ^' F" z, w& ]
The staff must be able to:5 {# B  m* L  T0 ?5 ^
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.  R: q* z8 T! [) t1 P5 l* @& E& 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.; w, n4 D0 M& \1 N! B
 The interface should provide a menu so that the staff can:
: p, N0 H  p! z3 D' K3 W; c2 Ha) Enter the names of the two Java program files to be compared
8 u+ J. U8 V# U* `: \4 i% [ For this assignment, it will be assumed that the two Java program files are in the same folder as your program.. r8 ]' ?5 R) |2 P0 d( ?
** 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)., ~  z, q4 r7 j3 ]
BSA104 Business Programming – 2007: Assignment 25 ]1 n4 S5 e7 }  y% s
Page 2 of 5% ~( |0 [1 j0 `5 i( t9 ~  m. x
b) Print out to the screen all the lines of code that are the same
3 ^: D8 [, d% U: L5 G Include the name of the file and the line number of the code being printed for each of the two files
' C9 ^- y9 U" Q; Rc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
! F& w+ S8 v4 ~; Z the name, username and department of the user4 J' l  w/ G% I3 x
 the statistics of the comparison. F( B: \6 h8 Q9 k) I
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different) W8 C: q3 E: H; r# s
 the recommendation for further checking+ J# a* B: L3 {7 U$ k1 v9 B$ 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 closely) g% [- B4 k; v" i  V; P! N* D% T
 the names of the two files compared0 l2 [( t& }' X6 n/ t
d) Leave the program (exit)8 ?; R" p8 V/ L& x$ s) ^
The ProgramCompare class: (Total maximum 20 marks available)
+ \- [* J2 M( \. S  ~. L) ~- ]( Y2. 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)
2 V* O- G. X# `, O8 C/ ia) provide an error message if the files are not found or there is a problem opening them
* M+ p! ?+ \- {/ nb) compare each line of code) U" I9 o9 j% C. z3 p2 q1 D! N7 }! t
c) print out the lines that are the same: c! y0 A% i$ k2 E" Y% F: w1 P
d) count the number of lines compared / lines the same
7 `- N0 K6 E+ r7 o  BThe AuthorisedUsers class: (Total maximum 20 marks available)
+ q" U* T: g4 j( Z2 M1 p6 ]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)& i0 r& J1 P& t) p* H0 s8 u
4. Provide methods to:6 A  f. U3 ?1 F0 h6 E
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 T) F4 q7 u! M( P
b) return the name of the authorised user
& I& ?* a0 I; wc) return the name of the department of the authorised user
9 Z) K2 I1 W4 E8 n! BIndividual Data (Maximum 20 marks available)
9 h5 F! t3 r* w0 F/ j4 D4 s+ ]2 [4 h5. 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.
! K$ f6 d: G6 e; ?5 p9 i- pDocumentation (Maximum 10 marks available)* O- n9 ]2 m- H; R7 B. Z1 b
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.
- R) h' a. }7 ?1 z! i9 TBSA104 Business Programming – 2007: Assignment 23 v8 K- n9 Q( L& g
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了5 U! G& `+ M3 n% [& T3 M. Z$ J
不过你要翻JAVA的类库说明。你有下载没有?
3 d; o0 g; h/ b' p1 I查询关于对比的函数。貌似关键字是contrast,还有compare
4 F3 j: b' J* L; i) B" [( t; X& U
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
6 ^; V& c3 u' M2 m( r& v$ ]痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
* M. q- B8 s) ^: f+ x% q可以下载到的 是 jdk-1_X_0-doc
' l# b2 B" S# L: {6 L( p% ?
- o7 |! s7 j, y$ v( D1 v0 S: R2 `[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-27 01:20

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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