找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1274|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急' }- j8 g2 W' H+ }; P( `; f 0 u; [( @( W' m2 [# I: t1 W& o
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************8 b: {& G6 P% Z8 {: T+ W
//  ProgramCompare.java         Provided by: DRS
$ h* f+ w' C. V3 k$ q//2 G0 _: H7 m& L( D1 S
//  Program shell for Assignment 2
/ h+ Q5 {: ]. _7 N. z) E4 J! g//
$ S+ E4 i- X: t9 {8 Y! K//  Compares two text files line by line
7 S/ ^- D. P0 W- u& k9 }//*********************************************************************4 s8 d8 _4 z. d7 e

  W: F- k. r; J4 Himport java.io.*;2 v) `& @5 T" P

& [/ `9 K  z+ O+ ^3 K% l. Q* ?) ppublic class ProgramCompare1 ^( A) Y5 s  P  B% r
{# m& F" `  A. R% }9 A
        //-----------------------------------------------------------------
( p1 _1 y5 i/ }$ x/ }        // Constructor: M, l: Z- X" `4 h2 O9 ]9 u0 J% C1 J
        //-----------------------------------------------------------------( k. }& Y5 M" ?
        public ProgramCompare()
* s. N. p( ^0 n, K5 ^  W8 Z, A2 p        {
5 C9 _  L' z& O4 Q        }
7 ?3 `5 n) M# w  j
# Q5 X. s( q0 B0 G$ r" Q        //-----------------------------------------------------------------! P- m5 O7 U; o4 g
        // Method for testing that class has been reached
% Z" ~; t3 ^( F! H8 H1 Z" H        //-----------------------------------------------------------------        - L- m7 a9 ^9 ]2 ]
; Y6 U" h" D) A3 B0 o
        public boolean ProgramCompareReached()        
$ L/ n0 }+ d* c9 T4 a7 Z  E        {
; F, J" O9 L6 [$ @; A      try
' E- N2 [- g: h( x8 M. l2 \) t   {        
2 E1 L6 n; a/ }/ c                        + j) X7 q9 ]: q& C
                //********************************************************************; |0 T* p7 J1 ^
                // Try-Catch Statement is used to handle exceptions - such as file not found ( y5 }' J- B( W+ ?
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
6 E3 m! K3 [( T' F6 d! w                // For more information see page 534 of the textbook+ `3 y8 ^+ Z0 F+ n* Q; V2 o
                //********************************************************************
! D' S' R' P) u4 l                    
! \& z; z2 x& z+ K; p, _. _        }; t; n2 V7 i! Z  k5 Z
             catch (Exception ex) // Exception caught here and message displayed to the screen , C5 x9 A: Q( C4 ~% f
          {$ @5 t" s/ m- ?& A# z$ U1 O
                    ex.printStackTrace (System.err);
; d% g8 `, {) ]* t8 Z) I2 P$ J# A           System.out.println ("Error message goes here"); // Replace this error message with your own          ( U3 d: S, e- `# A9 Y7 e/ @: D4 v4 h+ o
        }! O9 a9 u2 j: B- Q
                return true;
9 C, q+ K- Y7 `8 t        }
9 Y: L8 ~! D+ K) V# m& R" j3 g" h
* y0 R" j" f( l& k9 u$ b} // end of class ProgramCompare* P' e8 j. ?, X+ `0 [

/ D# l( ~( B) i3 j) E* b3 A8 j+ e//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************$ Q+ Y& n- s8 p# r  r% ~
//  ProgramCompareMenu.java    Provided by: DRS/ V8 {1 A5 `1 [6 g; C+ C8 k
//5 T) @  x& J  ^8 [: y5 b. Y
//  Calls AuthorisedUsers.java and ProgramCompare.java
& l4 l0 ?/ C; X) `: w5 ]//
) a! N- y$ L3 S9 f//  Driver shell for Assignment 2.0 x! l. l: H  O$ v, S
//********************************************************************
2 w3 j% F% F( N) Z2 |; p: _) Y% `, w: t- W. p
class ProgramCompareMenu: E+ m. u+ i! n
{. J; D- s2 ^- l! Q3 n1 g; T% |: n
    public static void main (String[] args)
% }6 d3 e- [: m3 b7 r6 }, z3 c            {6 b0 f- }* H  J; n/ p* c# F3 s
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
) m% ^" o* x+ n5 R( h4 `                ProgramCompare reached1 = new ProgramCompare(); ' \6 X9 N. o! |1 @: X. X1 F
                AuthorisedUsers reached2 = new AuthorisedUsers();        & [! E# B8 D; s9 a6 G. n/ f% F
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());# x6 F% t4 F5 l+ ]4 n: j1 _
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
9 H3 L, t2 d' Z' m7 g$ D        }
9 Z$ ]0 k! @8 d0 ^2 \}// end of class ProgramCompareMenu# T4 t1 U* a; s) q, O( I+ K

$ W) W, d$ j+ X' U- \* {//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************5 q  ~/ |1 G7 _4 a3 I7 h# w, ~  T* \0 N
//          AuthorisedUsers.java          Provided by: DRS: o; T- F4 |2 u6 C8 k
//               
9 e7 v; A' u- V' C- b4 F+ f2 s//         Program shell for Assignment 23 N& u( s6 \1 q  B+ J3 x& u9 P
//1 _/ g0 N/ `+ U2 z2 d( e. C
//         Represents facts about an AuthorisedUser* M2 C: X% j% R: i$ Q, R4 A' M
//********************************************************************
$ D. r8 A4 @1 b; H0 A: @4 f/ N# c
, U! g7 |- R1 q7 dpublic class AuthorisedUsers! v; _  M2 `- ?
    {$ ~- R) C/ G+ k( y2 H

' ^6 @4 F2 {( A; [" X# `% l6 L" [        //-----------------------------------------------------------------7 ~0 e1 |2 `; _2 m
        // Constructor3 }7 M. k  h4 V/ Y: j
        //------------------------------------------------------------------ Z4 f1 L6 `8 C# B8 m6 |3 G/ V) p

9 W. x  C2 K  I. q: t        public AuthorisedUsers()# q$ C$ g/ |9 g% c& k" I; k
                {
, C! T, J+ y$ @1 |. T4 P: b                }
1 W8 ?1 v9 _( Y$ f, }0 j/ ]8 r8 ?9 H: F. j
        //-----------------------------------------------------------------
) D  w2 R* ]# Q: a  i7 @0 X& {+ a; M        // Method for testing that class has been reached, r2 ?7 n5 s  Q
        //-----------------------------------------------------------------        / P5 ]$ @" q; y1 |+ C7 j' i
        public boolean AuthorisedUsersReached()
* d6 x, L4 i$ P7 a+ l                {0 X6 v% W) z2 H/ X3 ^8 L3 v7 x
                        return true;                       
6 o7 @! j, V0 b8 W% W                }
1 ^; i2 q% o3 h3 [                ; B& ~% q: a! O- O4 t7 l
    } // end of class AuthorisedUsers# y9 y. O7 q3 w7 Y- Q+ v" g
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming! [, T5 X7 D8 v: G" ?, ^
Shanghai - 2007
' R; ?0 ~1 n( u0 TAssignment 26 O$ _& K! n' g7 M
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): k0 U& Y5 M" \8 h3 U4 \
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.
4 o+ d' a/ b$ z3 V% u# b3 B: NThe staff must be able to:! G2 J2 g8 @" O; y, s
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
. T; L3 [* @# l7 z4 v- z  h1. 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.
+ n( P! i2 p3 B) Z The interface should provide a menu so that the staff can:
, t* v' U. a6 f# D% }8 ?( m4 u9 Ya) Enter the names of the two Java program files to be compared
; b* J  m+ B5 y7 @  m" ~ For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
2 Y/ _( m3 O: I- Z$ h! C% z** 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).( V% H, N/ V' B. C% x
BSA104 Business Programming – 2007: Assignment 2
( A4 y8 R" v3 xPage 2 of 5
  a3 v8 T% e$ V5 F: ?- Eb) Print out to the screen all the lines of code that are the same  X( l4 D: U: e" U1 g) q
 Include the name of the file and the line number of the code being printed for each of the two files( r. V7 H$ T$ y% S( V
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
' F; u3 Q- g1 q. l5 e the name, username and department of the user
- t- i2 `9 ]; O6 y the statistics of the comparison- s  p. {% f+ `1 f; P9 K" i" P
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
) e% p# M; t5 R+ t, I; S; N the recommendation for further checking
! B! q, V$ a9 ?5 w( a) l- 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
6 C3 b  {0 Q5 f' ` the names of the two files compared
# B/ R* {- d" z; A7 Td) Leave the program (exit)/ J- _- ~7 d; e' C' y
The ProgramCompare class: (Total maximum 20 marks available)) ~. }7 @# X/ @+ C' _
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)
8 ?# o8 Y- q7 g( k" Ua) provide an error message if the files are not found or there is a problem opening them
' C2 a( r* Y3 i9 g2 t9 bb) compare each line of code
% Z6 @1 O/ R& ^6 Z; o, s" Nc) print out the lines that are the same
* W" B) ]& ]9 I# U/ Zd) count the number of lines compared / lines the same
6 S; }- A8 [6 w3 K' uThe AuthorisedUsers class: (Total maximum 20 marks available)
) h2 @, Q3 N& m& o& D  i5 D3. 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)
8 D. v& I* A0 G; K4. Provide methods to:
, @" x( i' j+ ua) 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
" c2 j" {( D- D' |3 d  b* z9 fb) return the name of the authorised user3 L2 T+ w$ f& V6 x! ^7 `
c) return the name of the department of the authorised user
0 p8 B; `& j' v  y8 p- o( V" B2 eIndividual Data (Maximum 20 marks available)  V6 o; L0 O, ^" {! `, v$ C
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.
% Q6 ]0 i0 A" i$ zDocumentation (Maximum 10 marks available)
- u* i  r- |" \, \# j! G6. 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.
- g& O+ K  _& V# k  H0 u- j5 aBSA104 Business Programming – 2007: Assignment 2
, D5 q+ n  G% o: TPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
8 y2 X( n) B' }( Q" S; j: X不过你要翻JAVA的类库说明。你有下载没有?
( `' I4 t& R8 A$ I8 o6 L查询关于对比的函数。貌似关键字是contrast,还有compare
( v, f, h4 A# c/ U& s  r& O# z9 X* m8 C/ I' `% K$ h
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -5 |: }: b1 y( q
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
4 a5 u' o  W0 E+ j" Z可以下载到的 是 jdk-1_X_0-doc
7 R3 J2 O- w5 `9 t0 z7 O) I( l/ z0 }% u. x7 K' X
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-14 10:04

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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