找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1092|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急# @! h1 z$ A# a- b% V( W & p0 u; W y' U6 ], f
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
* n! K. E# V- j& S  Y9 t; B//  ProgramCompare.java         Provided by: DRS
" t% z. E# ]/ d9 U4 [//
% n- g4 Q% o% I* K//  Program shell for Assignment 2
) f& q5 N4 ^9 Y8 q& [: v7 Q* v/ w; J% E//* P1 R0 M* V6 [) v. Y
//  Compares two text files line by line
' W8 i1 J$ R" w! G2 d* E/ ~/ l( H//*********************************************************************' s' o9 U- ]4 T! w) t. l/ x

+ _& }6 t/ B- j* F1 O0 iimport java.io.*;
* a9 R& Q' r  D( x. g7 N7 l0 H" G  n& c- c) Z! L
public class ProgramCompare
0 H6 L  W5 m- R! I7 i( C{# E- s7 G! j+ S: ?
        //-----------------------------------------------------------------+ }$ {! j/ a4 h0 p! g$ H! l
        // Constructor0 N* I& i3 ~7 E+ n. S% k+ S- \
        //-----------------------------------------------------------------9 c/ I3 K3 C4 I* a) ~7 F
        public ProgramCompare()# G/ r( U$ |  T; v4 ^) n5 a
        {
! D" a2 z- O- S# k, H        }
  x) @2 i( S0 d. l
# u* K5 {* M4 a0 l) _* S4 @        //-----------------------------------------------------------------$ @; J  L4 f- s( u/ M" o& G
        // Method for testing that class has been reached
* m6 i" V$ ?1 V- F" Y' V        //-----------------------------------------------------------------       
# O3 r& ^9 P$ J
# u4 b9 t' ^5 }5 p# b8 \0 F        public boolean ProgramCompareReached()        
2 F4 a/ r% w+ n$ x) |' {. b        {$ @4 ~1 t2 c0 M9 |3 G8 P) m
      try
7 s6 A; v  S/ d" J: a- J   {        
4 |+ g& d% ~( k$ R% B# c; z                        * B2 Z+ t+ A- T# {+ A
                //********************************************************************$ Y/ f. P) M( A* G  F; T
                // Try-Catch Statement is used to handle exceptions - such as file not found
0 s6 k0 z3 `) K/ m9 g                // Reading the files will need to be placed inside a Try-Catch - just like this one!# s0 J7 J/ b! o3 }# {" G: Q' z; t
                // For more information see page 534 of the textbook1 |9 F  ]$ q* S6 z. x+ F* l
                //********************************************************************/ l  l0 a5 h; g. Q6 s( l8 w
                     ' w* z4 M( u4 Y. l' R) i
        }
) i7 e/ o0 M; S) U! z             catch (Exception ex) // Exception caught here and message displayed to the screen ! w( o  M$ |, U) N) m
          {6 U5 L" A- \9 c
                    ex.printStackTrace (System.err);
2 l) m) J# T  g* N           System.out.println ("Error message goes here"); // Replace this error message with your own         
0 V2 T. o3 F4 S8 \. X4 E8 Q        }
, o0 Y/ F. m& [) ]" m: @                return true;; P8 P& i1 g1 e. N+ d
        }' i8 I: x5 H- n. R6 s9 A* N0 e- i

8 ~- t1 f6 \* U5 y  L- l" x, W. W} // end of class ProgramCompare
' L  S$ Q" Q7 D1 Z& }% u1 W6 W( O" }$ G" r# ~3 B" Y8 u: h
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
" g: G- b/ A4 V- l//  ProgramCompareMenu.java    Provided by: DRS* G+ l( L/ r( g) J& @! Y
//
$ ^! _9 t7 U7 p- l: E$ _$ _7 P//  Calls AuthorisedUsers.java and ProgramCompare.java. D8 H! d9 B) m# e# b! O
/// `, F' M9 C; H' n0 v, C
//  Driver shell for Assignment 2.
( m- V$ }* S9 R) V//********************************************************************! h5 {( N( ^( f
- W( F) u  c* u  r6 ~2 f6 _8 n
class ProgramCompareMenu
1 k, b) h- s5 H{
% e# d* i  d4 w3 r6 y    public static void main (String[] args)
# l" S. d2 Z: y0 X( {            {
) G; t1 V7 [; B+ j* s& v  C                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
0 l& i6 Z7 Z' e                ProgramCompare reached1 = new ProgramCompare();
. e6 E0 M' l6 b( R% Y9 e1 r% L2 R7 S                AuthorisedUsers reached2 = new AuthorisedUsers();       
( g* \6 W' A$ z                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());# |8 b% m4 p  f6 T
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
! e9 y0 j9 Z0 H* v        }
+ F, p2 U7 O5 y% F. A2 K; Q( @}// end of class ProgramCompareMenu
( i9 w% A: t' l1 u, \. v( u- g! N/ F& O- o
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************5 L/ W+ T3 x2 C6 M+ X% G1 u6 b
//          AuthorisedUsers.java          Provided by: DRS
1 F5 H+ B& S  f7 ^- N, J! M//               
, [. D1 K& i- a* q1 r6 c- o7 g//         Program shell for Assignment 2
) @( M; n$ l# @, Z//' Z, r, {) k6 \7 `
//         Represents facts about an AuthorisedUser
( N# V3 T' l* Z6 Y//********************************************************************
$ r: Q- Y% N; u; W3 I% z
* V7 A, T- I& D9 \" C( T* u+ G+ Bpublic class AuthorisedUsers2 w: Z1 E' T1 g# q
    {8 O; v! G$ E7 {; A
6 A2 g  T# j+ c8 U; K) |
        //-----------------------------------------------------------------
) W9 t& L. u. ^5 @3 c        // Constructor
# G. M- ?& J7 L9 j0 u+ I0 x        //-----------------------------------------------------------------
8 f" \' e7 A4 \8 e" M8 i; f# w0 N% U& U8 K
        public AuthorisedUsers()
# O: ]: r5 {- h# V1 x+ `/ C                {2 J9 p7 a! B% S0 @# a6 |, ?) b" s
                }
! R' R" N0 Q' x% L
0 X! v8 G9 ~: z) j, x5 z        //-----------------------------------------------------------------
8 B/ x4 N' Z5 j$ D7 Y1 O; x        // Method for testing that class has been reached. `; j0 `; N, Y2 w0 m+ [: i& Y
        //-----------------------------------------------------------------        " y3 e  c/ R" o+ s5 q: ^
        public boolean AuthorisedUsersReached()0 B1 A, G& b" ~' k& A
                {
: e9 a- m' r, I                        return true;                       
3 v2 V$ i* i' u! O: N                }/ I5 N# h3 D' v- y3 r
               
/ w  d. o2 K& D( r& \6 t8 I    } // end of class AuthorisedUsers0 n/ E& T# ~+ t6 |: M8 ^
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming. w/ v) N. i9 {4 w1 B' n
Shanghai - 2007% B. ~: H0 o+ S9 J
Assignment 2- X2 ^  u! }8 Q
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)
$ Z* E. ]3 h4 r* e1 d' c& j1. 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.
: P0 N* v/ r2 I3 O3 u; L- d, BThe staff must be able to:
( l* G0 a5 g, @& z* q Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
* V: `; s: H3 z, Z$ S% g1. 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 [' D; V/ f0 i- n, u; b6 O
 The interface should provide a menu so that the staff can:* w1 o5 {$ M; M# b" V7 X! j
a) Enter the names of the two Java program files to be compared
0 }, H' @1 l3 r& K5 N$ D For this assignment, it will be assumed that the two Java program files are in the same folder as your program.4 f- V* U( J/ b3 Q* e0 d/ G8 V0 ?
** 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).: m( ~' n: q0 y2 J; J7 v
BSA104 Business Programming – 2007: Assignment 2! {# a8 ]4 m) g. W& p+ `2 d) u
Page 2 of 5
" z  H8 f3 H. S' M! K( wb) Print out to the screen all the lines of code that are the same
7 e- m$ K: j5 [; O& e+ d Include the name of the file and the line number of the code being printed for each of the two files1 O$ a1 W& |2 a
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
" p. ^; h7 D7 M2 I3 U% a1 Q the name, username and department of the user2 t: G& d- ^) S! c9 ], r% _- p+ Y
 the statistics of the comparison/ E0 g6 l8 U8 E2 p' A
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different8 z1 h2 N4 V. g
 the recommendation for further checking% C0 i5 p2 _, m5 C  l, x  Q
- 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 closely2 D! D7 U& g# K# R
 the names of the two files compared% |8 z" Z9 b  |& o1 V- D9 @8 p
d) Leave the program (exit)8 \: N: {# c" G  F+ I; V' U  v! V
The ProgramCompare class: (Total maximum 20 marks available)
* F) \+ c- x. s: o% J$ ^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 Q5 \- k: t6 b) L$ Y% x7 j
a) provide an error message if the files are not found or there is a problem opening them
4 Q+ S4 w# k; k0 {* F* pb) compare each line of code
0 \" r1 d! E; I& `c) print out the lines that are the same
4 |7 ]* ?4 g, C$ T5 [d) count the number of lines compared / lines the same9 ~3 S( b% e5 g. ~4 p
The AuthorisedUsers class: (Total maximum 20 marks available)
+ T9 B( C. F2 ^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)  Q) F8 M, r- E, d0 T8 ]
4. Provide methods to:
1 x) r4 V$ ?' g' M8 j6 ra) 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' Z& O: }- w+ ~5 e
b) return the name of the authorised user
- n" P# k5 a8 d& K. Ec) return the name of the department of the authorised user
0 }* K0 R% L, m9 l! h" P( bIndividual Data (Maximum 20 marks available)
* Y5 E" w5 v! c4 H) S3 P9 g2 n5. 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.
: V8 e" M! f# W/ {1 T7 A: |+ P1 |Documentation (Maximum 10 marks available)
3 R/ o% J1 r; y, p& L! o6. 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.9 w5 a- ^$ y' s9 j5 h& w7 i
BSA104 Business Programming – 2007: Assignment 2
; B$ O2 T/ k# Z8 y2 |Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了- g( n* y7 a+ O# B0 r# }
不过你要翻JAVA的类库说明。你有下载没有?
) J. y8 k" V4 i, B查询关于对比的函数。貌似关键字是contrast,还有compare0 |4 X/ z* ]2 ?! L( Z1 F1 D

$ ]: L9 V6 H4 k! @[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -& y% B3 L3 |8 U8 ~* u( F
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
0 h3 I) I' A, P" u6 }可以下载到的 是 jdk-1_X_0-doc1 B+ z0 t% b: e. H1 O: c

& y9 E0 M: ?+ o* i+ i[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-3-4 15:59

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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