找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1036|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急- e& C& T' W" t" \/ h T ; W, ~; q* J% s- ~9 b0 o* `
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************  v" g3 @; K! [  ~" Q  b
//  ProgramCompare.java         Provided by: DRS6 z4 o9 C, P" T" j) {
//
0 u; J  I7 o4 d* r* e: L. z9 f//  Program shell for Assignment 2
! h0 z& |( B# u" w/ Z& |% q//
5 t0 `+ S0 M" |" ^$ L//  Compares two text files line by line/ H7 C  h* Z! r% j
//*********************************************************************
* m" S* o1 w- s* k: h& D
7 v- v$ q% D! ]- k* Fimport java.io.*;! P% L- w- N5 z% A
/ |) ^9 ]' f9 b. E) r2 ?2 m
public class ProgramCompare1 |1 x5 N' G. e3 T8 l
{+ |( a4 N" W! P; I" k
        //-----------------------------------------------------------------
6 R; M* x& [4 A( g6 L! o  }        // Constructor% }4 n- |: z9 t
        //-----------------------------------------------------------------% \# d& y# l( I' W4 I
        public ProgramCompare()9 {* _& ^8 \/ q7 P/ u
        {' B4 l+ T5 S0 w
        }  Q9 F' f1 K+ x+ G1 v- B

/ }  T! M# v5 `        //-----------------------------------------------------------------3 L/ b7 r3 U# t- e8 c4 j3 Y6 @
        // Method for testing that class has been reached
4 [/ @8 i! S8 h: R* N% q        //-----------------------------------------------------------------       
* l( k) E1 s2 h2 j2 B( V* D& N$ Q. O1 {* I5 N; E0 }
        public boolean ProgramCompareReached()         ) x. L: n; G7 g( `
        {: p$ [4 O3 Z# y5 U3 x! H6 A
      try 7 Z( ]: M9 N6 i( D% q
   {         3 p- E4 h( {0 Q
                       
9 P  g+ D2 I2 `1 I4 E' S                //********************************************************************+ X8 H% k8 S4 `8 ]! Z. Y0 A
                // Try-Catch Statement is used to handle exceptions - such as file not found 7 s3 \/ D9 A  H0 l6 @
                // Reading the files will need to be placed inside a Try-Catch - just like this one!5 p2 _' ^" f/ x$ U9 H
                // For more information see page 534 of the textbook& i, m; S! _" ]) j' `! ~7 X# a
                //********************************************************************
/ L3 s/ ^& K; D; V, }7 s2 A' M/ ~                    
1 a% J6 ]& ~3 Q6 d% B7 ?: W7 l        }
! e5 i" r- k5 H4 \. r3 M             catch (Exception ex) // Exception caught here and message displayed to the screen 0 V/ R% _. f, X
          {
( N# a# H2 x+ z2 s                    ex.printStackTrace (System.err);
6 c& M% I% ~& Q6 k           System.out.println ("Error message goes here"); // Replace this error message with your own          ! V# ^$ v" j2 n+ i- }0 f
        }1 }0 e5 |7 K* a1 P- n
                return true;8 m( t* ]( ?" [+ A; T9 B
        }
. v4 L2 |* _7 ~" s0 e) M* m0 \6 D# I8 U3 ^! x- ]
} // end of class ProgramCompare8 x& ]0 q# q; j, R8 H+ P$ F, E

& G  c# Q* Q: m4 u//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************5 u( z/ d! b% B- C
//  ProgramCompareMenu.java    Provided by: DRS
' `; T  ]' ^8 I" x  D//
/ k. c+ W9 D: G1 C' T//  Calls AuthorisedUsers.java and ProgramCompare.java' Z$ {. U- y* r% s4 {8 G7 V. a
//
9 c. X: U: [# G2 H) r- X% o/ M//  Driver shell for Assignment 2.2 ~. h+ c! r  d1 o: d7 D3 V! d) X
//********************************************************************
* s: }2 u; w3 q) l, L7 A, @8 a: E9 g' G8 @3 R) _- D
class ProgramCompareMenu
3 a, a- y$ Z' v, \+ W{# j- e) t. P5 I4 \' R
    public static void main (String[] args)
+ ?& w0 X+ ]1 x: r            {
. }# ?* G8 N; K1 N! y9 W                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
* ]8 y1 t/ ^. R( y) D                ProgramCompare reached1 = new ProgramCompare();
: W% T# J. {3 M; w- b                AuthorisedUsers reached2 = new AuthorisedUsers();       
3 y6 `; E9 z. i                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());8 K) ~" h7 J  ^2 I
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());          U; k) `& z- \- T2 y" O: }
        }* q# b- r' e  b7 s2 x
}// end of class ProgramCompareMenu9 r! T3 F8 z) P$ C. _

" U! N0 F- P1 N. L! i" q( C) G//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************  N# b9 _# i4 ~, T* o& v" n+ t: q
//          AuthorisedUsers.java          Provided by: DRS
) H9 i) B" m( c$ r& t//               
/ P. x5 k) N! @3 y4 x5 N! ^# U//         Program shell for Assignment 2
9 ]7 H2 _# s' V: ?7 E9 Q% |; x//  F' s( o' @( X3 P/ o; \
//         Represents facts about an AuthorisedUser  M8 k) B* x, V
//********************************************************************
% _* s& f3 F- |( Y3 B! p0 u0 @4 |$ V0 G- V' Q% V
public class AuthorisedUsers! W/ S7 ]9 ^. c, c
    {
! a8 j, h2 U! L) I
0 W. H$ f& a6 U- O$ N! p" a        //-----------------------------------------------------------------
7 A$ B) M# g1 A) E4 k' |        // Constructor
1 z2 j" m: u7 [/ c) k9 J8 \) X0 d) d# W        //-----------------------------------------------------------------5 q! ?( p. U% ~# q8 k) i

/ t  E3 W' s0 t1 x9 k: o        public AuthorisedUsers()
, {; E* O3 o- z9 J$ Q$ _                {
) w, _  ~) d% h9 R% Y( U8 B) {2 D                }
  U2 I/ E& T. V* i
' K+ m- o! O" S+ E* l* v        //-----------------------------------------------------------------0 X# A7 K: [' U, A" x, P
        // Method for testing that class has been reached5 x9 O# ~' h4 L6 G8 z1 p4 C3 ?! C
        //-----------------------------------------------------------------        ) o  e+ ]$ X& k+ Q% m2 j0 ]
        public boolean AuthorisedUsersReached()
' B( h4 B1 x! a" n                {
* n' o- w. H3 d& \9 Y. y9 d! J                        return true;                        2 |& G2 \9 x: n! X' V8 {/ R
                }4 s8 a/ C# a; Q+ T; y' Z
               
* c1 j6 r* ^! a" J9 |    } // end of class AuthorisedUsers- t- V2 j/ I$ d
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
8 l  Q% G% C8 V0 Q8 X0 AShanghai - 2007& o: j# U% w6 n3 t# n1 N
Assignment 25 ~+ X+ l- g" O8 |7 x% p
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)* J/ W9 R( J3 b2 O, Q2 T+ W7 e4 }
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.
& |+ ?) Y- R! o% P5 e+ MThe staff must be able to:
/ m1 F2 X# X/ _+ _% D; V Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.0 f- U4 J% S! i# o( v  [" _
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.
% W7 y' T4 w) H+ Y9 n. M5 U The interface should provide a menu so that the staff can:
' F8 q$ s! L$ h3 k7 t1 f/ r9 e0 N" Qa) Enter the names of the two Java program files to be compared
3 a3 j' m' M' u, f8 R  y# Q For this assignment, it will be assumed that the two Java program files are in the same folder as your program.* E  E5 W0 E' T$ F3 D! d
** 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).
4 c* j& u2 f0 Q/ R: y" ~! i8 IBSA104 Business Programming – 2007: Assignment 2
& d8 C* y4 H# R  T+ g- D2 `Page 2 of 5
( Z: ^7 G: r  M+ S0 ~$ i. Y* d$ [b) Print out to the screen all the lines of code that are the same
9 h$ h8 x7 T$ V3 }/ s) D) N: ^ Include the name of the file and the line number of the code being printed for each of the two files
& J$ f! i& ^2 n% v* P; l3 n  [' }c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
: }1 n" j$ ?3 V4 i4 b the name, username and department of the user2 V9 v2 g) b: a7 z4 P
 the statistics of the comparison4 v1 H- m" @3 y' T/ k- C% A- p8 H3 D6 z
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different) |. |; @1 O+ r6 s2 U% c% j$ c
 the recommendation for further checking# Q, V/ v/ L( r& S" w7 k4 ]7 i, 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
" i$ I$ d: f7 \; X2 M  \ the names of the two files compared
4 v9 u# _) x  Y  S0 D# r1 p; {$ od) Leave the program (exit)2 ^9 G! N* D! }9 R
The ProgramCompare class: (Total maximum 20 marks available)$ N6 ]& \  e5 X& f
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)5 C7 r/ p, Y+ z; C1 ?
a) provide an error message if the files are not found or there is a problem opening them9 E6 n  H$ _* b7 w7 F0 a
b) compare each line of code
" @: D0 F' ^% q. Q3 u$ Y  Bc) print out the lines that are the same0 L( G* c# l# n* q2 Q9 E
d) count the number of lines compared / lines the same1 o; E! }1 r- ~
The AuthorisedUsers class: (Total maximum 20 marks available)
$ X+ E) {% P: ^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)& K8 C. F0 D( Q* M# G* |
4. Provide methods to:1 E# S5 b' }2 {3 `' F
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
) D8 p/ g/ h! X: Q$ Q8 |3 G  Lb) return the name of the authorised user
+ U( i( u+ g5 E3 z7 H$ R  e4 B3 n  Ac) return the name of the department of the authorised user
7 V' c4 a* T3 m3 R" H( G; rIndividual Data (Maximum 20 marks available). X0 e% Z. h* A$ j  [6 D  _+ R% |
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.
! |* u0 a* B" e8 O6 P9 q4 vDocumentation (Maximum 10 marks available)
$ I3 n3 E5 ]& o* B/ R$ S: w6. 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.
8 b5 y% `0 Z; i3 q! w/ m& q' HBSA104 Business Programming – 2007: Assignment 26 b+ L! t' m8 d: d* x/ y/ d0 V
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了5 J) B' B; f: x3 I1 _9 j0 d
不过你要翻JAVA的类库说明。你有下载没有?
" p; d- X7 L5 y5 k0 o" y查询关于对比的函数。貌似关键字是contrast,还有compare/ b- y: y& M) e1 U! ~

! ~- e) Z7 Y9 B- z: I) J! n[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
6 Y( n1 \* b' k. p# [痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
" \0 c% C* e. b  b$ Z可以下载到的 是 jdk-1_X_0-doc
2 j! a' c9 l& I, ~1 L* f* p* `* J: ]1 v; V
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-11 08:45

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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