找回密码
 注册

QQ登录

只需一步,快速开始

查看: 966|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ' [5 k4 X5 Y; K: v' ~" Z/ R . R5 \) Y* r+ o/ S7 | Q" 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 | 显示全部楼层
//*********************************************************************
5 ~; l5 p( p2 T: [# s, U//  ProgramCompare.java         Provided by: DRS
# N/ l5 c3 c: y4 y, ]9 J; Z& A" |//- N, u4 X2 N/ z( i1 D" p" X5 {+ d
//  Program shell for Assignment 2* q# [. ?4 v2 P& t& d7 @
//  `/ ]: i" [! d/ D
//  Compares two text files line by line2 n8 `4 Q2 n" p7 V8 o
//*********************************************************************  U* g7 ?3 u2 O3 C/ H
( j8 B3 I" z" J9 |7 \2 O
import java.io.*;. @6 w' d& \1 t) j4 U% C

* W) B4 q! k; r( ypublic class ProgramCompare
1 X" z2 N1 r& D  c{7 B. O5 ]# n* v' U
        //-----------------------------------------------------------------
* e2 L6 K- v5 L, ~        // Constructor
, U; h' s: h4 _0 E        //-----------------------------------------------------------------, D7 H( g, g+ i, C
        public ProgramCompare(): C/ p1 ?9 z5 w8 E
        {+ J; ~0 B/ i" k0 k3 J" x; ]5 g
        }, L) @( m3 w. Z, L3 T6 e( \
: n( F  G/ s: v" `4 p4 ]
        //-----------------------------------------------------------------
5 T9 v+ ^3 x( X9 q$ g3 U        // Method for testing that class has been reached
( E( K- ?5 M( g4 G4 Y4 w# A        //-----------------------------------------------------------------        * a1 Y, b, n* E
0 s  x9 M1 k3 `6 F4 ]. [
        public boolean ProgramCompareReached()         6 A8 s; S. u1 @7 ^; U
        {
& e: I5 E% o1 X6 Y2 K3 }      try 2 M* o# x# a5 T7 ~
   {        
2 A" W# V5 Y0 s* @! _9 s                        & _: g) W, H$ y6 V7 j) Z
                //********************************************************************
* P% D( f" V5 r$ q, q) \                // Try-Catch Statement is used to handle exceptions - such as file not found ) g% F" z+ b# |" L6 x4 Y% |5 @. u
                // Reading the files will need to be placed inside a Try-Catch - just like this one!  e* Z  Q" Q9 s% }$ }
                // For more information see page 534 of the textbook8 z+ ~- @0 Y# W0 e! T0 u6 K
                //********************************************************************
% t6 t7 [# `5 p) {                    
2 V2 N7 p! ]7 a2 B8 \        }
3 }9 U8 ]1 v% f1 i9 s0 O/ q1 h             catch (Exception ex) // Exception caught here and message displayed to the screen % n$ y( N8 i7 D) k/ i
          {; |$ O3 p: r0 m& S* w1 d* ^* T* {+ }
                    ex.printStackTrace (System.err);
- v6 _7 n! S  L* {8 \; X9 }7 {1 Z1 N           System.out.println ("Error message goes here"); // Replace this error message with your own         
* Z0 v* l( x2 s! g6 U        }
6 _9 t4 A1 O5 }9 O                return true;
, z3 t4 V1 x/ J4 S( @% G7 B        }$ _6 W4 L# E4 D% V2 m
9 q+ Q, z* D+ J* N: q+ X* y
} // end of class ProgramCompare  h& v( x9 z+ b9 G( E
0 M" j1 W) b2 c* k7 Z
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
2 W8 i, i1 w8 S5 u* j1 [7 R//  ProgramCompareMenu.java    Provided by: DRS7 T0 `. w' [# o; J  [, S' R
//
/ K2 [  |  j  ]//  Calls AuthorisedUsers.java and ProgramCompare.java
. h6 ^# Q+ T7 M2 k' h//* ^' O- E* X( i/ Z
//  Driver shell for Assignment 2.
- H9 R- g7 }( `* v4 }$ u" s//********************************************************************
- X- I4 f- k) K3 a* o0 [& }" _3 R: J6 L
class ProgramCompareMenu
. i# E) d/ I! r. w2 s5 ?, {{4 @* E3 Z4 z% Q( l0 ^& L
    public static void main (String[] args)
1 @6 g9 L; M9 H            {
, n, n# w6 O4 S% g/ i/ Z                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
" x* \% y; Q, _$ f+ ^                ProgramCompare reached1 = new ProgramCompare(); : X# W2 O0 h, @7 c' g
                AuthorisedUsers reached2 = new AuthorisedUsers();       
+ F1 u& J) M  E  H                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
, ~# n- [: X  M' K6 r( n                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
8 W" K( Y3 S9 \; W        }6 U$ d; v7 v/ a. @; B2 G
}// end of class ProgramCompareMenu
& m  X2 ?( N9 Z( G$ u0 x% ]; g$ J- w6 J: t$ N: u6 k, {' Z( ~/ h/ B
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************3 S; l2 H& O5 n; k1 R- x
//          AuthorisedUsers.java          Provided by: DRS7 z: K& B2 c6 _7 R% q( f* ^. e
//                2 f, n* b, G# [% E
//         Program shell for Assignment 2
# Z" G- W, l9 X6 i% Z//- A( s4 p! @4 l
//         Represents facts about an AuthorisedUser+ U" \5 k# Z2 k% u5 X
//********************************************************************
( p8 G  E+ i/ o9 g; `$ n: l
* h/ n; H1 b7 i& hpublic class AuthorisedUsers
; J4 |4 O" R" R6 D5 q- W9 i5 V# G: m    {7 k9 F' ?4 ?. ~1 j) p& X
' h3 Y7 m% d0 W6 j" T2 g
        //-----------------------------------------------------------------
6 i- }6 V! B# F% @, W  p' [4 D3 _        // Constructor* k8 p& M1 o8 E( s, m
        //-----------------------------------------------------------------
& S  ~* z' I$ D
  S) G9 j5 t( b* E0 a: J        public AuthorisedUsers()- `# @' ]3 e6 G, m
                {( M/ A; t; B, X: z! s& F
                }
: H$ z$ v# R; p  [9 t5 J6 _
1 w# {3 e$ {9 y+ N; D6 H. o0 @        //-----------------------------------------------------------------; Q( }8 s* T+ u, A) o
        // Method for testing that class has been reached
5 O' @+ n$ c7 c- e! B5 _% x        //-----------------------------------------------------------------        5 O* q) C/ @) C# a. l9 H4 {8 ]
        public boolean AuthorisedUsersReached()$ T' P4 q- w# i
                {3 q8 n8 Z/ s7 A8 w
                        return true;                        * h' b6 G( z# B: s7 a4 f9 D5 b
                }( \% @( j  D# r) ^" k) h$ B
                4 l$ L2 H( P9 \( ?. \9 a
    } // end of class AuthorisedUsers
2 a2 w/ I. G2 x3 s. s//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming9 [! u" T1 `& Y
Shanghai - 2007
; |. c& ~& j) U" kAssignment 2
5 Q: G! L' ^" X- nDeadline 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)
/ L' q; i' c& ]7 L3 ~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.
0 b* h2 K3 b; ~9 cThe staff must be able to:
/ J( q4 x! z- y- Q8 \0 Q6 e Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.& d4 G5 B; D7 d! a
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.3 Y* S  Z  e+ |5 O1 E
 The interface should provide a menu so that the staff can:; I! q" M' i- x4 Z
a) Enter the names of the two Java program files to be compared! W5 j, x5 o3 V% v6 I# h
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
, j5 {% I' _8 p( L9 |** 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).- {" h5 X  f) p  d" f
BSA104 Business Programming – 2007: Assignment 2
) A9 \7 H, c, a$ HPage 2 of 5
" q5 |/ w4 m* u0 s) |8 s$ J5 {b) Print out to the screen all the lines of code that are the same$ i7 b- n. @" H2 v
 Include the name of the file and the line number of the code being printed for each of the two files8 C# d4 g$ Z) ]& N0 [: }+ B; R3 \
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
( Y% }4 ^  O$ {  _! f+ z the name, username and department of the user
9 y2 T" `2 |  v6 }6 R& X the statistics of the comparison
  x- x& j* D: ?4 S/ ~: h- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
9 h3 |6 Y5 c" |& b$ i7 K the recommendation for further checking
  X$ s: p* g/ u) Q( P- 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 closely7 r% V8 g9 [5 T
 the names of the two files compared5 m8 Y3 ^. T" j  x7 g
d) Leave the program (exit)
- I1 E- n( T( \The ProgramCompare class: (Total maximum 20 marks available)
" ~/ f1 A% X; q/ X8 V3 w2. 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)& r2 v: i" M" _9 F6 z" ?$ h3 @/ q
a) provide an error message if the files are not found or there is a problem opening them& S+ z" R4 n/ [0 h# Z2 {+ U+ m
b) compare each line of code' a' k: O: I8 U
c) print out the lines that are the same2 q, T2 T, v2 C$ {2 f$ Q
d) count the number of lines compared / lines the same
1 n+ n/ }6 j; p5 `2 Z6 Q0 A  vThe AuthorisedUsers class: (Total maximum 20 marks available)' g3 ]- i( K& k
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)/ Q/ \" z" y: C" Y
4. Provide methods to:
8 F8 C" H1 Q3 c1 l" {" Ba) 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( ~" u: i4 P; C  {$ s3 H/ |( j8 `
b) return the name of the authorised user! b4 c" U( C  w' Z# C- n
c) return the name of the department of the authorised user  u! W' n- @9 A" W( W+ \
Individual Data (Maximum 20 marks available)& h& J- M& `; j1 K
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.
7 L, I- H- |. Z$ ZDocumentation (Maximum 10 marks available)' ]$ s0 X) T5 ^# v
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.
$ R( p  h+ T0 k( ~' `BSA104 Business Programming – 2007: Assignment 2
( s9 s/ h1 k" k1 R+ h( sPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了9 G! u4 L7 W  {1 ?- q
不过你要翻JAVA的类库说明。你有下载没有?1 u# t6 V+ ]4 E* z* j
查询关于对比的函数。貌似关键字是contrast,还有compare- w  x" j1 P- _% a3 E# K3 K
+ ?5 z8 Q9 m' Z# [: D: D+ Z
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
- @4 J. ]5 H5 I) `3 s* G痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
. b4 R4 P! h- x可以下载到的 是 jdk-1_X_0-doc6 A/ f6 y* \/ ^: a1 a" s2 X
; K$ {+ {& l. S6 D
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-25 07:40

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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