找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1593|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急1 x/ j9 m9 d$ T* I6 ^ % L! R+ N5 Q( m( d: u$ z) H; K
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
! C/ _8 _7 U- O' S7 q- e//  ProgramCompare.java         Provided by: DRS
, D7 @, ~8 O& \  e0 @2 X8 N3 e/ c//
* y5 \5 ]! ^+ z/ o0 _: Q//  Program shell for Assignment 2
& T9 c# O0 r) P$ A! i' s7 ]3 q/ x//* \5 W6 u6 g7 p  l
//  Compares two text files line by line  W4 A7 ]  @+ S. x$ m+ G
//*********************************************************************2 K) o2 V6 A4 n$ G7 g; Q; E1 Y/ g
# l# D& B: R7 E5 y- ^5 B2 O" }
import java.io.*;  L" l7 `( h6 G' [- D1 ^, _7 l

. Q9 `  U  k+ |2 l! C  P! B- Ipublic class ProgramCompare* b1 Y  L' f! B( C# ?# |
{2 I& }9 `) i5 K8 @5 |! ]; A  n( {
        //-----------------------------------------------------------------/ S$ j3 s2 T) ]5 e2 P; Z
        // Constructor
5 H1 [/ D. G- T4 l  i& C& A# d        //-----------------------------------------------------------------/ u6 T1 I% w5 Q/ `
        public ProgramCompare()
" T+ D+ q6 U! j        {
  c/ S9 K4 P' q3 p4 v9 S        }
! _9 j. V9 V5 f) v, L. s% O3 l5 V1 T4 v' C5 v: y8 g; I8 z) q
        //-----------------------------------------------------------------( k: K) l% `* [0 O1 U* _
        // Method for testing that class has been reached) k: M; s6 u& b" m) [) D" i
        //-----------------------------------------------------------------          v$ ~8 K+ M1 D* \+ y' C
5 u8 k2 e% R  ]& y
        public boolean ProgramCompareReached()        
/ ]$ A' B% a0 S6 [        {
9 t9 q" \) D4 a! g      try 4 Y; |' g" H- y- }2 ~
   {         7 T/ i6 v7 C9 I) r' f) a7 K
                        / m: |2 @! m/ W' w9 C9 L
                //********************************************************************
; t5 ~# q8 Y* {                // Try-Catch Statement is used to handle exceptions - such as file not found : u$ N% {& @( [( y
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
% |5 ~+ \( w7 A6 D- A: i: e                // For more information see page 534 of the textbook
  G( d5 L$ F2 n; C- W& h; Y1 }                //********************************************************************) N# S. G1 |& w. `& E6 U/ _
                     ) S$ J: H' `, Y+ h  s
        }
5 _* u& c  C4 I+ z; V; d             catch (Exception ex) // Exception caught here and message displayed to the screen
/ f' \, }7 m; Y. p& W/ u          {9 ^+ H, D- Y0 q& A
                    ex.printStackTrace (System.err);" S, ?- E6 j/ n, }/ W  d
           System.out.println ("Error message goes here"); // Replace this error message with your own         
& Q6 w, ?) m& `1 t" \  J        }' k2 l. Y5 m3 n- A. |/ R
                return true;6 X* Y& o6 g3 k
        }
, }8 I' j: i- J- ^& Q8 p5 |
8 j& W5 L5 }1 N+ z+ H: ]& O9 ~} // end of class ProgramCompare
) S1 ~3 _2 v, ^3 Z: S
1 i+ h7 z  m8 L' l//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
# u( `, g1 ]) ]% A+ ?# c% L//  ProgramCompareMenu.java    Provided by: DRS
% i% j( L/ N; S5 W* t  U//5 ^4 b0 A- @' x% j
//  Calls AuthorisedUsers.java and ProgramCompare.java
- ]# N3 Q& k) ]; S4 R; |3 K//3 V% \( d5 K  H7 u3 C
//  Driver shell for Assignment 2.
* a( V/ L$ ?* y7 U1 N( c//********************************************************************) A% R/ R% i  V, Y. Y

# d; J5 m1 S1 K  G# P& `* F+ Bclass ProgramCompareMenu
2 O0 L% d( O: n" z{$ H+ E3 q5 H' y
    public static void main (String[] args)! N) h0 N& P& \% {& ?; y4 c+ u
            {$ i; {3 ]  e; J" S! l2 Q8 A
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable$ a8 M; o5 x% x, z3 H
                ProgramCompare reached1 = new ProgramCompare(); 9 `# H0 P4 @6 D1 Z; @/ n, X& q5 j
                AuthorisedUsers reached2 = new AuthorisedUsers();        0 }' W' O" S' e$ C) F' M
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
9 ~$ q& [& v3 Q: z                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
. N* M! y9 G# q: X9 s' ^2 M- U. a        }
) ~, [6 ?) |- @) P* j8 R8 c}// end of class ProgramCompareMenu) d% E  K+ W2 ^. k# f' D. ~

; u( ]: o& g$ a+ u) q* J* G: J& E//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************7 J7 r3 C2 V/ Y" U1 S8 c
//          AuthorisedUsers.java          Provided by: DRS, ]" N+ m+ o+ T. d6 P" Q
//                . W1 Q$ w9 Z5 q
//         Program shell for Assignment 2* a: S9 y' g# v& ~
/// {- w7 H# S7 {0 R0 g
//         Represents facts about an AuthorisedUser
. Q# I' V  |3 N' F//********************************************************************
7 j8 h  N: U) I/ V+ C; f$ H6 n. g, r# B7 s/ G  I2 {! `
public class AuthorisedUsers
+ N3 X% A) \4 |* p8 D    {
! ~, q, J- M7 d8 t' h/ G) t: I3 Q, o% K
        //-----------------------------------------------------------------6 y; _3 R: Z, M) q) m6 t( q- _4 m
        // Constructor; c3 M4 v6 e& E. \, j2 c( z" H
        //-----------------------------------------------------------------9 y- C) k" i4 G
+ Y1 x1 X: Y' n
        public AuthorisedUsers()( J6 s! q: M' F. M+ j
                {, n+ T* r# n# H0 t2 ]. x$ G
                }
& D* |! _8 R% q  {! h8 k+ n  Q4 W* \- U0 B. D$ \( q4 m5 b
        //-----------------------------------------------------------------
5 T6 J3 K5 x* q: U        // Method for testing that class has been reached- q- w) Z6 O6 `8 C# C% {
        //-----------------------------------------------------------------       
% i- d: \* Y: P  |7 s        public boolean AuthorisedUsersReached(), {& b- E8 y- A5 \5 }
                {
& f9 y) {, `% j" u- z! L2 ?( f0 k                        return true;                       
7 r1 e9 _3 D5 P; j# S                }
7 @6 y# U+ s" `/ t5 Z4 Z               
; p/ p0 T' \/ n/ Y$ Y    } // end of class AuthorisedUsers
9 |: l# e2 ]' y5 y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming1 Z, K( |: ?' }) ?% Y  d. v
Shanghai - 2007
* i& O5 x* r) }8 uAssignment 2  L- n& {; m/ H1 I% h
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 V+ S. M$ b7 }4 F( \
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.
7 \! [; ]0 q0 b* \4 v# z) QThe staff must be able to:
7 v3 y, h. f* F Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
" x3 [# k8 }. w6 j9 I% h1. 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.
6 `, g; h3 O. ~ The interface should provide a menu so that the staff can:5 ?! p0 m( k4 l9 f3 {
a) Enter the names of the two Java program files to be compared
( q" P0 \2 v+ e* s For this assignment, it will be assumed that the two Java program files are in the same folder as your program.2 X/ i& q! Y9 r  ^* f% p7 V, N
** 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).
8 o) [, {) ~; G/ X9 ?BSA104 Business Programming – 2007: Assignment 2
4 u2 R, J9 q: x; MPage 2 of 5
+ x# t* [. I6 i5 hb) Print out to the screen all the lines of code that are the same
% h( D! k9 Q  p# {4 r5 h Include the name of the file and the line number of the code being printed for each of the two files
( ^: }, G# D! K' B& p4 t, Lc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
/ y, b  o' X6 _1 Y* \ the name, username and department of the user6 l, p8 Y: V$ d7 Y4 t6 Y
 the statistics of the comparison5 k: H; x" a( v. E
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
: O2 W: a5 _! u9 r! e! @6 n the recommendation for further checking
/ r; T8 p9 n* ?7 A- 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! F/ C) m) W' E" q
 the names of the two files compared
" k! _- S- R5 L3 P& m, c8 _d) Leave the program (exit)
( a- F( H+ B" n! ]. W+ j/ yThe ProgramCompare class: (Total maximum 20 marks available); R! s( D6 L# Z+ _# l! S
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)3 X8 L5 F7 f! q- m. g5 U. W8 K  G
a) provide an error message if the files are not found or there is a problem opening them
+ I1 O; Q6 a; F0 z* L7 H" o* Eb) compare each line of code0 I; g- t* i5 v' E
c) print out the lines that are the same
" C9 K3 f* a! _9 o: `" @d) count the number of lines compared / lines the same+ Z' @6 @% ^+ x, y4 @# [8 o& N
The AuthorisedUsers class: (Total maximum 20 marks available)8 S; O( y) M" O& R+ l7 S# {2 p7 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)
  f+ Q& ~; j! Q5 C7 U4. Provide methods to:( l9 u2 d8 N- l- D9 G
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
, E% }* Q2 |8 @' r' `b) return the name of the authorised user7 w1 E% ~, h! F9 ~5 Q
c) return the name of the department of the authorised user1 P( K" i: D: F8 ?2 b4 |
Individual Data (Maximum 20 marks available)# f# r: m7 M' i( A6 }
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.8 C1 q& ^9 f" Q6 k; {7 A' Y
Documentation (Maximum 10 marks available)
" z) y: M0 r8 e( L1 M, A; _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.
- k0 ^- H) j$ P- m0 @, iBSA104 Business Programming – 2007: Assignment 2) d1 z6 I" h( D+ d3 e2 ^# H
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
; U: E8 F: h+ c! S% k# P; L8 |4 z7 K: |不过你要翻JAVA的类库说明。你有下载没有?
2 O/ W' ?: `: D% e3 t, P查询关于对比的函数。貌似关键字是contrast,还有compare
) b2 w- t# Q1 O& x' V* z  y: U1 J: }) q3 d
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
/ P* b5 I) v; V. b- t) G痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。0 Q" @6 ~8 E  [, k. J! q
可以下载到的 是 jdk-1_X_0-doc
, h& w; J7 j# {7 z
- ]9 b7 u% O% ]! s, B[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-1 02:21

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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