找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1116|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 6 Q' w4 S0 P) n' [+ T1 L. T N9 x% S# z. ^6 e
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
6 n: S) R4 W& l4 D: L6 j//  ProgramCompare.java         Provided by: DRS
( a0 b! Z6 K9 Z& [0 S1 h//1 T+ X/ D/ f1 l! A) O0 b: K( w
//  Program shell for Assignment 21 d3 a) b0 y/ e7 O* c8 b8 h( Y
//
. P0 i# y7 a9 d8 c0 E  S" Q//  Compares two text files line by line
! k6 A4 Z8 o' @$ t8 g$ i2 m+ Y8 ^$ J//*********************************************************************
2 i6 C8 v7 b( X1 F0 ^7 T' w9 B- U
import java.io.*;, J  c6 F3 n7 s' j8 p$ g2 j2 A+ c
* O" i1 n: w1 T0 m
public class ProgramCompare1 n: A& ~0 M1 ?; Q# F5 G
{7 d8 o3 p7 _- `  ]2 y/ ?9 {- `
        //-----------------------------------------------------------------7 Z& U  V1 D1 p4 p1 |. K: G
        // Constructor3 z) o- r0 |" H1 q5 M: A1 u
        //-----------------------------------------------------------------
8 G  ]9 D" u( O        public ProgramCompare()
' k) Q4 G0 X0 e% b% K; o# a$ f        {6 T  J% r/ S+ h' K
        }+ J6 S) J) }$ M( \

7 g: Q! ?8 C: ~$ z: W        //-----------------------------------------------------------------
) _6 e6 I! v3 R1 C  H2 x. P* t, d        // Method for testing that class has been reached5 |! B( ?9 L- b8 B
        //-----------------------------------------------------------------        - f% U+ y9 `, R3 Q; r

- x( p& O( q* s) ]3 Z/ k        public boolean ProgramCompareReached()        
) {/ h+ [* `+ Q        {
0 K: O, I' a8 G6 t. O      try 8 ~( n* {2 m. r3 M
   {        
0 K: w# }3 J9 D                        ( c/ D9 e3 U, `' \0 x
                //********************************************************************
/ b+ u4 `: y/ h9 u* u4 W                // Try-Catch Statement is used to handle exceptions - such as file not found
, z) `# F8 ^) [                // Reading the files will need to be placed inside a Try-Catch - just like this one!
/ l# O, r% D/ Z9 x                // For more information see page 534 of the textbook# c. r7 ?+ K/ S3 i" ?# M, |& c
                //********************************************************************5 i! K7 x. w1 l
                     # D, U  d% v4 s3 B
        }
4 q! s# q4 e! r7 l7 u6 a5 X+ v5 e             catch (Exception ex) // Exception caught here and message displayed to the screen
5 m. A4 W5 A& V. N          {& n# v1 o1 B# B
                    ex.printStackTrace (System.err);9 p. o. p! T6 V# H5 e! D% h, ]4 V
           System.out.println ("Error message goes here"); // Replace this error message with your own         
6 J4 _3 S' C) l6 O4 b- z6 _: b        }7 `" n% g. D8 |
                return true;0 h( o5 c1 k+ T! F9 z
        }
; p0 F( `3 j& |7 `0 I9 |
6 R3 [" e6 g# j+ [* |+ c/ F/ [: E9 s6 j} // end of class ProgramCompare" ^7 C, Z/ }: B" p6 N4 @: @- Q- Y" @* z
$ e' t! z, L; N  j: h/ e
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************% C# M/ T" O; N5 }* y. t9 S& w+ {
//  ProgramCompareMenu.java    Provided by: DRS
3 e/ h9 j4 l: ~4 b% A//: |9 H1 N# F& E6 y
//  Calls AuthorisedUsers.java and ProgramCompare.java( T5 h1 _3 ~  @* Z
//
  W: N( }. b9 S* }//  Driver shell for Assignment 2.
% F6 I1 E: T; S0 \8 Z//********************************************************************
3 ?2 F, ?7 t( t: l- x' @( j4 f+ i) L9 r0 n4 Y
class ProgramCompareMenu7 H: f( j9 E) T$ {6 B' W
{0 C; b$ v7 A2 J' y( M
    public static void main (String[] args)- p  j" c% g+ n; J
            {
7 o" M  f4 r5 ]7 z# k8 r                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
6 g0 I- Q, K6 }% H                ProgramCompare reached1 = new ProgramCompare();
* `2 q! z: K+ k- i! f1 \8 h                AuthorisedUsers reached2 = new AuthorisedUsers();        + o% n/ m. R; E7 k7 T5 U, z
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());& V: P7 T) V/ t
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
( A; L4 z* x  M, I        }# }5 n& Y$ \: E8 M. j
}// end of class ProgramCompareMenu
) H: Y1 o  d) g. _" F4 p/ j0 ~0 S2 ]5 R+ H. Z& V" e3 z9 b
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
) C4 U" M- n- Z: \  e//          AuthorisedUsers.java          Provided by: DRS
' t6 }  ^$ \( t6 @& [" E/ f8 ^1 A//               
% R. w3 E  r0 E, `- u9 x//         Program shell for Assignment 29 g1 b- u0 L( {7 m
//
/ v! d" g8 ?; P//         Represents facts about an AuthorisedUser. D1 o; _# \& S$ u% ~, u
//********************************************************************4 E5 A, w9 Q8 r
* Q9 L8 ~1 F% R. G3 h
public class AuthorisedUsers
! c) Q" ~% O: E. O0 R    {
) j/ N/ W$ Y. _- ~% p& w& J  D: H( P" d8 B: p1 \) g7 R( t
        //-----------------------------------------------------------------8 Y( V: r9 H  o- f% T* i/ M
        // Constructor
! m7 s% K$ k* M3 Y: T1 a  p& v        //-----------------------------------------------------------------
, X4 Z/ m0 V% Z6 l
& }. J' k: d7 Q! I9 ~5 E3 c- m        public AuthorisedUsers()
; J5 _% _. V: l+ w                {
  Z) ~& d1 \$ _! d' h3 @+ Z                }
  h/ Z+ _6 C& @. d* a. C+ K
& u5 I" C: G8 l5 N, K6 b2 e6 ^* F        //-----------------------------------------------------------------
5 r/ C0 k( u' ]9 D9 F( k) j$ M, ?        // Method for testing that class has been reached
' ?8 f' {5 k1 O( V        //-----------------------------------------------------------------        0 B2 j3 e# g' K# U% R! W
        public boolean AuthorisedUsersReached()+ `( r) \0 s- U& H( Z' b
                {$ B% ]! R5 a) N7 t% s  Z2 H
                        return true;                       
' ~5 u' R4 G6 H- [3 a! [                }
4 ^# K$ G" m$ p4 b                2 X+ [3 C  ~! q2 g' E
    } // end of class AuthorisedUsers
' O1 N- J; X" Q* `" s9 e  h//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
8 p, C! g9 o' ~- {( xShanghai - 2007
" q' ~3 c7 D- u3 `: s7 uAssignment 2
; a4 @4 x" Z% ^# L' e1 zDeadline 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 S7 W, u" \& `7 I
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.; p1 N0 K% H. G2 s
The staff must be able to:
" x4 G' n1 r# U, ^6 [& b Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
5 t7 Q$ l1 W/ S$ g0 X4 d+ j1. 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.7 S: l0 U9 v) A! |$ j% h
 The interface should provide a menu so that the staff can:
6 Y/ H* z6 c/ R- ]a) Enter the names of the two Java program files to be compared
0 W* T  |- I9 S0 w For this assignment, it will be assumed that the two Java program files are in the same folder as your program.% x% y5 k  H( Q) ?
** 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).6 [& ?8 N; ~; a2 s0 C" l" h1 k
BSA104 Business Programming – 2007: Assignment 29 V1 [3 o1 v! {7 E
Page 2 of 5% N! J9 [" P4 J6 A6 x8 s" M% I
b) Print out to the screen all the lines of code that are the same
" f. q$ k  H& w! u5 i Include the name of the file and the line number of the code being printed for each of the two files
  E, q1 h( U% ~! Hc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
" q' j! R- k. y- f5 }8 W4 P the name, username and department of the user
2 }* n/ ~( `3 S4 X: Y the statistics of the comparison! ?& H# {+ f2 B; h, M% j
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different& z4 `# a, V7 M& j5 d- S  o! d
 the recommendation for further checking
0 K* _4 S3 w" c: k% b: w- 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
' L! K6 ~7 K  G; E2 `; D& N the names of the two files compared5 T% ~( I5 K' l2 }9 [+ p) k& w
d) Leave the program (exit)
: R, \1 o9 @2 s5 X2 n* @The ProgramCompare class: (Total maximum 20 marks available)
. |2 r. W& ~4 j! m2. 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)2 n" O: o/ A) j8 _
a) provide an error message if the files are not found or there is a problem opening them- c/ S0 q  H6 ?( C3 k, C* l
b) compare each line of code
. u& X- H$ _7 D* Zc) print out the lines that are the same
% W1 t* R5 Y, k* B, u7 Td) count the number of lines compared / lines the same
; m1 L6 T3 E8 O: a8 P7 |The AuthorisedUsers class: (Total maximum 20 marks available)9 R4 o( k$ w- S5 B. ^4 y" ^
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)& R0 c$ A0 f( u5 o+ l& m
4. Provide methods to:" }  ^' t2 d0 ^, y
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 match7 P# F+ }1 M) N1 I4 \1 J
b) return the name of the authorised user4 F( j! T. e) ^1 q
c) return the name of the department of the authorised user9 m& y  p4 w% U- l  H
Individual Data (Maximum 20 marks available)
5 @6 a5 Y  s  L; d  p5. 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.
+ t/ |" C/ k. X9 KDocumentation (Maximum 10 marks available)3 y( }' S# V2 P8 s
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.0 B! h5 v3 A" S$ P
BSA104 Business Programming – 2007: Assignment 2
: ~9 \2 D& y% y+ e! c8 S, m3 lPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
) c& W$ k  Q4 T6 g. p* b4 N/ i不过你要翻JAVA的类库说明。你有下载没有?
' o- i8 ?* j8 P" W) @% `查询关于对比的函数。貌似关键字是contrast,还有compare& w8 s5 H" |9 s' K

% G" H0 _9 n  h2 Y9 N[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
  Y5 o. \0 b1 D$ F. ?* v痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
# l' Z& H. T' ]$ }9 d. E可以下载到的 是 jdk-1_X_0-doc
1 q7 A- l4 l1 Q: u: z  Q+ P( Q
- ~4 c8 g+ N5 f2 {[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-3-15 19:32

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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