找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1501|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急: X# F- X& r$ ~( Z' s3 y1 X 3 c) q" u' {; ]6 |- R
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
1 G1 n5 |* Y% A* J//  ProgramCompare.java         Provided by: DRS
; g& x" Q. Q9 |% T' R& [( A6 K//" s: `/ `6 i& m0 U: |" x& Y; I
//  Program shell for Assignment 2; h  |& [8 X3 U6 Y, }1 H4 r) n, k
//: q6 [- W8 a% C. ]
//  Compares two text files line by line
1 @+ z% z% o8 p8 P! Q//*********************************************************************) D$ k- X6 ?6 _0 R, @; X$ M4 I7 O0 R" b

, A3 B, S4 i' T% T: Mimport java.io.*;7 c5 Q) A5 a# T- T

; I6 i- R7 U/ ]  R  G4 n5 e2 Npublic class ProgramCompare' M: }6 U2 s7 O* F7 q4 u( Y
{
, q+ ?+ ^" O/ i/ d  `# P9 w" c        //-----------------------------------------------------------------
# ~, T$ r, \/ g$ o$ Z3 E        // Constructor# `6 }; b: P: o. e/ [( h; x
        //-----------------------------------------------------------------
2 ^$ S  U6 w/ B        public ProgramCompare()
" H$ T" l* X/ @) E/ c  b        {
& L8 @3 L, D. o' m        }
, \& |9 ], H  W! |* c  f& R+ L2 w
5 C+ N( y' E, z( k6 h  i" `; D1 R        //-----------------------------------------------------------------
6 o$ u# K& _' w  {0 t        // Method for testing that class has been reached1 g3 y& P, E4 j0 T7 y: ^
        //-----------------------------------------------------------------       
- A- Q1 k  I) f, s# s. a7 `$ U
/ q* U6 b  a- [! K3 J- ?        public boolean ProgramCompareReached()        
( B7 k9 N& G. p6 Z2 t4 D, U0 ^1 s3 _        {
4 ]% @' A3 h/ }4 y# B& G; N! P      try
) Z6 K) g6 o* B* |   {         - E! \* f- h* B% @( N+ m
                        6 r% u2 @$ n% B2 x( ^' U* L5 i* f
                //********************************************************************% v) `( y1 ~" P: ]. ^3 \
                // Try-Catch Statement is used to handle exceptions - such as file not found * x/ L, D  E. T/ F3 J3 ?6 b$ o: i
                // Reading the files will need to be placed inside a Try-Catch - just like this one!1 q& S- ^; X+ C
                // For more information see page 534 of the textbook
8 D! Q) m8 b4 f) k  V7 W9 i                //********************************************************************
- A$ }( L7 ]3 e0 h5 C                    
8 x1 K2 W# q" y1 c& {+ n+ q. T+ m& a        }
" i, F* }1 v2 K: \             catch (Exception ex) // Exception caught here and message displayed to the screen
5 t6 y6 h6 M: ^  D  a: r8 i8 R) D          {" K# R# J: N1 U% f$ C) A; \
                    ex.printStackTrace (System.err);" `- t0 ?, L. P3 u8 V
           System.out.println ("Error message goes here"); // Replace this error message with your own          " G, ]  `3 b* Y4 T6 n0 k3 U
        }/ E! l+ M. D; g& M7 `1 r
                return true;
' t4 j; g- v! l5 X        }! \( P+ z% }" h. D' d  Q
, K- I$ _; k8 G/ Z# y% D) R, b! R
} // end of class ProgramCompare
3 _; }* [% g4 i) e& J1 a7 N8 H6 D$ r, u: I9 C; C" I9 @5 L8 U0 i( g
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
& H. T/ C% ^% g* X$ F* G: a//  ProgramCompareMenu.java    Provided by: DRS) [# p- ^3 T, x& h& N, C3 ~
//5 j  N  i+ S. M% g4 g
//  Calls AuthorisedUsers.java and ProgramCompare.java
  h( q/ k  A0 k: C- F* R//
+ \' J* t* a5 r# X, I2 J//  Driver shell for Assignment 2.3 O( E4 k2 j2 p; |
//********************************************************************
# I5 Q% e- B9 P" o. V$ }% F. l. O5 V' ~9 r; m8 _
class ProgramCompareMenu$ ^4 W0 s! W& K
{
$ g7 h$ c* w& E/ D0 M; y    public static void main (String[] args)! t* m) T& o5 Y7 p# ~- L7 f) K
            {
5 f$ a% q$ D$ @* P$ `                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
5 e) `' }& G5 ?                ProgramCompare reached1 = new ProgramCompare();   I, G* g& {6 M; w0 ~
                AuthorisedUsers reached2 = new AuthorisedUsers();       
6 ^, C9 J& ]3 ^( ]/ o% c                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
2 l& f) |# H. O+ m  x/ \                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
' U1 |: l8 N; t8 a. N+ h        }
# n+ _) F$ a3 X}// end of class ProgramCompareMenu
$ z6 r. P2 ^; v0 S+ v' R( @
2 X6 ~; ^5 }7 B//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************. s: Y4 T; P2 u7 Q, }
//          AuthorisedUsers.java          Provided by: DRS
. R; _9 {6 S0 X) Y//                # L3 L# o! i2 P5 ~" y% B# O1 w" p; L
//         Program shell for Assignment 2
- m5 H5 O& P% X# _//# x7 Z# [! H$ n0 C6 _
//         Represents facts about an AuthorisedUser
# L0 b- @* C: a3 @//********************************************************************+ S; B* o3 C7 y2 s

; [2 [9 Z- h. I6 Cpublic class AuthorisedUsers0 Z2 Z* U$ w& H
    {
0 N( y7 k8 ], J0 _; ]4 w  M
, V1 ]& H, [+ W7 S' u% s        //-----------------------------------------------------------------
" d5 S* J* ^2 O        // Constructor# T+ o! E( @0 s5 m
        //-----------------------------------------------------------------
9 \; w) t4 T- {9 J: v& G& X
  [* O# k. u! q' b. B) P        public AuthorisedUsers()# ]6 I: M1 K1 i& e  o9 {; O* h+ ]3 k
                {9 t/ [5 K' U8 t* r# E6 c; a4 x
                }6 s5 y: @5 r/ {4 Z( i0 i
3 J6 I/ F" u; c: \( t5 j. v
        //-----------------------------------------------------------------& I3 d1 E2 Q( K3 }- q
        // Method for testing that class has been reached
$ L7 }& f8 L- M1 ~' d' Z3 B        //-----------------------------------------------------------------        . O$ ~- a: b2 M' ~9 t/ @
        public boolean AuthorisedUsersReached()
. O8 x+ W2 _# Z. q  a9 V- C0 U                {) R3 C0 k+ ?. n& c$ g; x
                        return true;                        - ~& D: t; s7 @) I2 L8 ^
                }
% ~# a2 C/ l2 V% K/ g               
* ~, p  _! N0 k0 x2 ?2 O    } // end of class AuthorisedUsers
6 X5 M7 u: M" j) r: m' |//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
, _# I; S7 ^- D9 B+ `, |4 c/ D0 XShanghai - 2007  I# t% k/ d& i. c
Assignment 2
) t/ Z( m9 C3 M% DDeadline 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), f, {$ z+ _# l! P0 u4 S; x! t
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.
  ~( \3 j9 `' N, h/ @% A7 [, @" YThe staff must be able to:& K3 m; P* K" h1 }% }! b8 o1 K" F- u% Y
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
8 b) c: s4 t+ k, ?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.
0 o4 m. F1 r4 C& x3 l7 P* D The interface should provide a menu so that the staff can:% u" r" N! _% v$ A6 t2 j
a) Enter the names of the two Java program files to be compared
2 s  w% p4 e3 c' U7 p1 D) f; m For this assignment, it will be assumed that the two Java program files are in the same folder as your program.: |+ V8 `; B* K( v; q! q( z& c2 f0 [
** 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).
0 E5 Q9 M7 ]" A8 e' k3 O. |9 pBSA104 Business Programming – 2007: Assignment 2" M+ P4 ]1 L6 i/ D( h) s# r
Page 2 of 5
' l$ E9 {8 D& c$ w* {3 I& p4 mb) Print out to the screen all the lines of code that are the same4 t& t/ w2 d! W' _) ^
 Include the name of the file and the line number of the code being printed for each of the two files# m! f; q2 g+ D. E# [7 }4 J1 J
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
7 G* q: @9 l) {% A the name, username and department of the user. U; K1 ?+ b( A8 J& R$ E* r+ P6 p
 the statistics of the comparison
" l( w0 A  r4 l1 r: B/ m9 U- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different0 H1 [! T) y$ [- \$ {
 the recommendation for further checking
3 o/ E. X7 c' O: 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: V" [$ S4 p# T2 N5 q
 the names of the two files compared
( }+ c4 @* b# Y# {d) Leave the program (exit)
# b9 E( ?1 }, Y& w- n- s' v+ CThe ProgramCompare class: (Total maximum 20 marks available)
: \- z+ @2 ]  y2 h7 w2. 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)  _3 b) O* A7 k+ p) C- \* V" \5 J4 N
a) provide an error message if the files are not found or there is a problem opening them5 J, `, `3 p; C9 M
b) compare each line of code. j8 g; U/ \6 ~- `# k2 `: j
c) print out the lines that are the same+ K2 n8 h, p: {
d) count the number of lines compared / lines the same
8 p+ `2 B6 U7 i. n0 A4 W0 e  {The AuthorisedUsers class: (Total maximum 20 marks available). @3 A1 o0 q: P# u2 x! G1 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)
7 X: }5 X5 u( T5 O3 o% E  n4. Provide methods to:
& w: `, S- o' T+ A2 ^! Ia) 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
: |" y/ ]! o/ S, H2 Nb) return the name of the authorised user
, S' q& x* p( p0 P8 q9 M9 vc) return the name of the department of the authorised user
1 ]- \9 c/ B7 R' x& W" }Individual Data (Maximum 20 marks available)/ I2 W7 `; T& g1 ?1 |
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.2 W3 g! j2 o# \6 D4 U( `
Documentation (Maximum 10 marks available)( R$ p0 H4 ]2 w/ j- Q) H2 Z6 u0 Z: }
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.+ A% w8 \! A  Q, j
BSA104 Business Programming – 2007: Assignment 26 ~& V+ U; g( k: v- p
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了# X# r3 {  ?( x% E* X( r
不过你要翻JAVA的类库说明。你有下载没有?
! ^' R) I0 F! _% Y/ f& h: p查询关于对比的函数。貌似关键字是contrast,还有compare) \: q1 }% i& `# B& R

  H) Z5 N5 w$ e9 j: `/ Q8 ^: a[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -  J9 K( ^% S. s! {8 l2 P; G) S
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
* z" s4 L  b% U; ?8 q" x- y  H$ j' K可以下载到的 是 jdk-1_X_0-doc* ~6 d$ i7 i3 |& ]  e/ w1 J

9 U* `! U9 B3 ^[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-28 18:09

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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