找回密码
 注册

QQ登录

只需一步,快速开始

查看: 948|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 * F, e2 ^* Y0 q3 i# f% p 2 y X2 x1 X# i
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
% Q' ~/ e) Y4 ]  _- ]* z//  ProgramCompare.java         Provided by: DRS
" P, Z' L8 p- v; j& `. K* \4 Y4 I//
9 t$ t+ N. |& Q4 C$ j( w! M4 u//  Program shell for Assignment 25 O' s: p1 A6 ~6 _! w; ?
//
/ Q( X, J# F3 l5 p9 o  m: O, k//  Compares two text files line by line
( l' u# k4 X2 P& K( s, j+ D( X//*********************************************************************, v( f5 Z' L; ~1 O) e
2 h( n: G; x, L5 e$ y
import java.io.*;
: T4 ~  i$ d" K) T6 z- _8 t& E6 ~# h+ q6 x2 U+ p
public class ProgramCompare3 E2 i! d( @" c# f
{
, k2 B3 m. f# [7 A, K; r        //-----------------------------------------------------------------
& @8 W( W- C8 k8 b8 j2 K, i( i  Q        // Constructor6 f0 V( K1 {. @- z* [+ X
        //-----------------------------------------------------------------6 ]; u( b" ~  G- H* C' K) j- `
        public ProgramCompare()8 L+ R. @  w' S. y: T
        {
0 {' h) j/ r; j( L$ n5 a        }
  n3 F/ x; Y' i, K" ]: O0 s: Y& H# V& C# e4 ^- |/ z: q5 g* A# I
        //-----------------------------------------------------------------) l: K4 I6 t# {. T' A2 A
        // Method for testing that class has been reached
. r  C+ D, f& ~! d; n9 c: c+ {        //-----------------------------------------------------------------          v1 N7 j" Z5 p& _: X) W
* f7 W. L  r, }& K
        public boolean ProgramCompareReached()        
; ^% E2 E: n. c8 Q! u3 a3 v! [        {, r! f4 _9 {! @% N+ H# X& Z
      try
5 T' O! J6 k# s3 e  v   {         ' q% d* G5 i8 L0 G. |# f3 j, w
                        . y$ `5 @# G0 S7 w1 `
                //********************************************************************2 v& H* B: |- W' C! p# _
                // Try-Catch Statement is used to handle exceptions - such as file not found * I" U* l& N9 Q1 F8 l8 t. l
                // Reading the files will need to be placed inside a Try-Catch - just like this one!& K7 d$ W1 f4 }5 F; d) ]
                // For more information see page 534 of the textbook9 m! Q* E. H9 ]4 n7 r$ J, K
                //********************************************************************  W( s; `8 e6 D7 ?4 p! J+ @
                    
: A2 g9 C. t+ C' x) T! i! h& O        }  B1 w: n- Z2 v
             catch (Exception ex) // Exception caught here and message displayed to the screen
9 Q% O. ?6 i- j) c          {: i6 y6 S& o% l) H4 P; B
                    ex.printStackTrace (System.err);5 K; e: w% p7 r( m; \' ~
           System.out.println ("Error message goes here"); // Replace this error message with your own         
; _' M3 X6 x& ^# I        }
% B5 f- F! v7 P6 B" r' R- U                return true;7 {! ~7 T$ B$ h6 ^. p  U0 h# Z
        }
2 t+ x. r  Q2 P$ o* p2 V- H7 ?& }( ?9 h) h- Y6 m: L
} // end of class ProgramCompare: S+ {( K2 Z. e- g$ a: y$ K
$ U( x6 v8 o/ S8 Q3 \' {4 D
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
% \1 q, w4 w) x) X! e9 n" z  f  j//  ProgramCompareMenu.java    Provided by: DRS3 }( ~. U) U5 h/ B5 b; }! W
//1 {* s4 V& ]# u* g+ F& d$ M
//  Calls AuthorisedUsers.java and ProgramCompare.java
7 c. b0 b: M6 u7 a2 L: C5 n$ _, N//- b  f& @& ]% S$ P  F  M" s
//  Driver shell for Assignment 2.1 M; \- g3 n9 l
//********************************************************************
9 X# O" c8 M( }: x: c% {  c2 a. Y! J7 S0 M% T6 T
class ProgramCompareMenu
( w: g  R" f1 d& X3 K. e, \{
# H! p5 Z/ O% I0 C- l    public static void main (String[] args)1 v/ q. ~3 d* _( j3 j, \+ b! |
            {
5 o3 h! _* `6 g' v" A: \5 \6 {. I& j                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
6 W7 b; K( b. ?5 D3 G                ProgramCompare reached1 = new ProgramCompare(); 7 N7 P& }$ q& T( ^
                AuthorisedUsers reached2 = new AuthorisedUsers();       
" H4 W  }/ U: ]4 \# e: N: D' m                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());, W; m% {7 E  `/ V
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
, B5 ]8 s9 }6 F& a3 d) e( O3 d5 `        }3 d8 [  ~9 m4 m
}// end of class ProgramCompareMenu
" O( v; G3 N# W- E1 l7 M
: D5 v. \' u% D//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
; D8 j' E  q" E/ ?0 G, M$ o: o//          AuthorisedUsers.java          Provided by: DRS/ b! b0 b9 R: Z" i$ l# B% [
//               
2 f) q- N) F# `( p/ B//         Program shell for Assignment 2$ M- L; D% C" M" F) V! B  ~
//
5 W- [4 }' w* Q; D3 ~0 t1 `9 _8 Y//         Represents facts about an AuthorisedUser
9 I% s8 q2 F- G% p( `//********************************************************************# m" k0 e" L8 h. `3 U, d2 O& C

, ^6 _$ w- ?5 n7 j$ K$ Wpublic class AuthorisedUsers2 a8 [2 z% H) p% ]( o
    {
" b2 I6 |: Q# q0 ~* p5 z1 c' w  ]
# o9 e& ^; |4 a! B& p7 }) M        //-----------------------------------------------------------------
6 w6 G" w) g6 J% N: @3 Q+ v        // Constructor( V3 g% K' M( k2 `# e! G  B
        //-----------------------------------------------------------------2 `# p: ?' m& E. D4 {+ P5 u

  b; z9 |. \5 y. J0 X# e4 D6 k9 N        public AuthorisedUsers()* V3 G2 b, s9 |& {
                {, w' R* T! ^- c) G
                }6 {. A- a: }4 Z# t4 M, D8 d6 a

( m' j! S5 E8 y+ {* {4 [        //-----------------------------------------------------------------
- O0 z* E+ f- ^3 H, W5 S( D' r0 _' u        // Method for testing that class has been reached
5 C. \( o8 g0 o6 v0 ?+ I! O        //-----------------------------------------------------------------       
5 g* N1 V* R9 S/ G3 k. F0 M7 v$ M        public boolean AuthorisedUsersReached()9 v$ E; p, [1 H3 K4 l
                {0 c- Y, T' U% T1 I! p4 Z
                        return true;                        * X3 L* J, m' d+ _. P! P/ a* w0 X
                }( e) x3 u3 y% d: X6 F8 q1 |
                0 Y( F  j& [1 w
    } // end of class AuthorisedUsers# T6 H  c( s, c- C
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
! H* \8 Q0 H4 y4 `' NShanghai - 2007
1 J- c& P* q0 W4 @& G+ c, NAssignment 2  [( ~2 G) m% D
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)7 [4 M8 d2 M) n
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.
% ]1 w3 E! q# K4 [2 B+ ^* m0 V, N. E7 {The staff must be able to:4 U6 A5 F8 d/ f7 ~; s
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.) A+ H. p/ E* W# [$ T
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.. `% c2 A! C% l" v5 {! @/ i" \
 The interface should provide a menu so that the staff can:
  Z  ]1 p2 _6 P* [' j' H2 ]( Wa) Enter the names of the two Java program files to be compared
% R9 Q* A; h" x% ]- N For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
6 Y+ h6 U: f+ L4 R9 t+ p** 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).+ v! p) C2 p2 L* X7 [7 E
BSA104 Business Programming – 2007: Assignment 24 E+ G, X4 }6 k% w/ t9 p* O
Page 2 of 59 S+ b6 p; [9 T+ ^
b) Print out to the screen all the lines of code that are the same
2 i6 j/ Q  P6 z+ ^* P- S3 x" _7 ^* P Include the name of the file and the line number of the code being printed for each of the two files
4 u4 v& g  c; Z* F$ K* o+ M3 n# Bc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared6 M: J0 k" O! Z) @8 k" p
 the name, username and department of the user
: s- U5 C6 m0 T/ t& ~3 O6 n the statistics of the comparison
& w! B# G8 q# B8 _$ `' c% L5 F/ ?- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
& r0 b+ U  Q! _8 r: f8 N0 w' C the recommendation for further checking. Z4 V( c' A; [1 [& i
- 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
3 H1 n- H# d1 C the names of the two files compared
6 U4 }& ]' @  @4 O5 L2 S, dd) Leave the program (exit)8 b: c3 z/ }8 k) S
The ProgramCompare class: (Total maximum 20 marks available)
. [* c# B0 k$ k" |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)) N; c/ U, a4 F) r( {
a) provide an error message if the files are not found or there is a problem opening them1 J7 q0 \0 y9 X
b) compare each line of code
0 x; O# C8 E0 T* Oc) print out the lines that are the same
. f1 l% w8 e4 {7 Qd) count the number of lines compared / lines the same
& M; F( _- ~1 R* Z$ \3 x2 WThe AuthorisedUsers class: (Total maximum 20 marks available)0 O% T! Z! }2 i
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)
, l( X. H3 k5 r2 V' |4. Provide methods to:
9 V% }$ t" p; ^5 F% F* M8 ca) 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. l* e; x" Z# t' n) B( [. m; K
b) return the name of the authorised user
* l: @5 P& O) C1 F2 Ac) return the name of the department of the authorised user
3 C4 ]2 J* X) E% `* `0 _2 w- c7 t& }Individual Data (Maximum 20 marks available)* E  t9 a& @$ }7 s: w
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.
$ P2 G3 F/ \) F7 ]2 w9 ZDocumentation (Maximum 10 marks available)
+ k, o! J$ o5 t! H5 \0 D6. 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.
3 T, i+ s2 s, I# qBSA104 Business Programming – 2007: Assignment 2$ d0 d8 C' O# q; P# R
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
' b5 R; H; a3 Z4 g不过你要翻JAVA的类库说明。你有下载没有?+ A8 Y" `. ?6 j/ v+ U- V+ Y
查询关于对比的函数。貌似关键字是contrast,还有compare+ w8 ^$ T8 O0 C3 g/ A! P+ j
0 q1 C/ _  K/ d- ?$ f, e+ z7 ^
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
3 K; k& B: k% P痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。1 @0 H: y- E: U
可以下载到的 是 jdk-1_X_0-doc6 b( W4 z9 E" [0 z1 e! b

! G* S- F: N; r5 C0 {& z[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-17 05:00

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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