找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1739|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 7 `) L! Q* B1 T9 j( A' v. `4 V # D6 u3 ~* u+ E6 ^
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************: U% J) C2 V* ]( `) n) V8 V1 [& A1 w
//  ProgramCompare.java         Provided by: DRS+ @8 Z4 O! X$ Y, S0 ]% `9 U
/// ~7 u. o; a+ k* _; y/ s, N; k
//  Program shell for Assignment 2- G% P6 H3 ]3 Y5 z( o7 v1 z
//6 D' E9 N2 V- ]( G) ?
//  Compares two text files line by line5 P3 r  k& t& ?- t5 \5 n) w3 B
//*********************************************************************
9 G! ~& A' {& M- @% y' j! l! M; J; u* q  K5 V- M3 q" F# g
import java.io.*;
4 {/ n6 p9 a& ]9 |. \
& K! u2 n# j& ~( h) Jpublic class ProgramCompare/ @" V  l, r+ d& S8 \) ?
{8 _/ B" y4 p+ F+ l% p8 F
        //-----------------------------------------------------------------
) f! w, I0 a5 p. N# w        // Constructor! A: K3 `8 v  E" V% y
        //-----------------------------------------------------------------! C6 a1 U2 n3 j
        public ProgramCompare()
8 Y9 K- }- v8 r" d5 d9 `$ p        {
$ E! \; }: T' M" I        }
0 t9 ]1 F7 ^7 U1 ^- \! A7 T7 X8 u' \, _# b, A/ ^
        //-----------------------------------------------------------------8 E* O" T4 P1 \5 D1 o% ^2 l" q
        // Method for testing that class has been reached% z) p- F( [, B8 i7 D7 W) `3 A
        //-----------------------------------------------------------------       
5 O+ q" ~4 J  I0 R! E, }
9 \8 W$ _# {! [  u. r% i/ Z* R7 u        public boolean ProgramCompareReached()         # g1 R9 I+ R1 H$ g3 @
        {0 b. @* R) q2 ?
      try
4 i" h: E! B4 d8 n   {         % I' r& F0 X2 ^* W) {: T0 i) S3 Y
                        2 D* S( {1 V' t7 F0 D4 V
                //********************************************************************
8 p% g$ Y" O- R3 F+ J& k* a                // Try-Catch Statement is used to handle exceptions - such as file not found 8 q$ {; y( J- Q! m
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
4 F1 y: `6 E+ e                // For more information see page 534 of the textbook( i3 a% A# s, z6 W: G
                //********************************************************************6 u. Z' ~8 e+ L+ I  `/ ]. W! x
                     ' `' A. O% \+ y! e
        }) ]- g' M4 Y* }
             catch (Exception ex) // Exception caught here and message displayed to the screen , x8 [! Y6 ^2 v* B
          {2 d" P  k# N. M( @( @0 \
                    ex.printStackTrace (System.err);5 A$ ]: O' G; @) a+ ~
           System.out.println ("Error message goes here"); // Replace this error message with your own          6 u; y, s7 N/ o7 X# u3 \
        }( I" r" z! f" p
                return true;
0 @0 L% \4 n8 d        }
) [& T8 Z  l0 t7 G: q! t  `. _) p* Q, W
} // end of class ProgramCompare
. r/ Y7 m, }: S, h8 [* N) N3 G( ]
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
0 L0 f; l% l' r3 V; u/ i: ]3 M, Z//  ProgramCompareMenu.java    Provided by: DRS
+ B' d/ n& m, t2 x//1 @% B4 H6 A* P; `' t7 n6 n2 p
//  Calls AuthorisedUsers.java and ProgramCompare.java
9 `8 u. T$ Z/ k( J0 R1 S! d//& q- H4 c0 X9 W: D7 R7 ?, e
//  Driver shell for Assignment 2.
- }3 R' c* C8 N8 _//********************************************************************
# y/ H+ j+ E8 L3 s6 I  V% @) @3 ], G# T6 S! d2 A! [/ `$ ~
class ProgramCompareMenu9 W2 g: I' B6 W& g, O
{( ?( d6 E% }  ~+ v& O7 a+ I( J
    public static void main (String[] args), G3 t  S1 a. @1 t( f4 o
            {
0 [5 t1 X2 X6 r- L: f                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
" s( W5 ]% m5 U' W0 N                ProgramCompare reached1 = new ProgramCompare();
4 s1 y% y& I) {" R$ I                AuthorisedUsers reached2 = new AuthorisedUsers();       
8 o  }! [6 R* {' p                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
2 n4 f% R* |% o+ W! a& U$ _                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
0 n' T9 q! F/ R! @5 p) Z4 b. F        }
- b4 c( W; w, u# n$ ~}// end of class ProgramCompareMenu
- S1 U/ |3 T3 z* `
3 c# ]3 |9 W  L' q- b//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************7 D& Z' D9 I5 ^6 B+ c6 c
//          AuthorisedUsers.java          Provided by: DRS& l4 o9 i6 d* t9 U3 X. J1 `
//                0 j9 D5 L. |  d7 P+ w0 H. T  H
//         Program shell for Assignment 2
5 P2 f$ A! G# v//
% L& e8 k( L$ v; v4 ]//         Represents facts about an AuthorisedUser6 t- g/ k; X2 D: O
//********************************************************************- w8 m  Y; N  ^. E+ Z6 x! ~# N2 z
* u* x; K# H( p$ _& W3 k
public class AuthorisedUsers: O7 f; r. E& N3 W+ e
    {
- l; `6 w5 I$ `% W4 H. h% S6 W% y3 D& Z) Y, Q# E
        //-----------------------------------------------------------------, f) X) w6 c1 M0 t
        // Constructor% ~1 \/ K  F  n' X$ U
        //-----------------------------------------------------------------
5 A% c; T3 x& S' f- q0 g: _5 w, O
6 n- `/ A/ w% ]# q- W        public AuthorisedUsers()
9 \3 D( E" A8 l) B9 p                {% ]; ]0 r! T' {- K
                }
0 H' G; A& B0 }3 q; B% J: v) T) b% J6 W8 e$ h
        //-----------------------------------------------------------------/ n1 [- g* w; h3 c  ?
        // Method for testing that class has been reached8 S0 D" M, i$ W+ G# X1 A% t1 y
        //-----------------------------------------------------------------       
0 Y" t2 k. i; u- ~  q8 L        public boolean AuthorisedUsersReached()8 Z9 S4 H& V, B8 g
                {  ]4 Q. ~$ h2 l8 G
                        return true;                       
+ x" \& E& u! \" F                }
" K2 q# r. v/ _1 m                2 ~. m7 y2 w: |, ?
    } // end of class AuthorisedUsers
2 @. p, t/ l' _: F//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming+ c) t6 z6 l" h+ X3 W
Shanghai - 2007
9 l: {  t1 ]8 @Assignment 2
9 x, T1 `: @6 I- N+ _' a; aDeadline 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)
; w2 }+ V, W% q1. 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.
5 x3 \  n2 B3 Q% c2 V  R: A" S, T* ^' ]- B8 zThe staff must be able to:
2 J& R) f$ ]) K  h5 c" p# s/ N Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.. @( U' O: R+ H  o+ ?% i
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.( O% F1 c1 T: Y+ a
 The interface should provide a menu so that the staff can:: y' k" v( B3 n9 V- Q8 Q  H4 \
a) Enter the names of the two Java program files to be compared$ g9 \0 l0 h5 i
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.7 Y' a" v2 K9 ]6 H: [% o
** 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).
! f1 _9 P9 i3 y, l2 yBSA104 Business Programming – 2007: Assignment 29 E7 B5 k2 A& A) a
Page 2 of 54 r' E1 d: e) l. w/ {. E5 e. ]
b) Print out to the screen all the lines of code that are the same
0 ~2 {) [' g, z Include the name of the file and the line number of the code being printed for each of the two files
! c) ^$ p( U4 x! c; h" jc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared/ l, m+ x5 W8 Q2 f: x; B) e7 _
 the name, username and department of the user
8 T# s- D1 Q  Z% c/ E) A; t the statistics of the comparison; }0 t  \' r% F! L( ^. x( O
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
' D9 t% e" w5 [ the recommendation for further checking
$ t+ p  n& A# x+ I& H$ Q- 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 closely7 @/ r; Y2 G1 K5 e8 B- {) x! Y
 the names of the two files compared3 b- r; b9 k2 T* ?: K9 w
d) Leave the program (exit)  S( E3 Z7 J9 G2 _) t- i4 f3 J
The ProgramCompare class: (Total maximum 20 marks available), Y' ^/ G- }4 Y0 Q
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)
. D- h9 f1 N3 d7 @a) provide an error message if the files are not found or there is a problem opening them
& U8 Q& i" Z" Eb) compare each line of code( o* Q0 L# q) T8 l/ `
c) print out the lines that are the same5 o3 `( ?+ h5 r, h7 r( T( o
d) count the number of lines compared / lines the same( |7 x) }! u+ [: V7 H0 ~7 n: l
The AuthorisedUsers class: (Total maximum 20 marks available)# Q" t% e' q/ `3 k8 u
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)9 z1 D) ?) i4 \! t. S
4. Provide methods to:
" l: a7 I5 |) O' Ka) 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
8 a9 A1 {0 Y0 nb) return the name of the authorised user
- c; p, x# n& e+ F! Vc) return the name of the department of the authorised user
2 e& K7 h6 V2 Q2 W2 h5 `Individual Data (Maximum 20 marks available)+ E; x; k+ R/ [8 H5 s7 x+ t3 q
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.
# Q1 n& K; l0 |5 b" i$ IDocumentation (Maximum 10 marks available)/ g6 D0 Y+ G8 l# p& N7 H+ G4 ^
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.  J" y+ _8 {2 B) c  j6 y  L$ n
BSA104 Business Programming – 2007: Assignment 29 r+ D3 c  W' n) a- z' j
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
4 q/ r% r- W" T; ^/ i不过你要翻JAVA的类库说明。你有下载没有?
  w9 r  f) I/ l1 E, {  N查询关于对比的函数。貌似关键字是contrast,还有compare
1 b8 F" u& B: ~8 {
8 k1 y5 h& ]  ^. R- U: y, H0 V; T  Z[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -; M0 S0 f* C* J  {; _' A0 F
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
8 X* j' V, [8 k7 k可以下载到的 是 jdk-1_X_0-doc- g% a! v1 p9 |+ M' `
  z3 q0 e8 j2 q* R' o$ u3 o
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-20 13:31

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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