找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1225|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急9 U, [6 N+ U7 ]9 Y" w. V 1 G+ }, C0 U8 C& l! f! I; 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 | 显示全部楼层
//*********************************************************************; \& S! R/ z: E3 l
//  ProgramCompare.java         Provided by: DRS1 J* v+ e9 c% f; D0 \
//0 c0 B! I% Z8 L' _5 o7 F' G$ f, m  Q3 Y
//  Program shell for Assignment 2% [! f+ t" N7 N% W; d3 j  U+ P4 P
//8 \+ J) J- `6 x* w3 w$ O
//  Compares two text files line by line" v9 ^* `5 Z7 `# \7 U
//*********************************************************************
* h/ P$ ^* u8 |1 w+ p3 S, `
( A( V; U. `- w) dimport java.io.*;2 C2 E( F! I7 e: N8 s4 X
  c0 }: T: P- x* z
public class ProgramCompare
/ _6 Q8 `, L0 J+ }1 s0 Y{( e& V* o5 f2 k4 _& u
        //-----------------------------------------------------------------: A- P5 ^. ]/ E7 G* Q1 j
        // Constructor6 N: O# J4 A- W( _  t9 p& R
        //-----------------------------------------------------------------+ Q0 n. m% }& K7 R2 ]3 S/ a
        public ProgramCompare()% z8 l0 `# I- _+ E
        {1 N$ t; x3 k  E: Z4 D' x2 v: S$ {
        }. W) q/ l6 G4 P6 K) d+ a

6 y5 ?, G' y! k8 K! l9 j; N        //-----------------------------------------------------------------
9 f; `5 n0 Z- X5 B$ q/ T        // Method for testing that class has been reached
: Z' G2 q* [; D% Y8 c$ ?( u        //-----------------------------------------------------------------        ! U% A; l% Z2 y+ c1 C+ [+ }
6 A* [4 L# t( w- T" ^+ Y7 K
        public boolean ProgramCompareReached()        
& L- W' I& |+ g8 J0 Q        {
* ]2 `0 x' S* x/ I5 w      try ) X# K' r& [: C* b/ A
   {        
7 ^( v9 J, u& O7 S! o- r$ }7 ~- z                        4 b/ H( A1 R% C
                //********************************************************************
2 \. Y  O, S$ ?% O, f                // Try-Catch Statement is used to handle exceptions - such as file not found
& I" J! n- q% t                // Reading the files will need to be placed inside a Try-Catch - just like this one!& ^. x2 h( D) H; x
                // For more information see page 534 of the textbook/ L: L$ @% f9 Y
                //********************************************************************- I2 v  X2 r0 H' y& m% V/ K, q
                     7 J" D, r! H0 h! z6 n3 m6 o
        }
$ [- _' o2 R, W" t  T  U             catch (Exception ex) // Exception caught here and message displayed to the screen ; \+ Q, {1 w% l. U0 y$ X
          {* a0 c) t4 M- q, D
                    ex.printStackTrace (System.err);
9 b6 ^- ~3 W  Z; y4 |           System.out.println ("Error message goes here"); // Replace this error message with your own          & }1 Q( y3 B- ?2 W
        }
' J( p& T8 f/ B' s0 F. _! c5 ~! }                return true;8 l- T4 |5 K% c
        }' F6 l& f: @5 m2 c

- k% c$ l, u6 G3 F7 ~$ {} // end of class ProgramCompare) Z* l: Z: u* V3 U% x! g5 Y

  O& G. _* w2 ~# Z2 ?- R+ Q//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************  E' u7 y! z9 n( a# _- @
//  ProgramCompareMenu.java    Provided by: DRS
' b* m& _8 E. r" B//
) b" L' Z) K+ A4 X2 t: ]//  Calls AuthorisedUsers.java and ProgramCompare.java8 n+ E1 L& N+ a# s3 j1 G6 N
//5 h$ D+ p. ]; Q# Z% ~
//  Driver shell for Assignment 2.
+ e# F% U$ F3 O' U# O//********************************************************************
+ S' g' \# c+ y) n0 W
' D, O8 ~: d6 Z% [  C% O+ Qclass ProgramCompareMenu5 X- z8 W* U- q  P1 g6 @; o
{
3 V' F. B& y- m    public static void main (String[] args)0 h5 N1 T" c" ~7 c; g2 i* n: y
            {
# R4 N9 r+ ^$ L5 C, Z; d  F5 y; |                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
: Z. W' z5 O% b                ProgramCompare reached1 = new ProgramCompare(); 1 l5 [( p( S* J$ j: u  b: R
                AuthorisedUsers reached2 = new AuthorisedUsers();        5 ~/ y  u+ q: `" u
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
7 \& q& N- S, a0 l. W9 w- |                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        9 G6 p; ~/ c$ t0 S; T+ F( i) y# t% Q6 x
        }
& J  r. X* [9 y% @' I}// end of class ProgramCompareMenu+ d2 k$ i& u7 `7 I; @

9 B8 ]" A; y3 h//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************- m" Z1 [6 |' |/ b& D/ a  z) D
//          AuthorisedUsers.java          Provided by: DRS
& z0 V& c! M# \2 q* }( r! z" V3 {//                * m' k6 Q' z' r
//         Program shell for Assignment 2
3 n1 f1 T- y3 P( n" \9 P//. q7 M, Y% r; |8 k$ r: W
//         Represents facts about an AuthorisedUser3 G% _$ b- Q7 |
//********************************************************************9 z! {$ \1 c# X2 |: m( ~* u

+ T) [5 e8 H: n* r# k2 j7 b  k* qpublic class AuthorisedUsers! b$ h# g! W" h, Q+ b/ L
    {
  d, p* I3 C. S# }1 J/ x' {' O# A6 f( G- t& U" q3 M+ \
        //-----------------------------------------------------------------6 o1 }  O5 M7 ]' V
        // Constructor
, ~  a2 Y7 S7 _  n9 W        //-----------------------------------------------------------------* X5 O. A, G: D# Q
7 G% |9 ^) _2 X4 @, X& W8 k
        public AuthorisedUsers()% d; ?# `4 ]9 o& o4 E5 H, N( F" n# ]
                {; v0 x$ Q0 c" M1 M* N' i
                }8 B0 @5 F9 e0 _% }2 i7 \( j

' x3 D7 \$ m7 K  b( i        //-----------------------------------------------------------------
- p% P" v7 D  s        // Method for testing that class has been reached9 s! O4 e% e& g) s" v
        //-----------------------------------------------------------------        ; F  `. h6 z* ~8 L9 y( v! d' l# \' `7 F
        public boolean AuthorisedUsersReached()
( z2 s2 {0 l# s6 H# c                {
' a. I3 _( g0 ~- X                        return true;                       
: _) R( S9 ~" u, I- B                }
/ [* I. O- f: ~                : W, _$ i' ~6 N! R2 H" J
    } // end of class AuthorisedUsers
% M! [; K2 k8 s, E! D' z//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming8 s7 t6 e. r6 X, T
Shanghai - 2007! U/ u: [* d3 z2 q- k
Assignment 2% g( F* P; i; G
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)4 g5 x; B6 R/ Z% a
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.
8 n( j: n6 i' h: `+ mThe staff must be able to:
( i! Y; ~  M0 o  w" h# V+ p Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.+ F) z- R, M  V6 L
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.; z# ]* m( T) r: V+ ^
 The interface should provide a menu so that the staff can:6 E, \, M9 W* ^- m6 N. f
a) Enter the names of the two Java program files to be compared+ d& t5 V8 w5 I- o6 X
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.; a* u2 h* p  C1 E
** 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).
1 J0 X6 O4 ~$ U3 a' SBSA104 Business Programming – 2007: Assignment 2) y) T; A1 q# F9 n: h
Page 2 of 5- d+ B+ P6 |0 Z
b) Print out to the screen all the lines of code that are the same' S) m7 K- Q6 q
 Include the name of the file and the line number of the code being printed for each of the two files8 T) r( L6 U& C. _: W8 `$ y
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
% Q& a' ^1 _, [; K the name, username and department of the user9 s7 g9 Q' _9 G6 q9 v& U. C: y
 the statistics of the comparison5 _' o3 g+ p( U4 y9 x3 r& K
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
6 v% p7 Q$ |5 E' w9 I( w: G the recommendation for further checking
6 G% \/ g5 i, a; ^+ _6 V- 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
" _; {7 L8 B" q: u# S) N4 _6 v the names of the two files compared+ Q0 p/ b- T5 {4 N
d) Leave the program (exit)4 v7 I" j1 x; m/ ?
The ProgramCompare class: (Total maximum 20 marks available)
: t5 T! r, r% \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), p, _" m0 T- d  H6 }8 Q
a) provide an error message if the files are not found or there is a problem opening them+ Z4 Z. ^/ t5 f
b) compare each line of code
$ d5 h+ ?$ w0 a% C! P( zc) print out the lines that are the same( P" w8 D% @) }: e! Z4 \5 ~/ v3 o
d) count the number of lines compared / lines the same  d7 k* q: X- p1 v+ D
The AuthorisedUsers class: (Total maximum 20 marks available)
  s, A' z( v8 B3 @1 f. j4 }3 j3. 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)
4 Y; {! Q% l5 C* ?& o4. Provide methods to:3 C; Q+ G0 b4 _& l0 a5 g5 |! R. K3 \6 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 match( A# T( D( W+ x$ |2 l
b) return the name of the authorised user
& X. l4 k3 E+ Q% n* I5 }! ?c) return the name of the department of the authorised user; E8 q2 _( t" W% t5 e% g. {
Individual Data (Maximum 20 marks available)
! c6 v! D  s4 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.$ a/ s# _& `3 B# i
Documentation (Maximum 10 marks available)
- _2 e, b$ t) z6. 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.5 S5 `( U% I# O
BSA104 Business Programming – 2007: Assignment 2& x( c& D. y7 `2 ~
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了" G9 [+ p" F# [3 T3 `
不过你要翻JAVA的类库说明。你有下载没有?
7 Y9 }. b: H9 `/ {/ C查询关于对比的函数。貌似关键字是contrast,还有compare: l% O. }9 L& b, f6 A( }/ q6 r

6 o1 v  Y) z; A- h[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
* J& Y* ^6 L8 a* e* M* e痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。. s% b2 @" D; @5 N9 O* e
可以下载到的 是 jdk-1_X_0-doc- h. M3 R0 c6 c' K

8 K& p& V4 c3 m1 w[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-21 23:17

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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