找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1377|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急, j1 n; _0 I0 a$ ~ T) }' b Z* E: u" m- d5 C; l, P
回复

使用道具 举报

 楼主| 发表于 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 z2 K. n  r+ Z8 H+ ]% C0 o, r5 ^
//  ProgramCompare.java         Provided by: DRS
8 }8 O$ H# Z8 W9 s) L3 ]//, Y* m( b- Z8 |, B# O) ~
//  Program shell for Assignment 24 P  z+ {" h: _2 @8 T
//( h( j6 T+ m' G. ]" ~
//  Compares two text files line by line4 i9 ]" J! m- z: ?
//*********************************************************************
# A; g) c* C7 m* O1 m: o2 G$ l( P. w' p( p
import java.io.*;
$ ]( \: `6 A# ]9 S' _- E% ^3 N$ Z3 H2 X( E& ]& o! W
public class ProgramCompare; L/ k+ g( r8 K# m; W# }. a  d2 [
{
3 C" ?: b2 Q( y! Q, G+ c# |        //-----------------------------------------------------------------! @2 R1 e2 {0 }- H1 g- {2 V' ?
        // Constructor( K5 W9 r" c; B
        //-----------------------------------------------------------------
  q7 s* M9 W+ {( Q4 _7 c        public ProgramCompare()
/ B# m% x: `$ [; k5 r        {
. H6 Q; T2 z3 \+ |) t! r# W* F        }  w7 M# q7 ~5 ~' c$ i  w! T; k8 C

9 Z* ]) u! T, F0 h! e" h! W9 Y        //-----------------------------------------------------------------6 |7 E% @% I' n: z: h# {# N
        // Method for testing that class has been reached6 t% J- @6 A% r$ J% u4 H: `
        //-----------------------------------------------------------------        % Y6 u5 b' \3 x" c7 \) h0 r

) m8 T4 k( U0 u  V        public boolean ProgramCompareReached()        
- l0 m, o5 F+ k7 _5 P# R        {* @( h* k6 t% ?1 o0 H9 c- s
      try
# n# r+ n8 F. i: f   {        
6 e! E  W* d# W* v; w9 Q( D9 d. I9 r                       
/ W8 y& ?1 P* x1 f0 w                //********************************************************************  G* n, B% B7 Q$ K
                // Try-Catch Statement is used to handle exceptions - such as file not found
% G- ~8 g/ X. G6 @# |2 u                // Reading the files will need to be placed inside a Try-Catch - just like this one!% N+ m6 {2 ?9 I5 _0 s0 m
                // For more information see page 534 of the textbook
* w+ y" O% K4 S( J  y+ `, b: H- u. L                //********************************************************************) U4 |" V& J7 u0 Y2 o
                     , o8 k3 k5 E7 r$ n8 p/ G7 Z7 x0 w
        }, o3 [2 o6 a% U$ {8 e* ?
             catch (Exception ex) // Exception caught here and message displayed to the screen
3 I' D. V+ k# l: H% D3 I9 Y5 X          {
4 X0 J6 ^9 X5 K7 w( ^! F7 H                    ex.printStackTrace (System.err);2 d2 F! z% u- {) E* _' B$ a
           System.out.println ("Error message goes here"); // Replace this error message with your own          % K5 T" l& u: X1 s+ I+ u' v  U
        }& |% R  l0 E& g1 T: [" A; Z
                return true;8 E8 |/ D( t+ `( }. S
        }) I2 L& L) d- C6 H8 {. x# K

8 h8 O" c% m. q6 e& n8 ~6 r' ^} // end of class ProgramCompare9 J; ]6 k4 d/ e7 D9 x; s$ `: A+ p
$ a8 U9 {; _. u9 `+ s' \7 E
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************) S* e, y4 n1 F( i0 j) r6 M
//  ProgramCompareMenu.java    Provided by: DRS
3 E7 W7 j7 {) p6 }! d. L//1 R8 u7 H6 ^2 P
//  Calls AuthorisedUsers.java and ProgramCompare.java
, F. o( A8 s8 v  n. d//8 O$ K# O/ w0 h& Q5 h% C' Z
//  Driver shell for Assignment 2.* h  j" i& E1 Z+ V8 |5 @
//********************************************************************2 F* V* O! g, z
4 [/ c# t  b2 _" p' s9 A# S7 ?  g
class ProgramCompareMenu; |  N# j$ u+ b$ @9 d/ \
{
$ b6 X" e' r$ w  r0 |; w% F    public static void main (String[] args)% G. m7 }. T# M8 O  [" N
            {
! Y7 [1 g; M/ o( X% N1 i                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
% q0 o* M* P, m3 J( i* `& N- H                ProgramCompare reached1 = new ProgramCompare();
# A; [8 J' r& W( ]" D0 d" r2 V                AuthorisedUsers reached2 = new AuthorisedUsers();          v7 n7 a' j3 V" z% |. q
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
, [$ G" l2 j+ O3 `: Y1 }) }4 a+ t                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        $ B' h4 P) E* G! N
        }
/ S1 H5 N1 s, a" ^. @}// end of class ProgramCompareMenu; R, r( S$ Z! Z5 i" ]

" }  L- ^4 Z8 R/ T. m5 d  F/ p6 Z//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************- E+ }1 f& g9 e( q. R- ~2 c. W$ U
//          AuthorisedUsers.java          Provided by: DRS5 z- k3 U$ U5 N1 ?; R: I- W
//                - |- P  i. }" s5 S5 W1 g
//         Program shell for Assignment 2
7 ]6 g9 d3 L" H6 @) U* q! ^+ S//
1 C7 s$ Q  r+ ^" D" Q/ K//         Represents facts about an AuthorisedUser+ ~# E# U! u4 s" _4 M
//********************************************************************& v0 Z  l* w7 m3 L% m+ }
" Q" a, `: w4 Y) H2 |6 q
public class AuthorisedUsers
( \6 O+ m* e: U3 @+ K    {
: F# v/ \3 Q+ Z6 f
8 G9 E# g% }/ J        //-----------------------------------------------------------------# S7 |* N$ p' ^; Y  |0 J
        // Constructor
8 Y) V7 s& |" }) P        //-----------------------------------------------------------------
) J8 k, @% J: w8 Y$ Q% l  m% W6 v6 _
        public AuthorisedUsers()
; E9 K+ Z4 m: }& i& N2 l9 L                {
* a" E  W! v0 ]" L. ^+ U/ w                }7 }# K+ ?* ^6 a" _3 x

) Q( L+ ~$ _! q3 J! g        //-----------------------------------------------------------------
* F- |& e' d! {) P9 R        // Method for testing that class has been reached
: v6 P8 G8 k; i2 x9 E. F% g        //-----------------------------------------------------------------       
" i* N: u. t! N( \        public boolean AuthorisedUsersReached()3 f0 A4 o+ v* i# b& ?/ l  d
                {
& A7 x2 z7 K# V6 a! @6 L  @; C2 V                        return true;                       
' _( u; E' `2 J" u3 n, J                }
8 v+ t6 t( J( m7 Q                5 j/ ]+ d+ a  h
    } // end of class AuthorisedUsers
% Z. d! o' v7 G9 T" f6 ~//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming# ^( a. T/ x5 |  l( f2 Q
Shanghai - 20072 r% q* N! p! p6 Z& V. }1 @5 U2 X/ L
Assignment 2
& s1 j' v- b$ T8 A9 M' ^: gDeadline 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)
+ a" k7 e* y+ C+ w1. 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.; _8 g: Y0 n: Y6 ?8 Q5 n# \4 }$ V5 F
The staff must be able to:9 I1 R2 U& C6 r6 c  A$ q
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
  Y6 P" B. @  M& u. w) C1. 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.3 I! j  F6 {+ E( a7 D; R' Q5 J; l
 The interface should provide a menu so that the staff can:
' w. l# \8 b: d3 U; k3 f! ga) Enter the names of the two Java program files to be compared
5 _: @" w. C# m% |6 R- W For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
1 I  i+ x5 o0 M3 V** 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).
2 a, {  n: j" F3 O- Z7 {+ gBSA104 Business Programming – 2007: Assignment 2
8 C0 V; a4 V2 e) uPage 2 of 5
) l- w7 N) S7 G3 r; Hb) Print out to the screen all the lines of code that are the same# x7 k3 ^+ v4 A) Y7 e' q
 Include the name of the file and the line number of the code being printed for each of the two files1 X8 \8 E& o9 A1 t. J  K: X
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
& a/ y8 }" h' q$ ]2 X the name, username and department of the user) T3 w4 Z+ C- s- }4 a; K- w
 the statistics of the comparison. a6 K' [% O6 g1 z2 ?
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different/ W7 ^' [2 a: U3 N' l4 J/ _; |% z- D
 the recommendation for further checking
3 _# j& t/ \" |4 X: ]8 |$ k6 x! e- 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& H/ f+ o, P, I" q! F* @& l
 the names of the two files compared" c1 Y9 F+ C9 A+ a+ l6 X
d) Leave the program (exit)3 L' w7 f, |8 a/ [1 z
The ProgramCompare class: (Total maximum 20 marks available)% n+ a( b4 p% I3 V# [
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)! z, e2 y* z' P  u% b; u) i  I& M
a) provide an error message if the files are not found or there is a problem opening them0 U+ A4 Z+ B" V8 R3 [" v" w
b) compare each line of code
/ n" L" Z) P" ?- O3 G( kc) print out the lines that are the same
! e4 O% W; n1 q) q9 U+ V$ bd) count the number of lines compared / lines the same# K  \, H5 |: n" |
The AuthorisedUsers class: (Total maximum 20 marks available)! e$ \) A; p! I$ E9 N& m) h
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 r5 N1 H' E$ j4 S2 I, ]
4. Provide methods to:* ~) U0 K9 F9 K
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 match0 A2 j' B" z- [1 q, [: f
b) return the name of the authorised user  H2 B8 X& d# n0 x8 ]9 ^' `
c) return the name of the department of the authorised user/ @& ]" A4 h. `7 j" u
Individual Data (Maximum 20 marks available)
6 o8 I$ Z# p' f( w4 z4 U7 o5. 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.
$ n+ Z( F# V6 A( }, h- {Documentation (Maximum 10 marks available)
! o* q$ W$ _, u8 ^; q6. 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; y6 C; g4 I& x
BSA104 Business Programming – 2007: Assignment 2
7 I0 B8 k, H1 mPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了6 w- S" e6 `: c0 ~. Y& I
不过你要翻JAVA的类库说明。你有下载没有?9 L  |. G6 n' ?7 Z( y. L( [* h
查询关于对比的函数。貌似关键字是contrast,还有compare: k' Y$ p3 ~; `6 @3 R% N, W$ E2 {

2 Y$ V. S" x; C5 _2 s& \9 g[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
  y0 f0 a' M- x痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
+ }6 k) J/ p/ G; Y" y& o6 ?: m可以下载到的 是 jdk-1_X_0-doc
( R  _, O1 e) v8 u; q, e( j! Y- {( q8 w& a2 |3 Z
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-11 21:23

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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