找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1876|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急. y: S @1 a" ~7 t0 o0 x# { 6 j6 _- @+ p0 [( R0 Q
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************4 g" f3 h' h7 [6 {
//  ProgramCompare.java         Provided by: DRS
; m, V4 K$ Z3 @0 N" H8 V//0 A* k' t# f) N. ^0 c2 o  l, j
//  Program shell for Assignment 2
9 S1 b3 H4 u5 z8 }$ H/// i  {1 _( ]& s2 q/ S" x1 {
//  Compares two text files line by line
& a4 a  b6 H! _$ j% h  ]//*********************************************************************
8 r7 J7 H+ @, |# M! x
0 t6 J( a/ k' w' Oimport java.io.*;
0 e* j. S2 n5 O1 M  \6 n3 y; z9 t! u, @" i! g; e# X
public class ProgramCompare3 E# n8 h( g! `, M5 _7 m2 z  f' g% q- ^
{
" N7 W: u, Y& l/ ?        //-----------------------------------------------------------------0 r3 Q# Y& A8 B8 \2 l0 \& t6 n
        // Constructor! t+ f2 X) n: O9 K/ B- U' E
        //-----------------------------------------------------------------8 C1 Q, y" ?3 E: R! Z) X8 D
        public ProgramCompare()
% C0 c7 I7 A% k1 m2 L; l) p        {
1 c! q# w/ n1 }- C. z. h# t7 x        }
) [% T& J; h/ _, ?: }  T" l0 G
6 z& |, }" l4 I* _! g# }  v8 |" K        //-----------------------------------------------------------------% }* D8 P& N, L# }9 t" l6 l+ O
        // Method for testing that class has been reached! T. \: G( @% O$ p, D- p7 |
        //-----------------------------------------------------------------          r- c! V3 C  ]7 Q% j% i
" L$ d' e& j  d) y; J3 _
        public boolean ProgramCompareReached()        
% Z4 c. }& W( }/ d        {
0 `( A/ d& k# B3 B1 Y4 ?      try * J- T$ U; ^0 L
   {        
+ R' n3 F. r7 p. C7 c4 T                        : P# h7 }1 @  ?0 S: g! h
                //********************************************************************' W2 F6 x9 o! B! q# S4 ?# L
                // Try-Catch Statement is used to handle exceptions - such as file not found
: J8 k8 b" j7 y% p: j% E  ~- h4 S                // Reading the files will need to be placed inside a Try-Catch - just like this one!
- u: }; [8 |- G4 C' s! T# H- [                // For more information see page 534 of the textbook: |' z; {7 D+ v- q/ E
                //********************************************************************
; G& I7 w9 a3 m$ E                     2 L7 A7 u' A* k, Q0 m
        }6 h  ~0 l. S' R
             catch (Exception ex) // Exception caught here and message displayed to the screen 0 C" H/ Y0 h- Q/ L
          {
2 h" d2 z' F" W$ Z7 l2 N% Z                    ex.printStackTrace (System.err);
  f6 \3 }0 |3 \8 y           System.out.println ("Error message goes here"); // Replace this error message with your own          8 C5 U, o+ x) u! ?+ g/ T
        }
4 L9 D& c) I5 {- V# G1 V3 N                return true;
, P$ M' }( F$ G! |2 _' S        }; G& i& z8 V8 c5 g. J  X
3 R; S1 ?, F9 U9 Q# ^( ?; T; G7 w/ F
} // end of class ProgramCompare
6 J' ?4 Y" @9 [' a5 G9 G) S
% M" _( t0 u! k8 X//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************* ], x+ Y3 i8 p% J
//  ProgramCompareMenu.java    Provided by: DRS
6 N  P/ z1 Y: W//
7 M0 i2 r3 p9 |% m; o( R//  Calls AuthorisedUsers.java and ProgramCompare.java
* d8 S: h! y' }/ P5 c3 ]; ?" l//( I( e( j& l+ v( n5 g
//  Driver shell for Assignment 2.) |2 B0 g) [8 m4 z' n
//********************************************************************. X/ q# i+ T0 ^

+ V* G# s* Y* {2 c$ N! C$ z: F* hclass ProgramCompareMenu
- H4 [& ], }' `{8 |0 i1 B9 C% t  a7 d' P
    public static void main (String[] args)* Y# t1 n# i8 Z7 p, h* h- C
            {: C) U( v$ a* m+ v" c6 L: e: K- ]
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
! W. o3 r3 S6 v) C, Y; K( s' y                ProgramCompare reached1 = new ProgramCompare(); . w, `# L0 n7 ~+ H/ e! J* N' z
                AuthorisedUsers reached2 = new AuthorisedUsers();       
! G* ?/ l+ Q& h6 A6 n: l# q                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());5 j+ k- r4 C9 S' M9 ?* [
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
# R& e2 b* q+ e% g0 P+ G4 K$ t0 u3 Z        }+ `9 l4 p! D' I* Z
}// end of class ProgramCompareMenu
7 m) o: u: C* U) H9 k
# H( A; R0 q5 Z; M+ z: Y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
: G) u! i: Z& i//          AuthorisedUsers.java          Provided by: DRS2 p% `0 J% K' D- J, _' \+ w
//                2 [% _3 a4 ?$ X# [
//         Program shell for Assignment 29 t3 P7 K: c, T( J5 Y" B1 |7 O
//
6 K2 G' I% H" m//         Represents facts about an AuthorisedUser& n) \  a0 P* f4 a1 q1 [3 ~
//********************************************************************/ k& t& y4 y" M: P2 K: t% A# ]
, w8 j3 H, Z+ i+ T4 V
public class AuthorisedUsers
% u% c7 `; [( y8 a. t  i- }    {8 {& j# ^: D) q- y  W' h# J
5 _; g) \3 I1 @% ]% N
        //-----------------------------------------------------------------
9 M/ S9 e! `8 j. v. p        // Constructor
- e" U5 e" `, s        //-----------------------------------------------------------------1 y7 C$ w3 ^9 x) q4 Z
% j1 g: j/ p: ^/ L8 |
        public AuthorisedUsers()
! o5 ^1 i+ _4 P9 P                {: m4 n2 A% p: k, r$ o3 K
                }5 U  i  g% `. _8 P$ B  {' g
8 D3 _4 A- w' d1 M# K
        //-----------------------------------------------------------------
' r( T; W! k7 h8 N) p        // Method for testing that class has been reached
0 m/ R1 x; g% k* K" c  A        //-----------------------------------------------------------------       
0 s7 @2 d/ q! \& e3 |# H  |        public boolean AuthorisedUsersReached()0 K1 |8 g" g( d$ E* D% Z" ?4 I
                {
8 G8 }! O# q4 B* u2 L                        return true;                        9 m* N3 u) F0 p1 W& X7 k
                }
5 L! K  v+ y# c% f               
3 T1 M) n& N1 m+ H" b    } // end of class AuthorisedUsers7 v- V  ?# u9 @( k- u
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
6 y: G2 A% K+ H! D1 ?5 u, jShanghai - 2007% J8 D( ^1 P% @9 r1 x
Assignment 2
* {' Z8 k, J" W- a7 J! r7 |8 bDeadline 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)
: O6 i+ l/ ?3 k9 c1. 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.* e' \3 W( i/ I- g8 s
The staff must be able to:
+ H4 L3 m* Q- }! e( d Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.$ Q+ c. C, U& A, f2 c. i$ u
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.& g5 p; x) v3 O* c& K7 J' W
 The interface should provide a menu so that the staff can:
% n2 \& K) p; O4 v% Ya) Enter the names of the two Java program files to be compared6 p, A" r1 B+ T% M" G
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
- P7 r5 s8 l8 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).
( I. S& n: |* S1 P8 u4 oBSA104 Business Programming – 2007: Assignment 2
4 R: X# c/ E" ?7 J# R9 H) NPage 2 of 5
# i6 J4 Z* O: k# B$ jb) Print out to the screen all the lines of code that are the same% O( d, l( `% d5 U
 Include the name of the file and the line number of the code being printed for each of the two files
2 e2 Q* X; m) }c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
4 L  Z- f& \/ V4 n4 Z the name, username and department of the user4 `* [8 P" s& j
 the statistics of the comparison0 \3 c* a* E6 q& R$ M# c, ?
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
" z/ K; ~/ d% K% D9 \: B9 ^ the recommendation for further checking
# D3 ^% z9 f' i# Z2 a" B  e- l- 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 closely2 y  _8 f( F5 e: ^( E% }' d1 r# }
 the names of the two files compared
. T5 N$ J6 r0 \d) Leave the program (exit): ]$ L& V8 ?7 A. o9 w8 {" P! S0 J
The ProgramCompare class: (Total maximum 20 marks available)7 O, \9 d# d( n- s9 W/ K5 o$ l9 {
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)
0 k( u  {! p% K5 fa) provide an error message if the files are not found or there is a problem opening them/ L4 [1 U) g$ a* Q& n
b) compare each line of code* F' K" ~/ i! }9 W% t
c) print out the lines that are the same; }2 l1 i( @6 J& n' n
d) count the number of lines compared / lines the same
0 ]; i- I; C) ], |$ @/ qThe AuthorisedUsers class: (Total maximum 20 marks available)
, e* m5 B& X9 x$ 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)3 r4 U% q4 C: J( M6 c$ t4 ^9 M! e
4. Provide methods to:
4 r& e# p' X) V" T1 b1 m; X/ }0 Ea) 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
( n1 S6 o# E7 c4 O' ^4 |! kb) return the name of the authorised user0 i8 u! A& x, A2 ~5 Z3 }8 o
c) return the name of the department of the authorised user& q# x" b+ `  f) x4 L. t0 n" T
Individual Data (Maximum 20 marks available)% x+ x6 M" n8 L* B1 d0 I
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.3 S6 A" ?  D. ^& m+ P$ K2 D
Documentation (Maximum 10 marks available)$ S( @+ j/ \  V; z" ^
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.
, X  K6 B1 k& L) d1 [" e% r* D4 bBSA104 Business Programming – 2007: Assignment 2( P4 Z+ n$ e4 \1 w# w/ E4 O; r
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
7 {! |+ l  f4 A) x# p$ ]不过你要翻JAVA的类库说明。你有下载没有?
/ n7 f: l2 C: ?  ?6 m查询关于对比的函数。貌似关键字是contrast,还有compare9 I6 r2 u) Q; ~' p& s9 J  f0 K

" ?' s" U) a1 T8 g! a[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
4 S4 S) X, w' D$ O  g痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
7 F" m2 \9 s- ~0 ]可以下载到的 是 jdk-1_X_0-doc9 A- T) ]# n3 E1 f
/ c8 ~; I& A. F7 W& w
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-12-6 00:24

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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