找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1040|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急7 D: l% V5 X; R- t ~0 ~. L2 f& ?+ j- ]% l! ^8 s
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//********************************************************************** p$ N# A5 ]$ W3 b: `
//  ProgramCompare.java         Provided by: DRS0 p- f- S$ X; B* @5 E' ~9 e' F3 o+ s
//0 g$ z! L7 I0 G) I1 W7 s5 ?
//  Program shell for Assignment 20 y% s( Y" S5 E, \% U& {
//
, N! J! {5 g. I4 j//  Compares two text files line by line- L6 ^0 `5 B' L5 C8 o: M  ~  R
//*********************************************************************
* C/ Y: c8 e  t- ]% U! l+ b& n) d0 u
, U# S$ p: c) ^" g7 Fimport java.io.*;
% S) M; h5 x2 K
4 f% n7 k4 H% y! i! `' fpublic class ProgramCompare+ s0 @7 V) [- ]$ X/ x2 g" S
{  T, Y! P2 p- A$ o. t" e  i9 M# w
        //-----------------------------------------------------------------0 h7 z/ m5 G) t7 R; g: y7 x9 k$ O
        // Constructor& e5 i" b* R9 q; ?0 }, }+ p
        //-----------------------------------------------------------------6 A7 L% ~' g- N( c8 S5 F" q) W6 ^; N& U- M
        public ProgramCompare()! ]( `' x9 N; A8 k
        {6 k( w: f9 c  T: X" R" F
        }
4 ?$ M" T8 M  }" g( {- ?: m) u
. b/ M5 E) ~, K8 [" Y- J+ D, [        //-----------------------------------------------------------------9 V4 h1 U8 Y4 h. p7 o
        // Method for testing that class has been reached
! D% P& ?' b, U# `, J3 O7 g" p        //-----------------------------------------------------------------        : t5 w% r( L5 r' b7 X8 V$ u

+ x0 G$ S3 A+ @" ~8 q+ I        public boolean ProgramCompareReached()        
/ e3 x4 W- p. R7 n        {. h3 h% t/ y* w  E' F
      try ) e" i$ B& `( C! W! F
   {        
7 O, G9 a# ?/ ^4 o3 e* o: P                        . P0 D+ {  ]8 r% i* a% ~! l
                //********************************************************************5 p; I. V- a- D# Q3 S% c
                // Try-Catch Statement is used to handle exceptions - such as file not found + n9 x; j3 m( f. p2 u( A- N4 h9 V
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
6 {1 G9 x5 T7 q: P                // For more information see page 534 of the textbook/ E/ j  N- E+ y" c1 D
                //********************************************************************+ V5 P' i/ u" x5 x9 ]+ w% q6 c- u
                    
+ A" P! {9 k5 D" n0 C# a        }
" ^& N& [1 ]& F0 s$ d             catch (Exception ex) // Exception caught here and message displayed to the screen
" p  z* k# C! X& m4 s2 q          {
# \' d" h+ p( e                    ex.printStackTrace (System.err);# {4 Q7 ~; @( S+ x$ q6 ?
           System.out.println ("Error message goes here"); // Replace this error message with your own         
) d' A" i& s0 n        }# A$ t7 l+ @/ _" \" A9 v0 ^6 c/ p
                return true;* r; V* v6 K/ n4 K, G1 V3 @. u5 s
        }/ \% w( N0 G4 A& p' S2 Q& w! G

3 j) D% ?: g2 J% B3 b2 X. y2 T} // end of class ProgramCompare
! K2 a6 O2 c1 ?! ~* A
9 w2 {2 X) M9 L( M( `3 S( V//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
& |! t' O) L3 S! m//  ProgramCompareMenu.java    Provided by: DRS
; b8 k1 U, T0 k1 i//, U1 ]8 s& W! m0 n* v
//  Calls AuthorisedUsers.java and ProgramCompare.java
/ Z. i% |2 ?; g! m- J+ H+ N( O' f//
4 T' Q7 Y( K$ \- w9 U//  Driver shell for Assignment 2.
% `3 j; S7 |5 {: E* i//********************************************************************7 i. k* X, l  R2 T

" y# V; @; v* Qclass ProgramCompareMenu
9 N9 X$ h+ ~8 b) w3 A9 v- R( x{7 e  w* j0 {: k# C  ]  m2 C& U
    public static void main (String[] args)' R- j4 j2 }) J/ N- X) H8 r
            {
8 {! M+ I# ~7 Z+ E/ ?                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
5 J9 k; X9 y3 R, h0 r                ProgramCompare reached1 = new ProgramCompare(); ; ]* C% S% m9 M
                AuthorisedUsers reached2 = new AuthorisedUsers();       
( b: _3 u& q3 u4 s                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());7 i" |) q0 _5 J
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        / A1 q, |) Q5 W& ]1 |) s
        }
! I2 Z/ j7 A2 E. F& m}// end of class ProgramCompareMenu- j7 i% N& O9 q+ H7 e: r

' N" ], _9 h  t! H& ]//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
# e2 @0 }/ U3 }# u* M//          AuthorisedUsers.java          Provided by: DRS  G) x# B; ^" [/ p, {
//               
3 I' z# A* c' K+ r//         Program shell for Assignment 29 V7 E' F; Z+ c0 ^( i7 w1 p
/// L! v/ f/ s% |' Q6 ~5 Y
//         Represents facts about an AuthorisedUser2 _" B6 U6 M+ j3 G
//********************************************************************0 q) y' P% a! @" r

% l) v2 q" A  M; |) O6 b; C6 Zpublic class AuthorisedUsers3 }6 [+ @8 J6 L: ~1 }" N& K) B
    {
- l' r) d; r' j2 I3 }, ?, a% }1 N
        //-----------------------------------------------------------------8 \, B5 N3 p$ g
        // Constructor
- T) V: c- y) N        //-----------------------------------------------------------------
. ^6 @( l7 U: p5 o) k3 `  R% P: ]' y1 C0 L* g* q6 e6 U: i$ S" Z, J/ v6 K
        public AuthorisedUsers(), ]( {- \  u4 v! Z( P  Y
                {
* f' U% \* M/ T' L, @* @' ?$ b0 f                }
8 I' V2 d  M% R. o8 K3 G" C. K- C& @; T, t- ^
        //-----------------------------------------------------------------
& H* k; z6 _/ ~& K4 s" K        // Method for testing that class has been reached/ ?% K6 \' G% N# a
        //-----------------------------------------------------------------       
. i& ^5 N, K- q  @) @        public boolean AuthorisedUsersReached()' l5 A+ g8 [% I9 R! X* G/ |/ S. c
                {
$ h- x1 q* V& I( y' s0 }+ G! x                        return true;                       
# L% ^1 _9 i0 x  s                }
% ?  O* Z3 B0 i2 F' r& g7 r/ w               
8 z; m! `! F' Y( q3 e    } // end of class AuthorisedUsers
2 A6 N/ T8 ]7 g, r" l1 g//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming! F, l( i, @; v+ ]) {* o
Shanghai - 2007+ X6 |# B5 }1 m1 c: Q
Assignment 29 I; m$ N6 o0 b# i/ O' Y+ B
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)! ?( v; n' x; o$ F+ q
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.
2 [6 C; Z- H: u. NThe staff must be able to:7 |3 G1 I0 }. ]) }. c
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
6 N( i# C: [/ l: Y( `" K; r. L1. 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.
) ~9 P, n6 I# d The interface should provide a menu so that the staff can:- |& G% C' g) ~  ~( @. @
a) Enter the names of the two Java program files to be compared/ }& |* O1 S' v8 ^8 U$ O+ w1 l
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
# t1 @) d, S8 `3 G3 C** 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).2 T; B3 ^( `# ]$ z, Y, k
BSA104 Business Programming – 2007: Assignment 2- U7 F, I  M8 s
Page 2 of 5: m% b' C3 X8 c; g
b) Print out to the screen all the lines of code that are the same6 B( G/ T5 F$ p0 m1 D6 Z0 o
 Include the name of the file and the line number of the code being printed for each of the two files
: w3 L$ v9 m* ~5 ~( ?c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
  x# f# S- P- ~# J the name, username and department of the user- D# |& A5 u4 T5 [
 the statistics of the comparison
5 z' x! Q1 H# z. h% J- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
* D5 Z) [& c) k6 ^/ {+ F the recommendation for further checking; x+ J0 S! \. F1 f/ x0 X5 `
- 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
2 G4 R; n* `& w6 b1 Q the names of the two files compared
: `; d6 w6 y3 W/ f- H2 g# c; y1 g4 Md) Leave the program (exit)
  E3 r5 X* g. iThe ProgramCompare class: (Total maximum 20 marks available)
% ]% Q5 P' U# v; ~, l2. 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)" i: B. M# Q- Y2 E- x3 b1 k
a) provide an error message if the files are not found or there is a problem opening them1 ]" c; {4 |+ M( u& |! O
b) compare each line of code: e7 s; @; W( ~# i! R
c) print out the lines that are the same# ~( f. n% R, }: {
d) count the number of lines compared / lines the same1 W, ~0 w$ A. o
The AuthorisedUsers class: (Total maximum 20 marks available)
& c2 l. B# @$ e+ P6 I4 o3 I2 r3. 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)3 G. i6 ]+ H% ~3 S8 @7 y% Z+ U+ B
4. Provide methods to:7 K. y: p- K# I$ n. `7 |
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
! d& X2 Y* u9 N: kb) return the name of the authorised user
. D( j: g9 H4 Q* z$ I; Oc) return the name of the department of the authorised user( H) p9 x) n% E6 t* Q' l; \- I& }8 u
Individual Data (Maximum 20 marks available)  p# T: v5 x" M) Q) G: }
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.  v% J0 p0 ^& l# k
Documentation (Maximum 10 marks available)
% ?, Q' a: c4 {; `- s8 j* ?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.
+ \: H) y% l8 D. w$ kBSA104 Business Programming – 2007: Assignment 2# Y! b6 S1 Q% C
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了$ P; Q: a9 K% ^3 F
不过你要翻JAVA的类库说明。你有下载没有?
6 \& D. @' m6 p- T* t% m查询关于对比的函数。貌似关键字是contrast,还有compare4 x- }6 g1 }1 Q. K" N

; `* [# n( L6 K# p, M7 S[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -+ j/ q1 W% z5 G" z6 G
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
& F+ I7 Q2 _" X: _; o& }) X0 w; c可以下载到的 是 jdk-1_X_0-doc
- `1 H  }! C0 e6 p! g# @; ?8 p. t" t& M8 _3 M. |3 m5 v
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-12 23:50

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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