找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1163|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ) U. y" w5 ]% K" b8 l. X8 U0 n6 J- y! e5 C0 y: h7 q8 C4 ~( [$ b/ 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 | 显示全部楼层
//*********************************************************************6 c4 o1 S' T0 z: ^" r
//  ProgramCompare.java         Provided by: DRS$ n/ u( b# W) x3 D
//
2 k! \: y2 D# r( \- C1 D" A//  Program shell for Assignment 2
$ T. A; ^  k5 \0 \7 M- M/ I$ c1 ?9 o//) k& U- ?( }! U3 D
//  Compares two text files line by line% r# a+ g2 }5 w7 y. }
//*********************************************************************
  d) Z  e, e4 v) d% N
! B3 k* U6 i% B& z" r+ ^8 kimport java.io.*;
$ A3 Y4 V2 r6 d+ J3 ^+ ^, T9 E0 b' m% N
public class ProgramCompare
- L/ l7 z, Q' g% U( u+ {5 V* }9 T% x& B{2 N  B5 ]; ?1 A' i0 ?: s
        //-----------------------------------------------------------------
. L$ s, d$ v8 I& `        // Constructor1 q8 b6 R+ j- _8 q- D4 D* v8 v
        //-----------------------------------------------------------------
' t8 F& q5 a) ~+ t- A; j' C        public ProgramCompare()6 r7 f% H6 k" T% e
        {: }% i& j* p" S/ e  `* f+ {% w
        }' _1 {& u3 U* b# k
3 F8 \+ C- Z) p8 j' R. j7 ^5 Y
        //-----------------------------------------------------------------
! u$ k8 Q8 {1 P  Y! X        // Method for testing that class has been reached+ D% i7 O/ N' F  t0 A( D
        //-----------------------------------------------------------------       
: _/ d" k1 n- ~7 }. m8 F' b3 z/ }9 D# x" j4 O9 L# w4 A2 U" e
        public boolean ProgramCompareReached()         3 y7 w5 g; |4 ^. G' k
        {, X2 t  K: F4 s* C: V/ A: ?
      try 9 E: }4 l3 D! Q/ v5 J4 F2 o
   {         # P7 C- X: N( e! q/ ?. i
                        ' t9 Y4 x6 R! H+ ?4 o, Z
                //********************************************************************$ l" z# b. r0 Z) o& c: P/ d" r
                // Try-Catch Statement is used to handle exceptions - such as file not found
& W( |8 Y! U: p2 N; D                // Reading the files will need to be placed inside a Try-Catch - just like this one!+ h% _1 o; b7 j" t, T/ l! d
                // For more information see page 534 of the textbook0 Y+ q4 q6 F6 q' ^* k' R
                //********************************************************************! k% }7 U( X6 `+ t' ?0 f
                    
" ?( @* _! s2 m. Z2 l        }0 f) p! M( ^) W& `5 \, @2 O
             catch (Exception ex) // Exception caught here and message displayed to the screen
; Z$ }- H" f7 j/ |. {8 |          {
- m, W/ k5 d4 F5 N" P  [1 {, v2 ^4 s                    ex.printStackTrace (System.err);! g6 E* b; _! w3 `
           System.out.println ("Error message goes here"); // Replace this error message with your own            F( Q! V& a5 j1 X/ f1 W$ S
        }
5 B* |1 ^5 f) g! }                return true;1 f5 f8 ~4 }, b1 F1 z) t* ]% _7 M' f
        }
5 R( M; Y: @9 m6 i# ~
1 _2 X$ ^3 J7 B! |} // end of class ProgramCompare! n" N' ^, H) b

/ h! G- |* F2 m: ^. j1 E! N3 o//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
+ q( c8 w+ G* N) W! ]1 b3 V//  ProgramCompareMenu.java    Provided by: DRS( l6 a8 D' x" ~
//; x% ]* w  v) [2 {' y
//  Calls AuthorisedUsers.java and ProgramCompare.java
" |. N4 O4 l- ]" s//
; G9 g- Q, m1 [8 Z& S5 @; k//  Driver shell for Assignment 2.; O; A5 H1 k/ `$ g3 Q  c0 n
//********************************************************************
2 n7 O% F, k! R& n7 s2 l7 s, p
" x1 X7 q0 S4 _" g6 P9 Aclass ProgramCompareMenu9 s+ ^8 M8 M) M! E5 q
{
' ?& e0 A# v. m( u    public static void main (String[] args)9 p0 H5 O) z3 a$ N
            {
( a: {8 F+ ]0 k$ F7 I# C; V' \% x, P                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable4 }% b5 a; `* R# Y
                ProgramCompare reached1 = new ProgramCompare(); ! P( V! ~* l9 \' h1 @
                AuthorisedUsers reached2 = new AuthorisedUsers();        ( N8 E) v% M+ w' K
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
0 d. F0 ?" V  [+ R& Y/ b' q$ U                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
, I# m% {, g0 b$ M  S) h        }! }% N( L  {+ y, i: ]
}// end of class ProgramCompareMenu" v% M# Y' h: \

, b2 H) }8 n+ `! {//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************5 X. L; h0 W& r5 @- v
//          AuthorisedUsers.java          Provided by: DRS
1 G: D/ l% o+ Y4 _: g//               
. l) V+ q& e" w# c/ t" b$ d//         Program shell for Assignment 2; L% `6 ~7 n+ O  H9 c# U7 m
//5 y3 w1 q9 x8 s
//         Represents facts about an AuthorisedUser
3 i6 M: ^. `% V" P+ J//********************************************************************
( F, {9 p; ^6 j+ x- k, o" C
$ z/ m4 }6 _8 v% I# U& [6 C4 v, b: A! mpublic class AuthorisedUsers
( ?' i! l2 l  i5 P" Q$ ]    {7 J/ b$ I1 U: `# p2 Z

& t, `1 ~4 C9 }4 r# t; ^) y9 e        //-----------------------------------------------------------------0 l3 L" a" ?, L& U3 c; B8 S
        // Constructor( X: g& X/ J- _' e9 ~* {6 i8 N
        //-----------------------------------------------------------------1 \% w  `# x  b0 {* f

5 D& K6 |2 e' H        public AuthorisedUsers(): l- Z! s4 U* y5 D6 w) X& {
                {
5 w+ ~/ z$ }+ F8 P- W; {                }- }- O7 [1 P8 K2 q0 O2 P$ t) v
' B3 ~! {: l3 [( E: X
        //-----------------------------------------------------------------2 v$ n5 ]+ I' l, g( u
        // Method for testing that class has been reached
2 C, ]4 R: q1 N$ R& D' A& a# {        //-----------------------------------------------------------------       
  d; I) m( c& T& ]2 ~! F  T' a# R7 K        public boolean AuthorisedUsersReached()
% T$ N. {6 @7 z% X                {
) }- D  P% S& e4 l  \                        return true;                        8 D9 h+ E) M- e0 F- {' ?
                }4 y: h/ \7 c3 X' i- y) J$ F9 K
                % e; n; b# K3 R5 `' L8 E* x; Q7 x1 c
    } // end of class AuthorisedUsers
5 _/ s+ @$ o+ ~( ^. H+ F1 ~1 T* l//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
3 _# l" N4 D' u/ yShanghai - 2007, v1 l6 w1 S5 X. o) q% f& A2 J
Assignment 2
" k% y& ^8 ?0 Z  G+ JDeadline 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)
7 `% Y" M7 E2 P; g" F/ 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.
" B  l, M0 D3 P# yThe staff must be able to:
4 _8 @$ m5 ~9 Q; q9 v' ^4 m Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
& w" b  P" D- y  t2 L1. 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.5 `/ f) w5 b' T# U2 M2 f' H2 D
 The interface should provide a menu so that the staff can:# R( ^5 c' s! k3 t$ u" M
a) Enter the names of the two Java program files to be compared
  M% F2 M: D8 Z( f& _  }3 |1 m For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
/ x1 y7 \* X5 @& m# Y  Z$ Y; 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).& |( Z& P  M2 |* }3 j: H
BSA104 Business Programming – 2007: Assignment 2
. Q5 J  ~6 G7 o" \% B$ A& cPage 2 of 5. v0 r& B/ ?, G) s) m4 L, f/ X. w) H
b) Print out to the screen all the lines of code that are the same
5 ~0 R. a) h: m. Y; u6 [* ~ Include the name of the file and the line number of the code being printed for each of the two files0 z) F6 K7 k4 B- e! N
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
. C5 k& l! \) E6 c the name, username and department of the user
2 t8 I# h" ?: x* C  L! M the statistics of the comparison+ B0 {7 o3 k8 P% m) H& b! p
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
7 s# {' ]/ i. e) i4 b2 C# G: c the recommendation for further checking5 z1 S  P" x/ e) F: U. {" n: M! k8 {
- 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, _; b4 t+ Q1 X5 y4 t; H7 q the names of the two files compared: x9 ?# P5 Q8 t7 h3 ^6 Y( X$ w
d) Leave the program (exit)( x% ^; l1 d$ |
The ProgramCompare class: (Total maximum 20 marks available)9 _- `& J) `8 c' ], ]+ F
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)
) P" n$ Y  Y/ J$ Pa) provide an error message if the files are not found or there is a problem opening them" w; {$ b/ q' a8 |
b) compare each line of code3 F  `* G& z# q1 v" W+ D
c) print out the lines that are the same
) G( f( }" j6 O: r) Y% R4 A8 s# dd) count the number of lines compared / lines the same- m, N# e$ v9 X" e2 V% H% t1 e
The AuthorisedUsers class: (Total maximum 20 marks available)- ~# D8 }( I* V2 @1 z
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)
$ h6 T- ?9 ]! }. i4. Provide methods to:
. a7 |7 ~9 G( `2 H. j. a7 {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 match7 Q# ^1 t- f8 `1 F" c& A
b) return the name of the authorised user
) R- v9 _; |/ @5 M& Cc) return the name of the department of the authorised user
* I; O4 v3 U# f, @* w' c3 X# gIndividual Data (Maximum 20 marks available)
  z* B! A5 N, L9 I* A% I5. 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.) \  N! K0 |( z. \: W/ S/ ]
Documentation (Maximum 10 marks available)9 L, B& L* d, _; @4 u% Y- W
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.
# _# I9 W) ?6 x* w+ T7 s( G  `1 OBSA104 Business Programming – 2007: Assignment 2+ L5 a2 [! b5 Y8 z  [0 n9 H8 c
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
7 y: t( \0 t4 [不过你要翻JAVA的类库说明。你有下载没有?: R0 U1 H0 C, k
查询关于对比的函数。貌似关键字是contrast,还有compare
1 X+ c( I# r5 F' S* H( m9 ]: F
" p& S" t7 ?  M, @2 m[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
# G2 K" _2 e/ Z% G% o& }痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。' G, z  s* T# B$ Q) n6 J
可以下载到的 是 jdk-1_X_0-doc5 }7 g! Z5 a, G: `! F1 w

: Z$ i& b8 z, ^# x[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-7 08:15

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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