找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1615|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急8 z0 h/ N$ [1 C) Z1 d1 N / m( f. M2 a/ l4 Z: ]5 v& K
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
; L) z: X7 i8 \//  ProgramCompare.java         Provided by: DRS
4 O0 d$ i7 I3 x  c; S( \# N" F//
* Q: q- b  B% I% S7 j0 H; H//  Program shell for Assignment 2
2 u% U* q' W4 O1 V+ \5 s: H* V0 L//) ~6 T3 T7 r. T3 I, o! Q
//  Compares two text files line by line" B  L$ X" O! U' q7 `, x2 \
//*********************************************************************4 I" @! i% `, h: s* S" @0 v  J
% P) M5 e- e# M# R+ v# U
import java.io.*;6 d% u  f$ _7 r
6 T! [+ [+ W* x
public class ProgramCompare
: Q# I( z& O! Q{
6 z8 T, p0 Z" h( M        //-----------------------------------------------------------------6 u/ d9 y' C9 `9 ~9 S
        // Constructor
/ J5 X% r: f* Y  P. h        //-----------------------------------------------------------------
5 m1 y* F) x3 b  g/ B& x5 L        public ProgramCompare()1 j$ d; b9 o$ J8 [
        {
; T. K4 h0 p0 r. ^        }
) W( A$ m  k! Q; O* \$ n" x" ?+ o
        //-----------------------------------------------------------------  p7 `; }# b- z/ f' L2 f% i
        // Method for testing that class has been reached/ |: ?2 f' q, b7 l  d6 _% {
        //-----------------------------------------------------------------       
) O/ i1 |" P9 d  H1 Z5 C# C
  Z: e6 i8 _# @* a$ K; @+ X8 V        public boolean ProgramCompareReached()        
9 w3 j8 X# @- T8 g# [; X, l        {
+ X. ^/ o1 y+ v% w      try ( G* ?9 Q2 j: k$ B) p$ f  V
   {         ( ~/ L% \9 R+ M6 h
                       
+ ^# o) p3 p+ C0 [                //********************************************************************
% F/ m% f* J/ k/ T                // Try-Catch Statement is used to handle exceptions - such as file not found
! G8 O: k* N! N3 B3 n* |                // Reading the files will need to be placed inside a Try-Catch - just like this one!
8 ^0 J) ?% _3 b; `                // For more information see page 534 of the textbook: ]/ \3 a+ o: |0 i
                //********************************************************************
2 }6 \: s+ K! X/ z                    
8 f9 r; U$ T6 ~6 j% I. M5 B! Q        }
4 V9 a/ k* j. A             catch (Exception ex) // Exception caught here and message displayed to the screen / a; ~$ x/ R; a' u# [" P
          {# S, T+ ?- L3 Y( q+ u
                    ex.printStackTrace (System.err);: o( v8 e" N6 ?8 S$ Y6 a
           System.out.println ("Error message goes here"); // Replace this error message with your own          $ L4 u5 e9 B! ]% S
        }
. |. v+ B4 Q! r' g                return true;; M; H' W, k; x7 w) w
        }
. s; c0 u" Q* w5 {9 K2 y$ D" X! @! P" C  r
} // end of class ProgramCompare4 p6 r0 G) y1 s- e2 M, c: p

9 h# z( v8 s; u$ J7 w* M//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
( C+ c/ h2 i  y. c//  ProgramCompareMenu.java    Provided by: DRS
# `; ~9 b0 W4 k- w' s' ?//* L' }2 {! x" Q6 ]- ]5 }
//  Calls AuthorisedUsers.java and ProgramCompare.java
, g% O8 X5 b, O! e1 z! \6 V//' B( j- f+ L: J" i! [
//  Driver shell for Assignment 2.
6 ]1 t* f2 h: l4 }4 S# w! t9 Q( b//********************************************************************# \4 G  [+ ^2 s) b

+ P, Y/ y5 o2 Y; _# }class ProgramCompareMenu
2 D4 p$ _% O0 J# C0 h8 m5 J{+ M/ W- N/ V1 h: T3 @
    public static void main (String[] args)
7 m  L! _) \# m            {7 z* |& U  ^& v
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
& N/ Z7 _" P. o0 L- h' L2 S* R                ProgramCompare reached1 = new ProgramCompare();
, c  p, J  u' q  a$ C4 j8 K& k                AuthorisedUsers reached2 = new AuthorisedUsers();       
) c3 F# i- w) l, A                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
! Z. a- e3 c$ [- B) F! u$ Y; L                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
$ S  P  G8 j2 ]5 L5 M        }, U5 w' l. j; `( b* v% R! _' Y
}// end of class ProgramCompareMenu
6 h0 l4 t; H0 o, h, @- O  Z% K' D  O
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************+ I6 l+ L' z* _8 P# n
//          AuthorisedUsers.java          Provided by: DRS
7 [2 Q% [5 v, a- B4 R& S& U//                - S. W0 s& m: }2 K4 v' z
//         Program shell for Assignment 26 Z( x2 _+ S7 J7 W- L8 o' F
//
& _% H2 Z0 T# |/ }  W) `6 D# q//         Represents facts about an AuthorisedUser: ~/ }! y9 m' O2 q* o/ e+ l: d; ^
//********************************************************************
6 [- A9 B8 n1 k; T& m! }- O
$ |) H: e/ I7 U- Q) ?; L% Z/ X1 E- bpublic class AuthorisedUsers: U% @' A3 d/ N- G7 q5 T( R
    {6 L( m/ H7 I0 d* H

' j, H" j4 @2 Q/ V' b! ~        //-----------------------------------------------------------------
  X: {; c( J8 }7 A5 s        // Constructor" \8 g  ?* C/ }* W# c
        //-----------------------------------------------------------------; N" h' C5 o7 U

: ?& F( v" P! I2 d( H6 @% I        public AuthorisedUsers()! y, m  U: m' |3 @7 K
                {. ]8 n9 C# x5 m' n5 _7 S
                }$ V$ s9 z2 m( u/ a% C( b

8 k  E7 c) r) h8 k        //-----------------------------------------------------------------
6 `* r( {( c5 Q( f/ f2 M        // Method for testing that class has been reached
7 g( V5 @  r8 x0 l  c0 @  Z, F        //-----------------------------------------------------------------        8 ^* B# `! g+ C5 h5 k9 @- Q
        public boolean AuthorisedUsersReached()
. u+ i5 l! o. I+ D( j$ e6 i/ S                {5 |: L% b2 Y1 D
                        return true;                       
- A; g4 N+ F- ]- t! G7 N                }' V! l' O$ n6 e8 D' F3 Y7 _
               
" i  c0 q: K% T( l3 \8 E    } // end of class AuthorisedUsers
" W: d& f: L, h! i: a//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
9 h; z( W; a- V0 VShanghai - 2007
) @- `8 ^% w& a. k& NAssignment 2. N9 L3 S2 g0 L" n5 l! X& L
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)
( g/ J* b7 n  D8 J& F8 Y2 r( l" K1. 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.
0 U3 X* c1 n2 o3 o# [" F/ d  @1 k; SThe staff must be able to:
  E+ e4 L! b( i: d9 q8 x: b Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.& I# ]+ I4 d; b  }, b) P
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.
' u8 j& x) _3 v The interface should provide a menu so that the staff can:
! r. @% o  Z4 x+ Y0 M) F7 N' Va) Enter the names of the two Java program files to be compared
3 \* B- g+ U# x For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
9 t" {: T/ Y- e" w1 A( A** 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).
) l' U9 B3 q  e0 Q& q6 f0 ZBSA104 Business Programming – 2007: Assignment 2  x+ I( A. ?' |3 |
Page 2 of 50 b: ?2 r, F4 M3 J
b) Print out to the screen all the lines of code that are the same- I. v' e) |) v( b1 X0 B+ Z
 Include the name of the file and the line number of the code being printed for each of the two files; X6 D7 ^  m. ?. C
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
+ p6 |4 G0 X& d5 t the name, username and department of the user  G: t% g6 i$ f/ o( l6 u
 the statistics of the comparison+ }3 f+ R( X4 T
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
, E5 e% ^: v5 T# |! o6 _ the recommendation for further checking) i& I* h) ~" G, o$ n8 s; Y' Z
- 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" R- ?1 O6 h8 `
 the names of the two files compared8 Y  h+ R3 z% P2 l! q8 h
d) Leave the program (exit)- S1 l& ]# \2 u4 {- M
The ProgramCompare class: (Total maximum 20 marks available). r1 m0 v$ D2 K" ^0 u
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)1 w) N  r! Z" R$ w6 o
a) provide an error message if the files are not found or there is a problem opening them( _8 P0 R: f3 P8 a
b) compare each line of code" i' I( W0 O  l) f) R
c) print out the lines that are the same
; o( U6 I' c5 f4 n9 q$ I. Id) count the number of lines compared / lines the same" U& _" ^3 Q" G0 g8 e$ g5 h+ L
The AuthorisedUsers class: (Total maximum 20 marks available), Q+ s% u3 W5 N; M# o. w6 t5 i% J& F
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)0 J, x( j) ?3 t% x: ?2 n3 b. |
4. Provide methods to:* Z7 A% l: |: L) F! D
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
! b: B, r3 v8 s% S" sb) return the name of the authorised user
* C+ t9 `7 ^* z7 d7 lc) return the name of the department of the authorised user0 T4 k1 e; V! p4 Y5 `, U
Individual Data (Maximum 20 marks available)
! V1 k; D' u+ ^: |& _+ K5. 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.
& H+ c9 V/ N$ M: y0 }3 _7 dDocumentation (Maximum 10 marks available)# c0 {7 v/ {9 r6 e3 ]
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.0 R- ^- B% W0 }3 L) \, C0 l
BSA104 Business Programming – 2007: Assignment 21 D( w7 d& u3 ^; S5 n
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
- B2 }$ x# K+ |1 `! @; a/ q) x7 g不过你要翻JAVA的类库说明。你有下载没有?3 P0 e; [( p! c9 h. q+ N$ ]
查询关于对比的函数。貌似关键字是contrast,还有compare3 F% y  C- o( E2 m5 Z
; D4 U( N/ y' R3 R' r8 [8 V/ |  F
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
; M1 W0 u0 m+ Z0 a痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。' }. U' x8 J6 x! j" M  N
可以下载到的 是 jdk-1_X_0-doc
8 T4 x. r; P4 t2 q2 I; t- R+ N8 Q( k* g. y) j6 D
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-9 04:21

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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