找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1690|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急: g/ _- ]. z9 e$ e& R1 b. E 3 S% Q- r- x: A3 Q9 l: s2 X. D
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************- W; t0 R6 g& s. t
//  ProgramCompare.java         Provided by: DRS1 v5 K& O; z! B/ I# b* y9 R) F
//2 z% E! o) J( p- D$ f
//  Program shell for Assignment 2# N0 h/ m/ S6 C( i
//* S9 y+ u# ]% X: V! \
//  Compares two text files line by line* q/ n: v! I2 i+ C
//*********************************************************************
! h6 |$ H5 v  i9 m6 e/ a
1 S* s. p; V9 oimport java.io.*;
- j4 F8 P/ Q$ n: ?, i# h9 I% o! e; a% U1 @  `
public class ProgramCompare
0 c& G* ]! g7 @, p{
' e) b% ?; Y+ ?/ r8 S. ?$ u1 ]. B- d        //-----------------------------------------------------------------8 ]! F. p# W0 Q3 c- V
        // Constructor) @. M. @0 e1 _( M
        //-----------------------------------------------------------------
9 F2 Q. s) W. @5 E: ?( }1 t        public ProgramCompare()
! v3 S# R) j1 p: }+ h( h( F        {
3 G% B! [* Y* `3 P1 D9 i        }) m4 m$ Z" o, k% f. i& M8 E; `( M

, D8 V# O) e, O$ T& b8 l+ k. p) B        //-----------------------------------------------------------------2 k+ |, H8 r+ x# ^# P2 U! v
        // Method for testing that class has been reached8 K" J& M6 M; d( p& Q! n1 q
        //-----------------------------------------------------------------       
& x/ n5 z' O# D! E" h
; ?* k( ^$ r( j/ e2 U  z( u        public boolean ProgramCompareReached()        
" g- K. g& T6 R% G; Z2 Y3 J        {1 J# [) O6 M, e1 j, j, L3 l
      try
- O$ Q) A4 a6 k" L   {        
2 ^6 i4 n+ u7 R+ A( s( Z; U                       
5 W9 }+ s: w; ]. G: m1 D3 F                //********************************************************************/ _4 n9 o% U! {4 T+ z
                // Try-Catch Statement is used to handle exceptions - such as file not found
' d! l  n) [5 E; A7 M1 b# W& p$ ]                // Reading the files will need to be placed inside a Try-Catch - just like this one!9 x$ V! a/ t$ L5 A' B; K
                // For more information see page 534 of the textbook1 x) W3 ?$ T$ C  Q5 c
                //********************************************************************
0 M4 n  n; b) c. y' i7 @                     ! F% \) h1 Z! F: F
        }9 h3 k# m0 U! x$ Q0 w
             catch (Exception ex) // Exception caught here and message displayed to the screen
4 t$ _% m$ t; x          {8 j! I8 e% l* f
                    ex.printStackTrace (System.err);
3 k/ H# s6 P; O% n* ^5 C% V           System.out.println ("Error message goes here"); // Replace this error message with your own         
. D4 o1 k, U. {" I( ]        }3 f, N- h; v' R) z( u& F
                return true;
, ?$ |# A) ^9 g. H" \$ D5 l  y9 j        }
8 T  A2 O* Z' M7 a. W  X: R- Z. |% m) t( e5 T
} // end of class ProgramCompare7 N, e" \8 Y0 N8 B6 f
1 I8 T) w/ [1 |/ e. m( z; w
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************7 D( Y( A& v- w1 F5 E; x
//  ProgramCompareMenu.java    Provided by: DRS+ m5 L7 e/ K5 i$ Y! A4 G
//% c6 {0 K" N7 T5 J6 j
//  Calls AuthorisedUsers.java and ProgramCompare.java" r: r" K! j6 M, n% X2 D
//6 u$ X  k/ f9 W2 v4 z: L' k3 ?+ v
//  Driver shell for Assignment 2.( q7 t8 c3 {+ ?% a* q; h
//********************************************************************4 o1 j( {  j6 j& Z7 t; k$ e
; k  Z: r) T9 k# Y, `  r( `
class ProgramCompareMenu
; H6 p" G( I: Q$ N2 b. C8 S) E! i{
5 y5 V6 h, F& ]3 z    public static void main (String[] args)( W- Z, m2 F( F# X( ~6 u
            {
; u5 v6 o8 @8 V* `                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
% ?  |( X  Y  a% q  Z/ N                ProgramCompare reached1 = new ProgramCompare(); 5 y% Z' ^1 l& v, N
                AuthorisedUsers reached2 = new AuthorisedUsers();        $ t  C& Y, G2 n2 z* D8 y1 M
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());2 u5 G) o# @% X# l3 U0 J
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        . J9 H1 O2 ~- g: C0 Z+ @# }0 t
        }
; v% e8 @, C3 S  m* t$ {8 T% M5 j}// end of class ProgramCompareMenu
0 V" J* c* G8 D9 k+ Z: w! d% x5 t
: m7 k( x# A0 w0 |//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
" ~% Q7 o7 g3 n! s8 o5 _//          AuthorisedUsers.java          Provided by: DRS
" m) W1 a+ ?( O- K+ F2 K5 I. Y( l//               
3 o. t+ B+ ]# x/ K8 Q+ s4 O2 y//         Program shell for Assignment 2
0 d: `; e: i( Z7 _( s& N$ P//: H2 c3 g4 T. s  o# B, M
//         Represents facts about an AuthorisedUser# t3 ?/ f6 V1 \6 ~
//********************************************************************7 e0 B7 J5 z$ C  V; x

! E6 u+ [+ |: [) Qpublic class AuthorisedUsers( X- z  J. e5 r- P# Z5 A
    {3 g( r5 }. ^' X% M6 X* E7 t
' v3 ~" R* c8 `
        //-----------------------------------------------------------------* F) A  x# K. D; K3 Z4 x
        // Constructor
# J' G" b: M# j1 `! l+ M' k        //-----------------------------------------------------------------6 v' u+ }& ^/ k+ b+ J: f0 ]0 w  `, V

$ E* o+ ~9 Z+ B% C# B6 C. k# h        public AuthorisedUsers()* B% \1 e1 n* @! M4 V# o4 @
                {
+ M2 w1 u. A) ]+ i                }
* j4 z$ f0 N% r( Z3 B; g5 C% {. b* [# N6 ?6 w3 c+ \
        //-----------------------------------------------------------------
, X% X5 P% p1 Q& G* m        // Method for testing that class has been reached
% U: {& j6 T2 f' ^! \0 v/ I8 L4 G        //-----------------------------------------------------------------       
! ^+ e' X& }  }" D* `8 B        public boolean AuthorisedUsersReached()
: D" q, c/ y0 L" X- y                {
' M  R' Q! {, `4 P                        return true;                       
* M. e2 p! Z. m$ v# F                }
+ H4 ?$ R# {$ g* Z2 H                * t) j5 `  i: P7 ^6 J  ~5 ^
    } // end of class AuthorisedUsers+ i# [( S* v. `6 z: L" W, K! D
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming3 k" q- o* ?4 M- \- U; D
Shanghai - 2007
. K2 k, Q) h$ {# {; BAssignment 2* L$ A7 B- ]1 v4 d3 ?
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); R* r- k) }- `4 c* `. L+ A- g$ I
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.
; n- ~+ X' L$ Q/ T( hThe staff must be able to:" X' {4 }% N+ }3 L2 P2 \
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
1 V2 c; w: T: b3 l- p1. 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.  w5 H2 v8 d+ q' ]; U. n
 The interface should provide a menu so that the staff can:' Z, U: J" i( O2 |3 E
a) Enter the names of the two Java program files to be compared4 ]" {1 g7 S! f8 ]; i
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
' ~- w7 d- W( ?! d6 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).
4 V4 P$ n- M7 T, ]  L+ b& k0 DBSA104 Business Programming – 2007: Assignment 2: i( o3 i1 R% ?
Page 2 of 5
( A. t" p7 S3 K( g' nb) Print out to the screen all the lines of code that are the same, m3 h- H  g8 x
 Include the name of the file and the line number of the code being printed for each of the two files% Y: N& S& j, x& ?
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared1 _  J3 ~. V1 @3 W1 j" ^1 i' _2 d
 the name, username and department of the user
0 g) m- `0 d5 N% u the statistics of the comparison
: D+ U2 u. B2 r! s8 B3 h5 k- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
0 R; Q1 ^0 R4 t4 Z6 R  J the recommendation for further checking0 l, v8 |  u: N: F) u% D" O& R) S. I
- 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  N( P7 ~& |& J! O' G+ ~! M
 the names of the two files compared* }- _* b$ X6 G3 V2 W
d) Leave the program (exit)2 b) Y5 b$ h7 p( N
The ProgramCompare class: (Total maximum 20 marks available); `4 [( z! p% 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)* R0 X( o2 }& K
a) provide an error message if the files are not found or there is a problem opening them2 p4 j" G& @( q% r+ q
b) compare each line of code9 @$ D5 ^% v0 U$ }8 K* v! Q
c) print out the lines that are the same
, V1 N% Y! N# ld) count the number of lines compared / lines the same* j* q: H( T& T( |
The AuthorisedUsers class: (Total maximum 20 marks available)& A0 Y! ^% A" `7 s* F% E6 o
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)% Y& U: }% y+ {3 [' c5 G8 [% D
4. Provide methods to:) e7 d' a  B1 o% t- v; n& V
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 match5 C! ]5 H+ F$ w' N6 g4 _4 D- f
b) return the name of the authorised user+ J9 V. h+ G/ {7 {: p, N
c) return the name of the department of the authorised user. ?8 W$ e5 [3 @" i" m% t$ ]
Individual Data (Maximum 20 marks available)
8 {0 U: @, ]2 x0 C5 k  ]2 W5. 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.
; c5 ^" m2 M, j; f$ s. V0 C) F# ~Documentation (Maximum 10 marks available)+ r. J) M9 @  [' ]
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.9 x' O- D. J/ ]1 `& L) a% K
BSA104 Business Programming – 2007: Assignment 2
9 A# z+ P: j" T3 }Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了) f' W% I! E1 A" k9 }$ S* S
不过你要翻JAVA的类库说明。你有下载没有?4 }' e) X- h3 F$ q9 H! q6 L& ^
查询关于对比的函数。貌似关键字是contrast,还有compare( k. y( c4 `* x. X% X" o& `8 u3 X

4 i# F5 B( O2 Z! f# ]& l/ N[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
9 j5 l, ^; M8 ^1 X, T0 R" D/ `+ n' E痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。- R# S# f9 z1 i; L$ P: m* M- }5 I1 q
可以下载到的 是 jdk-1_X_0-doc; P8 a2 g4 ?. y" A- g# v6 r: ^
5 _5 I: t4 W* L. h/ h5 J( o
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-1 19:29

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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