找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1536|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急; Q8 `9 i" \0 s: Z) G2 I ! w& P5 h+ M4 K/ f* H2 U m, E
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************$ T: P$ w" ]* i) ?( o! n
//  ProgramCompare.java         Provided by: DRS
. w+ y( V5 [5 S8 t1 C* I6 Y5 l//" X3 K; l& G( d( q! c* x
//  Program shell for Assignment 2
& ?0 }. H$ M  c. ~# |//
) [* F  x0 C; E/ P//  Compares two text files line by line
  L5 F- r0 q0 e. y# G3 y//*********************************************************************( O  }! n0 ]. Q3 Z$ j

$ G! l$ L9 g5 T- j& c4 Ximport java.io.*;3 ^( B! C- W  E) h) p/ Y. f
- \" `5 J, x; g! r3 i
public class ProgramCompare
/ p! c* g1 h$ \$ g{$ q) L% W/ f: N" [
        //-----------------------------------------------------------------; r; w: Q$ D8 d% |: y
        // Constructor
, ]: ~& Q; w9 i" u, O# a& B# g        //-----------------------------------------------------------------: V! Q' a8 M4 Y5 s( r7 g9 t" E
        public ProgramCompare(). y6 R* @/ _" F& a  g4 H
        {: d4 H0 h2 J" u, P8 W: m7 `9 p
        }
, p7 L3 z4 |) q9 p# M" Y  N) ?0 A
' a# L& z6 E, V( x0 U& E        //-----------------------------------------------------------------
& H3 K* S( C1 P1 n0 D        // Method for testing that class has been reached  Q5 @% p: e3 e
        //-----------------------------------------------------------------        5 L$ s% x0 L0 q  _8 ?( F
0 G6 Z0 e& z! e9 r6 {5 ]8 c
        public boolean ProgramCompareReached()        
; w6 |7 n0 b1 i, b" K$ J4 J        {
2 L( o- n. U5 K9 p( W      try
1 t; k( h" Z" n7 ^   {         + s$ Z# F. t! j, N  X
                        # q# o1 C/ j. B2 u7 O6 f
                //********************************************************************
; Z/ S9 b- Q0 t# o1 w/ w6 d3 p                // Try-Catch Statement is used to handle exceptions - such as file not found 8 v/ v+ r8 R& F2 A4 j0 T% q) F
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
! Z5 V) W  o" e6 N, S                // For more information see page 534 of the textbook
& b# z7 i2 B: m, V                //********************************************************************  b! F4 r( B7 {- l% f6 |+ m
                     * W* u3 I  ]! R) J) D+ a. v
        }  O5 x2 R2 j; `7 J" C; z
             catch (Exception ex) // Exception caught here and message displayed to the screen
% }! ^5 r+ M$ N& I# v. I7 N5 a7 R          {4 S) k) n" `. [& f/ B3 S  F. t
                    ex.printStackTrace (System.err);
; Z+ X! D% n5 @" C5 y           System.out.println ("Error message goes here"); // Replace this error message with your own          ' G/ B) ]- ^7 V1 c
        }
6 Z7 M5 L1 t$ h* R2 D6 u+ z                return true;7 _3 t( Y! s& i
        }8 q- [  `. w% J( d
4 a. J. Z* R2 Z% F- L
} // end of class ProgramCompare7 K6 }) t- P& \" x

4 \+ x/ B, U* l/ g# S//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
; f) B- F2 N5 q$ {' J9 m//  ProgramCompareMenu.java    Provided by: DRS! b- M% X; L$ j% j3 U
//" I8 R2 c5 D% H
//  Calls AuthorisedUsers.java and ProgramCompare.java2 L2 u% ?9 [# ]  g: ]
//3 o6 F" ~8 D3 U' |1 G. x9 ^
//  Driver shell for Assignment 2.
- v- i) W; W! o6 G7 U" C//********************************************************************3 T- d4 I' L* ^  N
8 c/ `1 Q% V  U' B* e
class ProgramCompareMenu
7 [8 ~! N5 V; Y/ _$ a{7 \  d. P# x% e2 `
    public static void main (String[] args)
2 S0 }+ w) m8 k4 o            {9 `0 ^+ U: n! H9 L
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable  l2 {* s1 C: I  O' `, E
                ProgramCompare reached1 = new ProgramCompare(); , B  h2 u6 m6 v
                AuthorisedUsers reached2 = new AuthorisedUsers();       
, {- A2 W0 U: z" K' P# U* K& Z                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());8 a1 A) |  L) X* C% G* {3 l* V! k
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
! e0 \" ]5 b, p4 t# Y3 H( y, p  o        }
. p- M2 d( r$ V5 p0 S}// end of class ProgramCompareMenu: F1 l3 b. @; o5 R* ^) ?
1 a, p* j0 B: i2 h$ s6 C1 \
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
: K7 A/ d) L9 Q! `//          AuthorisedUsers.java          Provided by: DRS
6 M7 l  C# w. r+ X" I. @2 S//                8 Z" }- A, ]# E0 n3 M
//         Program shell for Assignment 2
  W! F9 a9 P9 N. l- B//: n0 Q9 `. B9 p: T1 }2 }2 z
//         Represents facts about an AuthorisedUser
9 J9 o5 N7 E1 g8 [9 ]//********************************************************************
2 ?( x& o& o: {: d* |/ o8 |( {2 Q2 {& \, c/ H( f/ s2 @8 c" C
public class AuthorisedUsers0 a0 A) T1 ]- y5 x. y2 U
    {9 k. h5 _* T! B1 {6 s5 @
+ q# Z1 M" W5 c; h8 F  \
        //-----------------------------------------------------------------
- z7 N8 b; ^* H7 Q: |% O" Z6 u        // Constructor! S" Z% h3 y/ U  C$ K  c, A
        //-----------------------------------------------------------------$ d3 K* x2 I* \2 X1 U
) Q# [0 t/ D2 A! R6 n
        public AuthorisedUsers()) e1 X! R0 T- B5 ^" r! X! `+ k; n
                {
5 w" V: e0 P' q, M: A                }
. |! Z* d1 k+ W- c. d4 }, j1 T0 \+ l0 n7 q1 e1 F, \; P8 }
        //-----------------------------------------------------------------4 V+ b4 {3 w  h% Y( j% H+ u( Z
        // Method for testing that class has been reached- B, J1 c  A8 N1 e* D. z) x: x8 V
        //-----------------------------------------------------------------        ! w9 _/ ~$ n) B: a3 [* Z) u
        public boolean AuthorisedUsersReached(). _+ T: u; n9 s1 O6 g4 g6 g
                {" Q- p$ `( v$ J
                        return true;                       
# @$ _# E5 Q. I) A8 L$ Q2 k7 G6 Y                }
' x4 t1 ~  V5 \( i3 S                " x% c- M4 `4 N
    } // end of class AuthorisedUsers4 Q$ h% G1 }7 [- H
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming2 v. t$ }( o9 D* I  ^" }
Shanghai - 2007
2 B$ Z' z% h7 u0 @Assignment 2& ]; o0 z4 S2 I! {$ Q
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)
2 f, ~" U( P; b( o1. 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.+ M" M- E6 |* m' B
The staff must be able to:6 w; D( D1 U. C
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
' y/ O3 ?5 D- {- ~5 j4 \' `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.( R- \1 ~0 ^/ s2 O7 @/ \% F' e/ y: ]
 The interface should provide a menu so that the staff can:2 p" j* N) k' T* P* y8 V2 B
a) Enter the names of the two Java program files to be compared5 s/ g) F) d. Q! a% U7 o
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.. E- Y" x8 b6 q) W/ T9 ~9 f( C
** 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).' `% C9 g3 k0 b2 C$ H& ]- I
BSA104 Business Programming – 2007: Assignment 2
0 R/ J& J- b8 ~# o9 u" VPage 2 of 5; x0 R1 A; V( r9 X" t" {
b) Print out to the screen all the lines of code that are the same
3 X$ t4 |9 h4 a- l5 H: k Include the name of the file and the line number of the code being printed for each of the two files  ^( R6 q4 `' s! P+ n
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared% O. ^3 C; a! k. W
 the name, username and department of the user
) `. Q+ P  `# L' x) z# f; V the statistics of the comparison
1 \8 G+ x! L3 x5 p! B3 D- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different) B: z; }2 x( q( j( ~
 the recommendation for further checking
" B9 @: N# {( {0 [+ l* ^  Q* p% K- 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
' ~: k; \" M3 I/ ?" U1 O- o' m7 { the names of the two files compared/ I* E# Q! X, r, ]
d) Leave the program (exit)
# X* f; X$ s# |The ProgramCompare class: (Total maximum 20 marks available); ?2 i* w/ x$ Y1 g, u0 g4 X
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)4 u7 O/ v7 g4 l2 [0 i% E/ S, `, B( H
a) provide an error message if the files are not found or there is a problem opening them5 Q6 w2 s3 ?; d/ p- D
b) compare each line of code$ i6 D: x- b, e8 T/ b# n6 a8 N/ G
c) print out the lines that are the same! o( L+ ~* W- N3 _  w
d) count the number of lines compared / lines the same& _2 T% Y! Q% r4 m
The AuthorisedUsers class: (Total maximum 20 marks available)5 n& }: S( X0 ?4 k/ I) s* g; M
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)
8 P2 u  K) ]% `& h2 o4. Provide methods to:
" x1 X! N6 n( o  a# x, Z8 Va) 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
( f3 r3 G* j2 Z# B" U/ qb) return the name of the authorised user6 ]& X3 I( r- m7 t' ~" b
c) return the name of the department of the authorised user9 C" s4 C1 a! a% z2 I) l
Individual Data (Maximum 20 marks available)
8 }$ y/ |& b: r: u3 h  f; B5. 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.
% r+ i; D6 }+ e% WDocumentation (Maximum 10 marks available)" T) b) R7 F2 S& A+ g1 s
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; y3 m/ }  G8 nBSA104 Business Programming – 2007: Assignment 2
0 n! g& e9 |/ j" rPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
* Q' X* v: C9 y* K5 @: v+ T不过你要翻JAVA的类库说明。你有下载没有?
) A. ~+ ^9 Z0 [% @7 |查询关于对比的函数。貌似关键字是contrast,还有compare
) V$ o$ ]: F7 n: H
3 V6 Y% S3 R1 \1 h" \4 `[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -/ T2 x, ~; @( \5 L7 j8 O* ?
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。9 b/ n& b1 J  }& J# k% Y8 R
可以下载到的 是 jdk-1_X_0-doc' X4 r) t- h7 c; d

# i2 n/ Y( w$ [6 z7 _! K- U[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-11 21:45

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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