找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1590|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急$ }" Z) Y5 a0 R4 n& d7 } 4 B8 N7 c3 _3 \3 t; }! t
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************5 u) }+ h) X) w. C4 q( ~3 Q/ `
//  ProgramCompare.java         Provided by: DRS
. k8 P- O( a" E2 l$ h//
: I) [- r; R9 ^* n//  Program shell for Assignment 2
* p, s% }5 M( {" @& g1 J//5 B; y) }  \" v. i! L0 z) G
//  Compares two text files line by line  N( U4 E- }8 Z) o% p2 R5 z1 c
//*********************************************************************0 q, d+ @+ D2 S. _1 a$ W  s
  Q: g: ~/ U" Q1 W
import java.io.*;
& G5 G* V; R; Q5 |# @/ f+ l1 U" P3 D6 \! q! Y8 G. k
public class ProgramCompare
: k6 e6 I: L3 p8 x$ U4 Z) p. m{
: @2 v/ o2 l3 G        //-----------------------------------------------------------------
& r$ c4 Z( ]7 D3 ?# S" E        // Constructor1 i' m1 S2 c  b" |5 G! H/ P" F
        //-----------------------------------------------------------------
  S9 v! U! P" z& V+ |; f$ p# Y- C        public ProgramCompare()
7 f. Q1 c. k) R: g        {+ D' c# n- S) b0 n  W: A
        }( V8 }2 U5 \0 `0 z

) i  C7 _9 O; T' O& O6 M* H' q        //-----------------------------------------------------------------2 E& M, x9 R* M4 \. ]! a
        // Method for testing that class has been reached
+ l6 c0 b5 K/ d% N& r& z' V        //-----------------------------------------------------------------       
0 a$ Z4 P' U$ C5 m
; l/ a# k& R( F" t! ?4 a        public boolean ProgramCompareReached()         8 U/ n, N8 @6 F( m* C
        {
2 \. ?2 I9 {9 c0 |1 @) S& A6 J      try - |, f2 w* ?) B7 L  V
   {        
2 f; L6 ]$ `, M2 C/ S# q                        / Z* p5 j: B9 v" f
                //********************************************************************
9 _  f) ]. {+ F7 q                // Try-Catch Statement is used to handle exceptions - such as file not found $ D, Y- P' ~# h: D: c5 T7 Z. ^
                // Reading the files will need to be placed inside a Try-Catch - just like this one!/ f# r% x9 Y% l0 ^$ i# h
                // For more information see page 534 of the textbook! P- ]! a' s" o5 L/ D3 u, _
                //********************************************************************: ?# h/ k* ?5 k8 N1 x
                     ( x" [2 _1 s3 p0 F
        }
) w/ G9 r5 @* v' Q# u; h             catch (Exception ex) // Exception caught here and message displayed to the screen 3 X4 F7 W2 {1 r- J( M4 y
          {- y5 X9 v+ v+ u# v! t% C
                    ex.printStackTrace (System.err);
( [) E/ u5 |, p# }& i4 u% X* m$ _           System.out.println ("Error message goes here"); // Replace this error message with your own         
* K: b- j% }( o; L- x) J        }8 k$ y' h7 A& |9 Y) |2 U* M4 m
                return true;* d: _6 N7 @% \2 _2 T0 H) a5 @  z
        }! K! F. H6 f+ p& v/ y! L: P

8 Q; y4 P9 Q2 m& U/ h% _, s} // end of class ProgramCompare5 F% P3 r) \1 q! G0 }8 y, \

" P+ y; j4 j/ l" O. g) J//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************! w. v% z- n( N8 e+ k7 \
//  ProgramCompareMenu.java    Provided by: DRS4 F& b" `' z" H5 h$ u) X5 r- e
//6 N5 `& w+ M3 b" Y
//  Calls AuthorisedUsers.java and ProgramCompare.java
+ f& {- b+ T: R//
" S, s% j! J: M* t//  Driver shell for Assignment 2.2 M0 }2 d+ o7 m  I% r
//********************************************************************
- U( N$ n* i7 B2 u' D
/ [4 m+ x4 u0 }5 B0 i  h7 f) nclass ProgramCompareMenu) v! F# W: b& c6 U/ `: X
{
, H7 R' Q4 D% N$ J    public static void main (String[] args)- {7 Q. Z8 {$ u% S0 R
            {% _: G7 p$ E& h' T) M; N
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
7 U6 W7 G7 W" c                ProgramCompare reached1 = new ProgramCompare(); # T& P: R. p2 r
                AuthorisedUsers reached2 = new AuthorisedUsers();       
3 x* Z6 K; x3 K8 D                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
6 S0 o/ J* f7 V) S4 m3 B                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
; O& K) j% k0 Y6 e( c( F3 T        }
9 g- I0 F3 _3 e8 l7 L, W+ P}// end of class ProgramCompareMenu
/ G3 v' q# M- w5 `0 r) x' [* S
7 W0 O- D' \8 E; k1 B7 u6 B//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************! F3 O  D- f( ?( r4 v
//          AuthorisedUsers.java          Provided by: DRS
* s3 u! ?8 x3 n  ?  t1 ]//               
- I  ~+ s" m) v) [) I& j" p9 ^//         Program shell for Assignment 2. N0 y* ^  G' h# b; g. _& e
//
: T) g) Y6 b2 d: I, m! D  l8 r/ t//         Represents facts about an AuthorisedUser* m9 L8 |9 g  u  }& k
//********************************************************************/ F: g; Q1 {8 P& }2 V9 _; @# z
: V# F$ Z& b, l/ k5 b# x
public class AuthorisedUsers: d6 y4 d7 k4 Q0 {4 c5 e, m
    {
; a# f6 `; r% M/ c9 x$ n* G$ @. i9 ~& i  P5 f5 h% u# j
        //-----------------------------------------------------------------% a0 I& B3 g) ?4 ?( @+ F
        // Constructor- \$ p; _$ ^. j" n  [
        //-----------------------------------------------------------------  j- B: Z4 C* h# ^, B
1 |8 i' B# n/ ^2 `) X
        public AuthorisedUsers()
& h8 t9 A, ]8 I5 ]                {0 a& ^4 F) q% q8 d% D) t
                }- F- l. ~1 v& j* U9 E0 d
1 h+ K5 m! M3 w6 s
        //-----------------------------------------------------------------
6 r7 ~* J+ o2 q: B3 _; r2 N/ z3 O        // Method for testing that class has been reached
+ L3 N, g7 m0 C4 h        //-----------------------------------------------------------------        ! t) G# \% d" l. Z& O' S8 j& w
        public boolean AuthorisedUsersReached()2 j' Z( h( L2 T. D5 f
                {7 ^. g' M/ H. w; n
                        return true;                        * l$ H7 w/ z7 {9 W! C( m  @
                }; X% _3 Y1 o$ ?1 S, t8 T9 ~
               
8 K; ~4 g1 ?1 v! f    } // end of class AuthorisedUsers
% e; @9 P7 U+ ?//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming  N2 {( c+ l& p7 R! J8 r- O
Shanghai - 2007
" z' m' G; C& u+ EAssignment 2
) W4 B4 T4 h/ g! {7 ?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)
/ L5 a! }& [& g  N6 [" P2 B7 x1. 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 I5 `( E: a$ I1 U1 B; Z5 iThe staff must be able to:$ w) O+ j" d" M: y# Z7 H3 `
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
! z* g  f$ F2 Y" N0 _# {/ X1. 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.
# e1 |" v5 M( K& D4 o The interface should provide a menu so that the staff can:' C2 \2 _# ?5 x. P- m# F, r; j
a) Enter the names of the two Java program files to be compared! S8 Q7 s9 L* @! t9 Q8 y
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.% H: a1 G+ B6 v; h) d
** 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).. s$ F. `: c* C* |4 a8 ?
BSA104 Business Programming – 2007: Assignment 2
0 B6 c; q( _4 P& r5 a: H4 h9 WPage 2 of 5
) v/ S1 v" j: g8 ~' b" `# Wb) Print out to the screen all the lines of code that are the same
0 A; d0 X5 D( e# e/ ` Include the name of the file and the line number of the code being printed for each of the two files
3 a/ k: v9 P) Gc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared. X1 \$ B1 F. O7 O
 the name, username and department of the user
' G! L  A# \5 \# J the statistics of the comparison
( V6 f9 ?9 D. b# B# T$ y- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different6 E4 d* P8 r- s: e/ c. v+ }- Y
 the recommendation for further checking+ O, c  z% g* x/ l& ?7 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 closely0 p$ N6 f8 S0 @/ Y
 the names of the two files compared2 r6 i1 Q7 n' h; }
d) Leave the program (exit)2 [% e, _/ Y9 K1 q2 T! E# M
The ProgramCompare class: (Total maximum 20 marks available), g% K) x- Q6 \7 W
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)# [' k" g/ r: f+ F4 ?% b. x2 a
a) provide an error message if the files are not found or there is a problem opening them
% |% p+ z; o4 h4 ]& [& _b) compare each line of code
3 B  j5 o3 ]2 C" y8 S2 |c) print out the lines that are the same
& F7 `) h7 Z# G3 N- Y: yd) count the number of lines compared / lines the same
" T- a0 D! X1 Y  ^The AuthorisedUsers class: (Total maximum 20 marks available)( G+ g1 r; |3 r
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)6 g: v% z) E8 V! |* S  A
4. Provide methods to:0 \% Z9 g! d# M( R6 K
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
1 r+ y& [7 @! M# Ob) return the name of the authorised user
( _* D: Q7 y. t( }' ]9 fc) return the name of the department of the authorised user
1 c! T) w) y& m1 _5 GIndividual Data (Maximum 20 marks available)& j9 p$ q: H3 |4 O
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.
4 A% x+ I# A* r$ j+ eDocumentation (Maximum 10 marks available); k3 U  `7 d" q& N5 R* g( C% Y7 f
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., r/ ~5 m0 m: @/ W
BSA104 Business Programming – 2007: Assignment 2
$ e7 Q- J, Q+ {, p* [. _, XPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了: U4 U6 E$ r1 {! a  j$ D, }# _. Q
不过你要翻JAVA的类库说明。你有下载没有?
: c: w1 E( [5 K, o6 Y& [查询关于对比的函数。貌似关键字是contrast,还有compare
6 y9 P+ z2 L. X; L* i8 C% a- H7 S
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -4 c# P$ v- W0 p  ]& P3 c; l' ]
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。" T5 x- ?5 {3 S+ U0 ?: L
可以下载到的 是 jdk-1_X_0-doc3 Z2 y. F" k" h/ [$ ~0 }$ }

( }- g# [* l3 M* |8 u( q7 d[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-30 09:33

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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