找回密码
 注册

QQ登录

只需一步,快速开始

查看: 995|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急: u# L& p8 t/ O! Q# K8 f" g, F - [5 `# v! b% e2 [- U
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************' R  Q& X' ]1 M: q8 W, n# h
//  ProgramCompare.java         Provided by: DRS
9 x2 M, m3 U! _( K//
* Y1 X4 o8 g7 u7 `/ J9 [% u- |# P//  Program shell for Assignment 2
5 g, @1 Y  P/ u6 `//& t( @2 f9 U8 A/ Q2 d( d
//  Compares two text files line by line+ m6 g7 i( s; V. ?& U
//*********************************************************************
$ B" m# F7 g. P! b4 @, L) h
8 K6 l8 u! A7 }3 ]" p2 T0 v5 D. b; Limport java.io.*;6 [5 g# d1 j. E3 P6 t( D- c( F$ R
: P6 R8 w) d- J) t
public class ProgramCompare
9 p( B- F$ {! n{
8 T0 C5 O. T2 l        //-----------------------------------------------------------------' u0 o% V# n+ ?2 F6 |$ D0 x
        // Constructor+ F- [$ h* |$ d4 @9 U: v0 A5 S
        //-----------------------------------------------------------------: R1 `9 t( V1 ]& p2 h
        public ProgramCompare()
4 |, x' i  {# n5 N- h9 x        {
# ^' T% H# g6 C; t: h3 `  C        }
6 Z) i9 m: m0 M7 Y: {0 ?- e
0 ^+ P' z, r- G) x8 q* u        //-----------------------------------------------------------------
8 e, [6 }1 h+ k( T5 \) p; t        // Method for testing that class has been reached
  f1 R+ O& X1 z6 S5 G$ q& T        //-----------------------------------------------------------------        & a- ~/ n  D; T( l5 ~# _& h

# D* L4 r" }; {  a0 n  D6 P        public boolean ProgramCompareReached()        
( n! I  A6 M& f% }3 D$ e4 A0 L        {
4 W4 A* g" [" f4 \' E6 h      try
0 c# N! _% J& `" L: g+ i+ X0 }   {        
: Q8 K  E$ I9 c1 O0 Q  S                        5 V4 U) z+ {# u6 D' [1 a& ~/ E
                //********************************************************************0 m0 l, U1 Y5 S3 X" n, T
                // Try-Catch Statement is used to handle exceptions - such as file not found ' ~' C/ g) k$ V, E/ X
                // Reading the files will need to be placed inside a Try-Catch - just like this one!4 n1 ^' y- ]; g
                // For more information see page 534 of the textbook
1 C2 n( Z3 k* W8 [                //********************************************************************
$ `- O; ?$ v" `6 ?5 T+ s! D                    
. G# m+ I0 w: C        }
7 T' H* {4 m) o6 d  S. Z$ ^8 ~             catch (Exception ex) // Exception caught here and message displayed to the screen ) v1 l+ h+ N$ V# m4 Z
          {
. |4 l; B" u+ F! |6 L                    ex.printStackTrace (System.err);0 t3 O& ^' e6 x, a) m7 q7 L
           System.out.println ("Error message goes here"); // Replace this error message with your own          ) d5 W! K( d9 @# a8 ]' i8 K
        }$ z8 G( w$ o) o$ ]5 Z, J
                return true;- G" O# L+ d" |) j
        }
, ~/ u1 q" ?6 ^: U' K1 O& b  M. B. y- Q( M& Q
} // end of class ProgramCompare5 a% K- g6 }/ E; G

5 Z4 o# b0 o/ i6 n//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
$ i3 S1 O3 m" H! s) q( R1 Z- B7 ?$ M//  ProgramCompareMenu.java    Provided by: DRS
* T2 Y1 A4 i7 b9 `//8 j& _  c% v% g) \! ~
//  Calls AuthorisedUsers.java and ProgramCompare.java7 T% m' ~- m' Z8 y: g* R
//; P4 n9 C9 j, S) n9 h! a. s
//  Driver shell for Assignment 2.9 }) q' i7 [6 W6 T2 b/ m% s/ |
//********************************************************************* m0 D2 X& s) }4 X

- j% U$ r$ R! I( k  Rclass ProgramCompareMenu
$ I; v% R' A! M; c% R{1 L$ C1 |% e7 i. S( c& G5 M
    public static void main (String[] args)1 ?: p6 ~$ f  K
            {
! R2 x  r  S1 V" b1 _& T1 Q/ P                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
2 ], Z- F: L0 H/ A/ v+ g                ProgramCompare reached1 = new ProgramCompare();
9 j; |# j! O9 e. z: L; w" `& s8 @                AuthorisedUsers reached2 = new AuthorisedUsers();        % F1 X5 I( V. q- u
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());' {* s4 g( Y0 I  O. d5 t
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        0 i8 D4 Z: r3 p  K1 O: K7 d6 H
        }
7 X9 e7 L; H$ F}// end of class ProgramCompareMenu
* Y0 R4 t9 e( r6 x6 F; J0 l, T" f: y1 Q8 o8 E2 T& u) v8 `
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************7 U; H$ m- m3 ]9 ~- e! Q
//          AuthorisedUsers.java          Provided by: DRS( ^3 q$ ~' D! z/ {& P' j
//               
  W/ |8 E8 D# B  N% _2 E# U//         Program shell for Assignment 2
& d; }3 X. T* h. h0 H//
" f% [) Z3 Y2 _6 \& F- R% p//         Represents facts about an AuthorisedUser3 e; U% r6 \! Y) V4 M
//********************************************************************
3 N- A9 H3 l/ e
! |6 D5 ^: o* x. upublic class AuthorisedUsers; z" D- U7 l8 I4 f$ d
    {0 m* c/ W" Y: o

- x8 u6 B2 L/ B' L: ~- _        //-----------------------------------------------------------------1 h5 B4 W7 E5 j- E( \
        // Constructor
* t. J' k% T" @& s& O% ?( d        //-----------------------------------------------------------------
# k# q3 c" F  p! ]
% b7 c$ ], b: Y+ z8 O        public AuthorisedUsers()
- j! b+ c: _  ]: @) n                {4 X8 [4 c" }* e/ k, W
                }
( R; A" j$ n0 _) `+ W+ Y; d! h) G) h9 _. ~$ [
        //-----------------------------------------------------------------7 E- f& L' \' p. g
        // Method for testing that class has been reached0 x9 x& X7 \# j9 U4 |5 g
        //-----------------------------------------------------------------       
$ H# j8 y. o& h/ T5 S+ l; g        public boolean AuthorisedUsersReached()% u& R& }7 ?4 Z" M
                {
) m% T0 b% T) c6 ?8 v" L  w                        return true;                        0 k' w+ ]( o1 O
                }( ~+ C4 q( p; g7 O" Q
                3 K: l1 t+ [, \" c5 t! ^
    } // end of class AuthorisedUsers1 h7 ^; t0 g) z
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
; U$ e, G4 ?% |2 ~; b; y3 F" |Shanghai - 2007
1 R) a" W3 [0 B5 F5 C: RAssignment 2
: A! D- i: p3 a$ PDeadline 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)% _1 o! ~& k4 W6 q) H  q9 \
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.1 \- j) e  ^; b: u4 w% d  v
The staff must be able to:
3 s" o+ O8 W7 U- S& _ Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
, {" r4 _' V" `' V  q8 u1. 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.3 G& J. n$ m7 }. q) N' k
 The interface should provide a menu so that the staff can:5 i( ]! K- ~- d8 p$ K
a) Enter the names of the two Java program files to be compared4 i2 F, P1 ^0 v  E( j3 N' T
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
: r# k/ D: a# |** 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* R9 T' U/ |3 L5 j& j' V7 VBSA104 Business Programming – 2007: Assignment 2
4 ^" J8 }$ u7 c; h+ H+ ^- qPage 2 of 5
7 A/ s" E' \+ ^8 w3 q+ Jb) Print out to the screen all the lines of code that are the same9 J6 K* b6 _8 u% S: j* }9 q+ F
 Include the name of the file and the line number of the code being printed for each of the two files' x% f* }# `3 F' W. G/ y+ p
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared9 H& I) y$ J# G& J( H' [
 the name, username and department of the user9 o6 O0 A9 @/ p" z( n
 the statistics of the comparison' |& Z) j/ R' b" R% S. b
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different: h: w6 a$ `% D; u5 d7 [
 the recommendation for further checking
6 i* Y3 Y  H% _( J  t- 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
: }) W0 @- w- r: S: U the names of the two files compared- E8 w$ p) p+ D, z  V5 @
d) Leave the program (exit)
) i( r1 \- l" ^  `- N  g* ?The ProgramCompare class: (Total maximum 20 marks available)
$ b- X3 n" t( T( x) ^+ O2. 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)8 U7 F" j4 O$ x- R( m* M) b4 Z
a) provide an error message if the files are not found or there is a problem opening them  e' T  w; c: l+ r
b) compare each line of code5 g- X, N! ]) n% l* X! I. K+ f
c) print out the lines that are the same$ x8 h) u6 p2 ?& F. R
d) count the number of lines compared / lines the same
) q3 M: C' U; [* e4 YThe AuthorisedUsers class: (Total maximum 20 marks available)' X, N+ ~& U# W& J8 h* j1 L2 X. k& {
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); t2 ?1 |# @3 a0 H8 B7 g! w* n
4. Provide methods to:+ f( q* |$ p* r+ U1 T- M
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
$ H7 G) W" W; R; T% I) Kb) return the name of the authorised user
! m3 x9 z' Z7 q! u+ Q# ic) return the name of the department of the authorised user
" r7 D! T, m$ M# t. [Individual Data (Maximum 20 marks available)
8 [* \6 I+ I. T/ C5. 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.* c  s2 z! Q4 [2 z7 |8 V
Documentation (Maximum 10 marks available)2 E- {6 y; @: |- N- z+ I
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 _. n3 K6 V" g" T/ I3 U2 J  x1 O
BSA104 Business Programming – 2007: Assignment 26 I$ n" z" _" K; |: w; Y$ b
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
. n# @1 w0 T4 Q( ~不过你要翻JAVA的类库说明。你有下载没有?
/ |3 s  Z2 j8 v% V+ w; l查询关于对比的函数。貌似关键字是contrast,还有compare; b( X9 w+ U7 o$ a, K: o0 ?

8 S# j' B  u% R. N0 u[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
4 S( r" c. G. W6 n" R痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
( }, t3 t+ s2 o5 W# d7 T" d1 \可以下载到的 是 jdk-1_X_0-doc
( P6 k/ H, I4 `3 P3 _' j7 K* [; v, w
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-5 17:48

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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