找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1542|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急! B9 `% t+ x9 Z, u7 @# J9 V . g0 S* o. {+ ? Q! 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 | 显示全部楼层
//*********************************************************************# U2 \2 I& W1 F- g
//  ProgramCompare.java         Provided by: DRS
5 |8 d  z# p% b( w/ F//& S% {, M1 Z; U* q* X0 n' b
//  Program shell for Assignment 2
$ S5 W3 h+ ~8 t" n5 R/// ~0 @3 a% [$ k3 a0 [
//  Compares two text files line by line  _! Z# g# t# `8 B+ g
//*********************************************************************
( ?  M( w& `6 G& t# D8 W+ R: z: J& I. d: F
import java.io.*;
9 P' X; y! O/ m1 L& i, j, o, ^& v$ l7 r; g3 E
public class ProgramCompare( H4 K1 M2 j) N4 O
{; \: o3 ?7 G1 A4 O* v
        //-----------------------------------------------------------------
+ |$ Z: {% {( p        // Constructor+ e% ?( {) X. z0 j- H2 s8 Y! ]
        //-----------------------------------------------------------------8 c" C2 u% ^, }- D( R) u3 c
        public ProgramCompare()4 h0 D/ b  ~% e* k: M7 e4 b
        {  G: c, A6 ^2 g* _+ V2 e. \, b" E) u) [
        }9 R1 p5 x6 b6 F* C' A' a: J
. z) t/ X9 n& Z" a4 C9 G/ T
        //-----------------------------------------------------------------: ^; K6 j/ f7 }% F$ l. ^* K
        // Method for testing that class has been reached+ N* r. ^0 L3 A/ O9 _- V
        //-----------------------------------------------------------------        ) T7 y4 ]( W1 m
5 D2 z1 ?5 j* T! s3 s
        public boolean ProgramCompareReached()        
( }+ p0 n5 b! e- z( p" N: g        {/ ?# M5 T: C4 n6 G
      try
6 F/ C. h( Z/ q* g  w, F- b3 V   {         + b; _0 \8 b& s5 n
                        8 i: k/ r$ {+ x# w! C" l" C0 J
                //********************************************************************
1 u6 i" B" a# f" `                // Try-Catch Statement is used to handle exceptions - such as file not found " z" e& W/ c& }2 v- t
                // Reading the files will need to be placed inside a Try-Catch - just like this one!0 k& h/ \5 u) ^2 p9 i2 {3 N" t, [
                // For more information see page 534 of the textbook
4 _( S' S/ C( ^$ ]$ P( _                //********************************************************************
9 ~  o# Q2 @* H                    
1 d$ m7 v4 B. A6 K8 [1 @! \        }
, J! G( R9 n7 l* I             catch (Exception ex) // Exception caught here and message displayed to the screen
: {, H+ |; y7 o' Z          {
7 C4 l. W* P1 k+ f                    ex.printStackTrace (System.err);
8 Q8 a0 `: f. {9 E6 r           System.out.println ("Error message goes here"); // Replace this error message with your own         
, e& a8 p+ q) J; x        }6 A, B, ]: n0 y! s* t4 t$ T
                return true;
5 d- U+ j% r# }: @        }; l! Z+ s5 y) Y% f* N, ^% F2 w7 v

6 c9 n8 G" |$ G} // end of class ProgramCompare
% B' O3 h8 U, t- ~
/ @3 Y& H% n5 a9 f0 I8 `& H* r//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
1 S' E9 e2 \8 V% a1 N+ I//  ProgramCompareMenu.java    Provided by: DRS
( O+ h0 l2 v& m; a7 s  X7 G+ _//
) v4 v5 `" D* P# s9 V/ {//  Calls AuthorisedUsers.java and ProgramCompare.java' n! E6 [+ c9 P$ U. a/ ]% }
//
. n; _4 r: |" X/ {//  Driver shell for Assignment 2." W/ F5 H' o2 r* j! I: i
//********************************************************************
$ d; a) A2 Q6 L5 a7 ?2 |
# [6 c* P/ y2 jclass ProgramCompareMenu; S- X. \5 P" z2 j  l) p
{
7 f. E* ]. v1 O& p% H    public static void main (String[] args)
3 Q- p. s* [) ]5 n  z1 {) r1 S2 `            {
1 b$ D) O8 v  C                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
; X2 c8 Q5 Q4 l# r                ProgramCompare reached1 = new ProgramCompare();
' o6 F5 g! B9 e6 O- X! w                AuthorisedUsers reached2 = new AuthorisedUsers();        8 P) U: [- r& J' D3 a
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());: Z' i8 J4 Z6 z$ }
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());          _& l$ K8 o" n9 e$ s  o
        }4 L: [" }8 S% Z8 z0 H
}// end of class ProgramCompareMenu; o8 ~& U" y( R; [% h5 z
7 `/ [( N$ f6 ]2 i
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************- }  ?; M7 \( n" i' _
//          AuthorisedUsers.java          Provided by: DRS$ h: @9 ?1 C8 a. U! H* i( S  P
//               
9 \% G: |' A7 Y3 \//         Program shell for Assignment 2
$ j+ a! `% E0 C0 W7 K) O2 [8 K! \//$ }' u! G* L) i0 l/ T% |" p5 z
//         Represents facts about an AuthorisedUser
6 ~" `' J* L1 l0 c6 U9 r- O: H//********************************************************************3 u  I$ {  C9 K6 f
2 P8 n2 @: u  g; K' F8 L! }4 h4 v
public class AuthorisedUsers
4 W# g, m6 h3 X$ I/ A( Q    {
/ X1 V! L+ Y1 t2 F3 u
! `/ a  e% c+ a( H& ~  a( c1 M2 y        //-----------------------------------------------------------------, x2 N# A5 |5 d' O: y
        // Constructor) V. s- S/ ~! }: y: y, P/ V
        //-----------------------------------------------------------------  K- U# g) a9 N/ y

! O6 U% z+ b6 c3 A        public AuthorisedUsers()  Q' q3 T; D& G2 j' I4 ?
                {' t  A& k. n+ x' q- L% n
                }* V5 `; U5 h& b1 Z: f2 X5 G, s
& g/ J7 N. o; `$ r
        //-----------------------------------------------------------------1 ?8 u1 c9 L6 ?9 G1 c  z
        // Method for testing that class has been reached. ]8 W3 d- T/ ]8 g: p# L
        //-----------------------------------------------------------------       
3 y1 b; Z) g& W" \3 ~. b) ^2 W        public boolean AuthorisedUsersReached(), r. ^7 A) ]% F
                {+ l, `6 o* C' `2 v( \
                        return true;                       
' _1 J7 E8 F% r! Z- S                }9 j& R2 Q, y# c
                4 W2 A. q8 U$ U& J+ s& o
    } // end of class AuthorisedUsers
! m; V4 E! X: g6 R//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming0 K0 w- j2 ?3 [8 H; I" n& H: G
Shanghai - 2007
" L0 F( ?$ E2 i$ I# L: C$ gAssignment 2
0 x' Q$ x0 M& b+ @7 UDeadline 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 x, Z. w' J& G5 ^
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.
, t$ F% h8 i" N. J  MThe staff must be able to:, {1 Y6 j3 W. D' N. p% }
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
1 [% J2 Z  ]0 \' a1. 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.1 J" [" Z% ~% m* V
 The interface should provide a menu so that the staff can:/ \% r! ]" T( k: t4 |* ~
a) Enter the names of the two Java program files to be compared
: P1 L, P  m  I- L( _8 z% P For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
& }+ u  {9 u8 j3 Z8 y** 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).) C$ w) k3 a) D. s; |$ A
BSA104 Business Programming – 2007: Assignment 26 V3 }" t* k( N$ H& `- F* d, Q9 ~
Page 2 of 50 A3 q$ f8 `9 ~
b) Print out to the screen all the lines of code that are the same
: k3 @6 M( A& X Include the name of the file and the line number of the code being printed for each of the two files4 ?5 Q! z5 G; Z4 b0 R- x- |
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared; E% \% R8 {3 I% E+ G; a
 the name, username and department of the user8 Z) m7 ?, c' T
 the statistics of the comparison; j  Q; R# n* r. q6 N* Q# r) b% ~4 |
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
* S0 P% F7 V+ i! K% l the recommendation for further checking4 U. n. y: M2 A8 }& y; A3 y
- 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& B8 i; X2 j# q' @& _! D3 \
 the names of the two files compared
: c4 [# k$ a- n; w$ k3 ?$ H6 n8 \d) Leave the program (exit)0 @/ J. X/ K3 F  E
The ProgramCompare class: (Total maximum 20 marks available)* H6 v( H: l8 O7 T( ~
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)
* M; I7 n, _+ {a) provide an error message if the files are not found or there is a problem opening them9 s; ?5 x" p2 r+ b2 X/ q
b) compare each line of code4 H" x" K. O4 ~/ v+ G
c) print out the lines that are the same
$ ]0 u  X: f( G. a/ q2 i6 C6 |" ~d) count the number of lines compared / lines the same
/ J, A9 b$ S$ w" X* b& YThe AuthorisedUsers class: (Total maximum 20 marks available)) S5 t/ d$ D& b3 Q6 ^7 h$ C
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)
/ Z/ @/ N( Q, B- y3 L% |4. Provide methods to:3 T# O& O6 \+ f9 B! `. ~7 X; y, K
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$ R. `# q% p- p; X
b) return the name of the authorised user4 G  C' O% |! F: L2 L; S' n
c) return the name of the department of the authorised user
2 M( x) n- D4 C2 R- o! ~Individual Data (Maximum 20 marks available)" K6 H3 Z2 q; F' Q
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.' c& x! [! }2 i4 M# c
Documentation (Maximum 10 marks available)& o. b2 C* m" Z! X/ `
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.- N  Y' K" A, e8 M) B$ p8 u$ v$ Y3 ]
BSA104 Business Programming – 2007: Assignment 2
4 z. |, r+ |2 g) xPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
5 v# {4 ]6 Q, S. U4 l不过你要翻JAVA的类库说明。你有下载没有?
% r* W( a3 K* n; P& e查询关于对比的函数。貌似关键字是contrast,还有compare
8 W" a5 c5 ?9 c9 A3 S2 z9 [( z/ w" V( {  T- Z
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
2 B3 j* a( H" r( f3 d. A% e  T; {痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。  \* p; D# G( ?9 Z) p; e
可以下载到的 是 jdk-1_X_0-doc
7 x$ N: {- c) b1 g4 H# f- p& F0 o8 D) ?5 k" t, d5 B
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-15 02:27

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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