找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1194|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 K' T7 c4 G. G/ C1 G 0 p. K) n, f! w! x; {* S
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
6 c9 S6 K% b  T7 z4 w9 h//  ProgramCompare.java         Provided by: DRS
8 m( V  g- f8 M' B; P0 g//
6 `9 J$ h, X! ]5 o" q& R//  Program shell for Assignment 2: H5 H  d  l9 ^4 S8 t1 M4 x
//) f9 P6 v: d& |4 k; Z5 d0 b% Z  `
//  Compares two text files line by line: g* w* l' V( Z' W! d
//*********************************************************************
% w8 R- O8 ~1 n3 T+ r" Y/ ]" E7 m4 \% d
import java.io.*;
" Q( _" G8 N3 W9 c4 s* Q- ]8 l, \& r! t% ~0 F& O1 j
public class ProgramCompare
4 Y3 Y. ^# ~! Q1 X" Z{  a& G4 c! H- E5 g/ v9 R5 u1 A
        //-----------------------------------------------------------------
6 X$ k* ^7 q4 ?, N  q0 W9 [, v% V        // Constructor7 W' o8 `# c) e/ x# n* g7 s
        //-----------------------------------------------------------------
5 m1 }0 {4 C3 ?- s5 c        public ProgramCompare()
" \  R9 P/ R: C" m! V4 v        {
) h: K# Z" i: D3 h$ V- g        }3 l0 L& E$ }% N
0 g+ I. [7 N( V) p1 e
        //-----------------------------------------------------------------
" \" B' n; h* M        // Method for testing that class has been reached
; }9 I* B3 o1 ^9 t' w/ [        //-----------------------------------------------------------------       
1 i  N1 k9 \' W: y2 \8 z5 U; a
( y. \9 Y. r: s: i( w' G; O        public boolean ProgramCompareReached()         / n* h1 I( X. d4 Y
        {7 O" J2 A# N  t' I# ?
      try 5 k8 v! a. \) E; k$ g8 [! U% h8 `+ X
   {         4 m9 T  L: X; |" @. b
                       
" m; c+ L9 c1 d) i8 }" b                //********************************************************************# P/ j7 w+ e! E; x5 _, ]! z
                // Try-Catch Statement is used to handle exceptions - such as file not found
- L, q% {0 _6 [! |# E; _/ n1 x0 [) @                // Reading the files will need to be placed inside a Try-Catch - just like this one!) ^6 b9 W& c* h4 C, y, B
                // For more information see page 534 of the textbook) K  S  g; I5 q/ A4 b
                //********************************************************************" `. |. o. E, W# R1 j3 S
                    
) \7 |1 R8 o1 R/ [( G        }
/ T, x- l. x" E  V7 P             catch (Exception ex) // Exception caught here and message displayed to the screen
# K) Q* N( Y9 ~          {1 }5 U. h6 _  k8 {
                    ex.printStackTrace (System.err);5 j/ b! ]- h9 [; a
           System.out.println ("Error message goes here"); // Replace this error message with your own          ; G2 V) o+ ]  ?/ m
        }
3 |0 O' S6 G: B& u; q# X  w                return true;
8 K9 R* E5 D& H* L" Z        }! n9 i* @4 D( X. i  z2 {

7 q' X" G; `9 Z/ i} // end of class ProgramCompare
7 g: u7 I; s8 u* N+ {. z1 R& R
: A( G/ m4 D- Z# J//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
9 B7 c: Q8 Z$ s//  ProgramCompareMenu.java    Provided by: DRS& M3 m8 x* Q0 F# l0 Y: ?0 p
//3 c, q  l* C1 W% ]9 y9 v
//  Calls AuthorisedUsers.java and ProgramCompare.java# T- v" O0 X; c) f
//
& W1 F/ v& c! p& U/ W* i//  Driver shell for Assignment 2.- m) d- T5 E( d
//********************************************************************
- D, \% l2 T% U" U  \9 h2 j: f% \+ ?2 R! t) r* w
class ProgramCompareMenu0 \$ q6 |. q) l9 \6 }. e
{; X& h& j" N; p& a
    public static void main (String[] args)' g5 W5 e0 o: z3 p; a; |; W! m
            {
5 |* ?/ [6 a2 w" @! E7 ]                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable9 M& N* v* K! v+ P) L
                ProgramCompare reached1 = new ProgramCompare();
9 c1 F' S/ X0 q                AuthorisedUsers reached2 = new AuthorisedUsers();       
# d" n, b( z7 H/ ?4 I# Z# m$ x0 g+ V# L                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());+ E; v. N* r" ~1 @) ?& G
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ) k+ f" |- Q1 Z$ Q2 u
        }
$ G  K+ q; [$ r0 w  c- U$ ]}// end of class ProgramCompareMenu$ ~4 M. m! G5 \+ `4 @

4 S3 w& R3 I: f& Y5 c2 {  e, Q1 P- r//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
3 \& Z4 o$ Q4 R# C//          AuthorisedUsers.java          Provided by: DRS$ W3 L& L) o' p; @5 @; `
//                9 f' M$ U: d6 D5 U1 T
//         Program shell for Assignment 26 g6 H6 _) R  q  n) }
//, h  A; w: a" Q8 m
//         Represents facts about an AuthorisedUser
# V! t* w( F. w/ r2 b* B//********************************************************************5 k" G: h0 |% m2 V* C
# x0 T. E7 Z/ w, U3 l' X7 {) I
public class AuthorisedUsers3 ~9 i, M! {  A  p' {+ D; L
    {
4 A& u, b, I. m" W9 m, Y' I$ A$ Z! Q
        //-----------------------------------------------------------------
7 D5 w+ [! h. E' u& @, w. D) \        // Constructor0 F4 a  {- i1 R2 Z
        //-----------------------------------------------------------------
# K7 D3 \" x! T& b3 v9 @, f! Y% h* {
        public AuthorisedUsers()
1 p1 w9 D; |/ g( Z& f                {6 B) B6 ^. |& s% {# d8 M
                }
# E  u+ @3 _. C. ~, Z; K' Y; b. E3 P
1 P) q1 Q( t/ v) ]( c6 ^% J        //-----------------------------------------------------------------
0 r/ f) S' L- E        // Method for testing that class has been reached
  h3 i) n; M3 Z  d; R        //-----------------------------------------------------------------        % L% ?# y/ K8 T6 I9 p
        public boolean AuthorisedUsersReached()6 o5 I* Y$ y% x+ Y
                {
0 n2 {! U+ W! j                        return true;                       
% v: U" `- H! a$ z9 d                }
/ m7 @4 K: K( F  Q4 g: N                0 H% ?$ _2 S! L& M7 n+ P
    } // end of class AuthorisedUsers
9 @! s4 W/ T3 i//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming% u- r6 Z) e6 D& M' A
Shanghai - 2007
& d6 m+ t2 a2 X; c' `; FAssignment 2
/ E- J1 W1 q. y8 ZDeadline 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)9 M% \5 q* S* d2 @
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." {' o7 |/ d* i0 ]! M
The staff must be able to:6 o# r% y# ^1 P( e  d
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
" u9 j, v8 t0 }+ R' D1. 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 u: j1 Y2 {/ m. n5 g5 a5 X The interface should provide a menu so that the staff can:
: b' q: u: F# q+ Ha) Enter the names of the two Java program files to be compared; w- v. M# V+ ]4 F. c" E! D
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
2 n) k7 w% T& Z+ C& R; L** 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).
/ ~/ j2 B$ X9 @# c$ {5 fBSA104 Business Programming – 2007: Assignment 2
3 V; \& e/ ~6 y' H& }0 _" }Page 2 of 5% V( \7 H* D& w0 }( N/ }7 p9 ?6 Q
b) Print out to the screen all the lines of code that are the same3 d! Y1 L. o0 G$ ^8 b  E0 o& G
 Include the name of the file and the line number of the code being printed for each of the two files
* ~, t4 Y" ]3 tc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
: O1 W" C1 [# M, c/ @ the name, username and department of the user% H. G7 Q/ @/ i0 `2 C
 the statistics of the comparison, `4 u5 ], I+ r4 \8 ]& U9 d' b/ ^) c0 ?
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
- z: N2 A' F( E! H- r the recommendation for further checking
. h1 ?8 q" u$ f( e% e) f, 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  \  M3 G! U/ q. m' K% f/ l" e9 A! i
 the names of the two files compared& q' X; T% t5 a
d) Leave the program (exit)" s* ^, r0 g- r. A
The ProgramCompare class: (Total maximum 20 marks available)( a- J" l& K7 m, q( f+ l
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 ~! M3 H2 l7 ~  da) provide an error message if the files are not found or there is a problem opening them/ N) ], {* B* O% U$ H6 a
b) compare each line of code" F- r0 D' v9 W9 l+ ]
c) print out the lines that are the same0 A0 u0 Z+ H8 u1 w. H8 a
d) count the number of lines compared / lines the same
  G5 _- W8 M# |1 }" [The AuthorisedUsers class: (Total maximum 20 marks available)4 Q6 b$ V) V* B; ]. }( a; T7 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)
5 I5 p8 m* S3 G  d# B4. Provide methods to:7 \& l0 J/ e4 u; K. X
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. c! [9 ^# ?- n: X6 {# [
b) return the name of the authorised user
, o7 k- k0 G9 n7 l( O7 xc) return the name of the department of the authorised user
7 V* Q; _+ y7 |" `Individual Data (Maximum 20 marks available)
9 E# s" w* m9 _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.
, O1 q* y  M; r) {Documentation (Maximum 10 marks available)! l% W7 g3 M" r9 D. t
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.
) Z2 a8 T. R0 s" }BSA104 Business Programming – 2007: Assignment 2. `5 W8 j% j7 j, Y$ w( J
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了) s4 r  i+ e2 R2 V8 U" P: G
不过你要翻JAVA的类库说明。你有下载没有?
4 R2 e& G: l: m4 W查询关于对比的函数。貌似关键字是contrast,还有compare
0 x2 O# Z4 W& N6 J: W' W* v0 X; q1 a  C$ C  x* {
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -: N, k$ |( F, h5 E
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
' |* @' |9 t* i  x, I可以下载到的 是 jdk-1_X_0-doc" U: |( p! ]  a' d

! E) _+ L$ X0 m[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-13 17:50

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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