找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1074|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急( W' j! T9 A3 Z5 }1 V3 V, P; R& t6 l 3 [, h( r) H/ M2 _8 l
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************+ x: l- m( Y/ v! p) ~. V  j" [1 U4 w
//  ProgramCompare.java         Provided by: DRS
1 d0 k  @' M9 @$ S5 z5 L+ J: H//# Q, m% z- [" p0 z
//  Program shell for Assignment 2/ N7 ]1 c% }& ^+ d. i5 d
//
. L! V0 B4 ]: _. W9 T" H& }//  Compares two text files line by line* }1 j2 f  l! d4 I) w6 s
//********************************************************************** d/ |, Y" e2 q, @; M7 J/ R

/ U- [6 ^3 L+ z/ U& l9 b, ]2 N& Eimport java.io.*;7 Y. o- B  i* {1 H
% g3 j0 \  X! h
public class ProgramCompare
3 U- [' x, d7 L- A# _4 v; M{
) V" E3 `5 T7 H) r; @        //-----------------------------------------------------------------4 @- t2 {+ N% R# k2 N2 K
        // Constructor, x' o% K1 u1 z/ t& r6 P3 v! I
        //-----------------------------------------------------------------7 p  h7 m) Q( l: a# W! V$ K
        public ProgramCompare()
% x0 t8 H1 [5 L) o        {
; C0 F: a, }, x, K        }
/ k- t2 ~0 C. t+ y/ f' C+ O( T0 Y+ a- z/ e( P
        //-----------------------------------------------------------------
/ W7 o0 B- k: g$ ?* k. Z, ^0 q        // Method for testing that class has been reached
# O# u; h% M9 R/ G* ?! ^! M! e7 A        //-----------------------------------------------------------------       
6 J4 V8 C/ Q5 W' z' C+ a- p7 {* y- b% }! k1 P" y( |' A
        public boolean ProgramCompareReached()        
: t9 Q% b9 B. t% W        {  N  T5 ~. a8 C
      try
' H: Q2 ~6 l. H) l+ [   {        
. `( y* Y0 A1 x- |1 R/ a  o! E                        $ F3 X2 ^( _: h. L( D  o! ]  ~5 G
                //********************************************************************+ {: d( [6 u3 o4 q
                // Try-Catch Statement is used to handle exceptions - such as file not found
- m/ O$ _' G( F8 Y                // Reading the files will need to be placed inside a Try-Catch - just like this one!' c7 x# q2 A# Y, Z1 f5 Y
                // For more information see page 534 of the textbook7 o8 c/ H& [3 V4 L
                //********************************************************************& u' L$ P  L( Q8 v. V( Z
                     " H# w5 g, O" ]) I
        }
* J- a: W) ^* A3 }             catch (Exception ex) // Exception caught here and message displayed to the screen ! L% p+ V1 m% \& w
          {" g4 u7 W5 N2 s
                    ex.printStackTrace (System.err);
' y/ D/ ]( W0 |. B3 t5 k           System.out.println ("Error message goes here"); // Replace this error message with your own         
: T( G1 o9 ?0 [. o8 F, p/ P9 _        }8 Y* L: A& S: }0 P6 C# P+ P
                return true;2 I; O1 h; y1 Q
        }  l- N' m3 s1 U
" L3 A! c: G& a3 D6 j  R( V
} // end of class ProgramCompare7 _! [8 t* b6 S

, v$ t3 `" U4 f+ w, q//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************' @4 n; Q& y; X# M! U: V' N
//  ProgramCompareMenu.java    Provided by: DRS0 D+ g) L# q8 `* D" @
//4 k2 ]; \7 [9 ~& i$ b
//  Calls AuthorisedUsers.java and ProgramCompare.java$ a, z. V/ Y2 s9 `
//
3 w: |$ w1 C5 ]% y//  Driver shell for Assignment 2.
! X) n& Q& S1 L//********************************************************************( v6 Z4 e( H" T. N' V
( G6 i2 D; t3 M  s- b, Z. r
class ProgramCompareMenu
: z$ \, c8 `' ?8 d4 t  t, D{
! J6 n% _% S2 Z    public static void main (String[] args)
& m7 s, t2 v5 B  h            {
# _* _2 c1 U: ^- Q! B" }                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
. t- b$ ~# x0 Y# k$ y/ D) Q& @. a5 @                ProgramCompare reached1 = new ProgramCompare();
. R2 p% Q2 t- j/ m4 t8 m$ j                AuthorisedUsers reached2 = new AuthorisedUsers();        2 u* o4 c. z" M# P4 R5 G. b
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());3 ~' \6 \+ ^1 @* ~( T
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
; H6 c# b3 _2 |( j        }- X. o' a/ x9 d( r6 o& I4 k
}// end of class ProgramCompareMenu6 c) T1 C' V6 c& g
# Z1 ]$ N$ J* [! k
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
3 ]1 B4 c# k  E/ T$ A+ G//          AuthorisedUsers.java          Provided by: DRS
% B' T8 e: ~9 f/ P//                # a2 M! r( Q1 i0 ]
//         Program shell for Assignment 2* l9 z1 X7 y# O9 C
//
% l- O0 `! h8 O9 j//         Represents facts about an AuthorisedUser% O2 I( c* l, e  ?6 C6 L
//********************************************************************
1 M6 \" h. X, l' W8 {7 t- p# h' \( p2 k/ M$ s$ a8 ~
public class AuthorisedUsers0 o8 Z4 z7 q1 \0 j% K5 W5 J; h
    {$ H, e- W- p' c0 \4 V& _

+ ^; |. P1 K0 k0 Z4 o+ c        //-----------------------------------------------------------------
# e4 o, e/ ?! }        // Constructor4 a+ ]% u  h& N
        //-----------------------------------------------------------------( l; y' R* I. H  E6 X' b
# ]; C" C/ {4 Y& A9 W
        public AuthorisedUsers()9 e( f, k+ B$ ^
                {
9 g5 U* Y% j  |) B, [/ T* F1 ]7 w                }
( x: `: t7 d" k( G/ G( X) H7 s
, Y& ?1 _, C: ~+ r/ o8 O        //-----------------------------------------------------------------, k7 A' |" B, G9 `; d
        // Method for testing that class has been reached- Z. E: o' g  P! a
        //-----------------------------------------------------------------       
4 @7 s; |  W5 u* T        public boolean AuthorisedUsersReached()! O6 F; h: d: k4 L
                {- G' f; c9 v1 S
                        return true;                        3 H3 L: ?' ~  @: E# A
                }+ D. l+ k% n* K: r: N7 U% @
               
  x5 B: I8 C) @* I  s) ]    } // end of class AuthorisedUsers
( v- ]. @, |1 K# ?/ d. X7 a//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming4 p4 _) z" y( M% W' B, H9 o& s; e/ t9 ]
Shanghai - 2007
, t7 c5 m2 g5 i3 N$ ?( }Assignment 2
4 A" r8 _4 `) y6 F; Y* l/ E2 }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)
& V% t$ E1 I( u2 Z6 T1. 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.: R! b* h% m/ ?3 c
The staff must be able to:& d$ x& N" \# }9 h& K) p: k$ }
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
3 P9 t+ j6 E/ Y. _# x" K) e- o# B1. 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.
* N, p# s5 w+ x3 j& [- ` The interface should provide a menu so that the staff can:/ ]$ c( ]. K# h0 z) v
a) Enter the names of the two Java program files to be compared
) Q/ b3 v  W) I; J% D3 i For this assignment, it will be assumed that the two Java program files are in the same folder as your program.8 v# L) R, {' P7 V- z- \5 g* S
** 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).
: K; C/ g7 l8 f% G, YBSA104 Business Programming – 2007: Assignment 2( p4 S( {  ~/ ^9 |* K* [
Page 2 of 5; U: [0 B& l2 a( i* Q
b) Print out to the screen all the lines of code that are the same
' L, \4 Z3 l# N5 b4 f+ x- ^ Include the name of the file and the line number of the code being printed for each of the two files
+ i# [/ o" f8 Qc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
, B+ g6 ]2 q5 ?( f3 Q9 ?& u! Y the name, username and department of the user0 G. Z, ~- [8 r  @
 the statistics of the comparison" _( R0 E0 r" a* K8 z& r
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different/ c  E: h. h% C* Y# F5 b
 the recommendation for further checking
; \$ E3 j0 [: w9 r% {' E# h- 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
+ ?# D1 [, I1 a9 Y7 ^% O% u& X the names of the two files compared# F* {) }; x6 C" |7 W
d) Leave the program (exit). i, d2 T' L9 h5 _. h( j$ m
The ProgramCompare class: (Total maximum 20 marks available)* w: J/ R1 y% T/ D9 b+ V2 T3 M6 ]
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 T; b; s& |/ @& Na) provide an error message if the files are not found or there is a problem opening them
% j: r3 X4 `/ `1 v. Hb) compare each line of code) a1 J" T  o* M' e7 D/ P
c) print out the lines that are the same0 l% i+ z5 X7 g3 S1 K  b
d) count the number of lines compared / lines the same6 e5 ]9 |% B) P
The AuthorisedUsers class: (Total maximum 20 marks available)+ l% \* P" A  p8 K' |3 H4 D: S
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)
8 }) ]$ t" {* \  M  x. ]1 ~4. Provide methods to:  R8 {* S6 w( z/ V% j
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 match4 a# E) r0 I1 d* f, s5 E& v0 N: |* l
b) return the name of the authorised user
% ]/ h; ]5 \* J8 n0 b8 @$ ]c) return the name of the department of the authorised user/ }( C' C- [5 ^: U: u$ O6 m  @
Individual Data (Maximum 20 marks available)3 l9 Y6 C; d% f, t
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.) J+ U1 B, s! p- }1 Q9 B
Documentation (Maximum 10 marks available)1 |+ {- q* |# @  Z$ g
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./ f, m& C' w$ m. M* J! f5 d
BSA104 Business Programming – 2007: Assignment 2; \( x& l" r0 y4 X7 _% ~
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了' I" h* S$ ], i/ r, j1 U& l0 H) R
不过你要翻JAVA的类库说明。你有下载没有?! B1 ]& D# [3 b/ l* x! e
查询关于对比的函数。貌似关键字是contrast,还有compare
4 B( |; G& V3 [, s' }
, N+ o  X; w) g2 w7 U[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -" _" C3 b8 T/ I) o4 t1 f9 i* [) y
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。  \1 Y  m7 f! y2 F
可以下载到的 是 jdk-1_X_0-doc: f- Q8 Z7 y7 n6 s4 c

" M5 @5 p. Q! y: t# H. n[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-26 04:35

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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