找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1136|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急3 t. o' ~) F/ ]8 g 0 h( U/ M& G# A% g
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
. v& z5 p/ r, ^1 C! O; r, u# h3 D//  ProgramCompare.java         Provided by: DRS9 i! V3 L3 t* m0 H2 m! h3 C
//9 Q! }0 x% |9 S# J" E6 k; S, g
//  Program shell for Assignment 2
4 u$ T4 u7 |: ^//, L2 ~: K, _3 l/ {+ H$ T/ w4 A
//  Compares two text files line by line
  L! N; F* D" c5 _) A6 J6 f: Y//*********************************************************************- S; k/ O( a2 o7 T
0 J+ A  s6 M; I- I' u. `
import java.io.*;
( R# ]- u; V  b5 M/ f0 ~( T$ h" P5 {8 o( Z  z
public class ProgramCompare) O1 Q4 f2 n0 g
{6 c3 M5 C7 O' _6 u
        //-----------------------------------------------------------------3 q! d( N8 ^' c. L% V: A+ L4 z
        // Constructor" |- D( X# v9 C% O( z) ~
        //-----------------------------------------------------------------  @* v0 p2 T8 F( [
        public ProgramCompare()6 k2 }( F7 `# }0 D: U" d: N) H4 |
        {0 W8 d# h* A! z* ~) h; @" [7 [
        }
: L: @% m% f4 D9 ^
9 ?: B  X; m6 A/ U# p7 Q        //-----------------------------------------------------------------
. q2 M% J# [* n# L% E0 ~        // Method for testing that class has been reached
5 }  \6 p/ C  b4 c0 D        //-----------------------------------------------------------------       
" h( ?/ m# f% E5 z
1 b% @, ^& B( v8 |/ v- C: M        public boolean ProgramCompareReached()         & h7 f; _/ `  A* h( U  o
        {7 J6 L* h2 p' i  ?, S; l3 ^7 ]. M
      try , Z& k/ l' b3 z2 Z6 {, n0 H' ?
   {         8 }: s& Z$ ]# d
                       
  O. J9 P) s% V3 }                //********************************************************************6 s: T' r  Z7 P) Z, m- j
                // Try-Catch Statement is used to handle exceptions - such as file not found 9 v4 L5 G2 V% f$ @% B% s9 N. i- w1 Y
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
9 s9 D. P: t& L                // For more information see page 534 of the textbook
& s9 E  c' ~. Z                //********************************************************************$ Y( ]! ]# E3 u& g+ h# Y
                    
4 T2 y7 ^1 w& N5 {6 }/ G2 m. t" @        }3 A7 U1 y4 L4 ^
             catch (Exception ex) // Exception caught here and message displayed to the screen
4 s* x7 L% O7 y: |- {          {, q: T7 {" j* V' R
                    ex.printStackTrace (System.err);# H2 b2 I% }8 g0 v' ~  D
           System.out.println ("Error message goes here"); // Replace this error message with your own         
% \5 r0 b) y! I- A( G8 S) _        }2 a2 z& H+ {) w
                return true;
4 V1 k" D! ]: d% E1 k# \        }" j, i3 V/ E2 B% U- h
# J5 u$ c! R: ^0 K2 T' P
} // end of class ProgramCompare
9 y; n' _8 i4 x# }" I) }/ ^* E' K& j
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************: z% e  P! S4 `# L& O- J& m
//  ProgramCompareMenu.java    Provided by: DRS
5 s  H7 j- @# ]' V//+ s  {8 Z% d0 W  S
//  Calls AuthorisedUsers.java and ProgramCompare.java
% h& y% C) M) z( W$ i6 K//; p  R/ k* }' @& f3 X- _
//  Driver shell for Assignment 2.4 {! u0 c$ ^$ g7 O: L7 M! C/ U
//********************************************************************4 p8 `) g6 }+ A6 c
3 Q6 ], U& V8 Y" c* U, x4 |
class ProgramCompareMenu1 M: X7 a+ ^8 {) {4 U  J
{8 J" ]. I1 u( t8 m
    public static void main (String[] args)/ K- |4 n. d' c% U1 R5 [5 N+ n0 @
            {
5 K% E4 i5 A2 K$ z                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable5 B3 }6 l! L& p' K1 ^1 @, q
                ProgramCompare reached1 = new ProgramCompare(); 7 l' e5 V6 N& ]
                AuthorisedUsers reached2 = new AuthorisedUsers();       
# X- Q- @1 t- ?- M# }                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
9 {: s! _  r1 O6 R9 k                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        : f( ]: R3 J+ h( r8 S8 [8 I! R
        }5 S; V9 e/ }0 F% O; o
}// end of class ProgramCompareMenu
; s' V- {" {. U7 C3 O8 a/ G, Q1 [; n# U5 Y% w( K, F
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
  x& ~' Z& x; @/ F1 _/ b: j0 H  g//          AuthorisedUsers.java          Provided by: DRS
/ P# F5 c; P2 z5 \5 J2 W//               
2 x# k7 J# Q) X, a9 w//         Program shell for Assignment 26 e( Z, H" l8 ^: J: @1 a  ~
//
+ e) |& D) o# b/ Q7 n% ]//         Represents facts about an AuthorisedUser
5 L  w! _1 O, K+ s+ t- L6 h8 G//********************************************************************% K- S( n0 j% H* X8 m1 n, ~
  W% I( j7 B4 j( X: N
public class AuthorisedUsers
  f8 Q/ @1 [! E7 N, a9 h% {* J    {
8 i6 |& L( T( F3 `* y$ B: D5 q
$ Y* U2 {7 Q, V- A        //-----------------------------------------------------------------# a8 G3 N7 ~+ U: m& H5 r
        // Constructor
5 ^  Z4 q  Y5 V* A* o' ~5 m. @( x        //-----------------------------------------------------------------
3 @; R" b( G4 t6 W4 I! O
8 a0 }/ y. ]1 c4 Y- C        public AuthorisedUsers()  k6 Y0 X% _6 b8 G' k$ i$ ~
                {3 [& u% [6 h( e* ?/ s" k
                }
1 x2 M+ A6 k: o( C9 B1 f2 |6 y; `, [8 h
        //-----------------------------------------------------------------  B: h  ^1 n3 I' ?$ r" d% b' Q4 Y) n# z
        // Method for testing that class has been reached% @8 a# o  g: o2 n
        //-----------------------------------------------------------------       
$ l' S  E( p1 I) i$ E7 t; c- u        public boolean AuthorisedUsersReached()7 c4 C  N. X/ h1 g/ v
                {, }* u; ]2 }0 P# @
                        return true;                       
( v: D% {; p; C* X' h2 H& Q                }
0 j( N  }5 H# |# o. j! d                & |' U* Z2 y0 K6 M
    } // end of class AuthorisedUsers2 K* |+ }9 C4 j! Q
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
. z- u& q; x( H4 HShanghai - 2007' t# L) s/ V/ }9 B; K7 p! c- Q% T
Assignment 2
2 \" X2 c. P" B; Q) f! j- RDeadline 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)
- \5 c% K) G  [7 E$ i) ]/ Q" q1. 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.
( u& j! Z) [. s" NThe staff must be able to:) t. E! T8 ?) q7 ~9 L
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.+ l1 ^' Y7 ?3 _; u" D3 {/ T
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.
5 [8 h% F+ r2 i, }! h' V The interface should provide a menu so that the staff can:
( {+ e0 n1 `& x1 `( Q  w) Ja) Enter the names of the two Java program files to be compared: s3 m( Z3 k6 e! A* E0 }+ M
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.3 w: ^9 {5 B1 j
** 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).
2 p0 b3 [! T5 U6 i. m5 A/ R% QBSA104 Business Programming – 2007: Assignment 22 l: A# U  g/ x$ Q9 |7 i0 C0 a. L
Page 2 of 5+ b, d; O# o/ J1 q$ T
b) Print out to the screen all the lines of code that are the same4 s0 W( o* q( |
 Include the name of the file and the line number of the code being printed for each of the two files5 {, I* b1 l, A" a
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
. m; p9 a2 v$ Z3 q; t the name, username and department of the user; o5 i: Z2 T' ?/ Q( N* D8 d! w' l
 the statistics of the comparison& }4 m) K) `6 D9 N) Y
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
( g" f2 ?$ f+ m/ g the recommendation for further checking+ y( o% g% ]4 u
- 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
  M: S) }& s2 Z6 h" P- N the names of the two files compared
- r6 i$ t# V8 E$ e  Qd) Leave the program (exit)
/ |! Q* L( B$ T8 ]  wThe ProgramCompare class: (Total maximum 20 marks available)! o( a5 x/ v. L3 A" Z* I$ A  X+ H
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)! R6 L: v' e( O5 }& f; m! |/ e
a) provide an error message if the files are not found or there is a problem opening them: E# t+ _+ J: \  F. T) K, V
b) compare each line of code* T9 \9 H0 D  q& ]% ?- y) q
c) print out the lines that are the same& q4 u5 N6 _# u- q" T
d) count the number of lines compared / lines the same! ?+ H4 d+ S; @; j; y" [  C3 y% a5 e
The AuthorisedUsers class: (Total maximum 20 marks available), x& Y2 J6 }) R/ u  v, a
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)2 @, b, U: I/ Z* Z
4. Provide methods to:
2 z, z+ ]' T+ |$ \6 b( ma) 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
  d) _' z9 p( U, j) _7 O5 X7 U+ u: Cb) return the name of the authorised user
$ G) \+ p' R! V/ _& fc) return the name of the department of the authorised user
2 O* ?/ y2 Q) P# k& s4 yIndividual Data (Maximum 20 marks available), K' a' W$ @+ [1 m
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.
5 ^8 ]6 ^, s' j1 r" V1 H+ ?2 \0 G  cDocumentation (Maximum 10 marks available)0 K: s6 L" m  ]2 @3 c0 X& d
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.
% V1 F* x, \, j, CBSA104 Business Programming – 2007: Assignment 23 `9 d2 u4 x$ ]  ?: ~6 }5 }# }" G
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了; B+ F5 G6 l: z9 e3 O( E7 T! {
不过你要翻JAVA的类库说明。你有下载没有?
9 y3 k+ r& {$ C4 F( ?( H0 x9 d查询关于对比的函数。貌似关键字是contrast,还有compare# h* _* V: c% L, b

1 x- a6 q5 v) D, t8 H8 u$ }- P[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -% g1 I2 y2 v7 V6 _6 v
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。; _" y, y: T8 S( G. m5 l6 O
可以下载到的 是 jdk-1_X_0-doc
1 `) j) V1 J  c4 R+ c% [% m
1 G4 F" J; X0 H. [; ^7 ]8 N5 K4 ?[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-3-23 01:49

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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