找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1852|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 6 U& E2 A1 ~# B3 `: _4 a( H6 L & I' @7 t0 p6 T
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
1 |/ Y5 p6 p7 \//  ProgramCompare.java         Provided by: DRS
) W& E6 b& b4 m: d//9 j& Q. n1 }( ^0 T
//  Program shell for Assignment 2
  d6 X/ z0 W# @3 y' `! }//' e# Y+ k' a- G! L* k' l
//  Compares two text files line by line
2 K& y- g1 e7 o. }5 T" V* [//*********************************************************************1 m- T( m. X+ U6 W: S) }

  }+ F" _: f3 Pimport java.io.*;9 @# F! L+ j/ j6 u

8 R( C3 h2 j9 Z. zpublic class ProgramCompare
( X9 b$ A: g# h1 D{+ b6 j7 ^$ J( n; [" i7 c' Y* u
        //-----------------------------------------------------------------1 I' S1 V6 u9 v' o. V
        // Constructor
, @9 K) S, X  E1 P, q        //-----------------------------------------------------------------
: n2 \. e5 r7 Q# R+ N, s3 Y3 y- x. w        public ProgramCompare()- t7 A' y, h' E+ f( }$ R* j
        {8 p$ d8 {# H3 O( p+ W% f8 i3 E
        }
: \9 ?$ {  B6 d* ^/ U1 ]2 N( M1 D; X
        //-----------------------------------------------------------------; d4 v" B5 H' {# G% B0 P
        // Method for testing that class has been reached
3 N3 ^' k) y$ k5 ~# C, {        //-----------------------------------------------------------------        & j7 U1 f3 Y' d" m

+ z$ S$ B% p2 L% H        public boolean ProgramCompareReached()        
( H) e" S* S6 t        {
0 o4 b2 L* v: m7 t9 x      try
# {! @6 w- O7 J4 Y$ ~' e   {        
) e! w* c3 v5 m$ J' @! q0 _                        " Q; q: D- z+ F: T! F
                //********************************************************************$ \; a5 D$ g5 U5 \' d( n  u# J+ U
                // Try-Catch Statement is used to handle exceptions - such as file not found
. r# x+ t" x+ H7 e+ p4 K2 S                // Reading the files will need to be placed inside a Try-Catch - just like this one!
- T& D1 M+ X+ Q) N! A& m                // For more information see page 534 of the textbook6 R. k' N) h+ ^- y  z* G
                //********************************************************************
" O7 |/ E* U" ~! Q, }                     ' Q0 j1 e5 v/ f. ^
        }
: D3 |3 q8 b/ X8 c             catch (Exception ex) // Exception caught here and message displayed to the screen
) {, }5 S1 T% I% R( P1 [! d          {# Y! s9 n  q2 P) q6 J6 t
                    ex.printStackTrace (System.err);
  O& {; g; [$ w! S: g; x           System.out.println ("Error message goes here"); // Replace this error message with your own         
/ A: z8 E: j5 g. r0 r        }
0 ~& }+ Y# D; ?' Q  j                return true;
+ x: T. U2 K9 L2 W. [        }0 K. f7 ~9 P0 k7 b3 e' C
# B* c: f' k/ b! N
} // end of class ProgramCompare
/ F" B8 s  E' e$ M, g
+ q9 k7 S- [0 j- C- S: j5 _$ C% S6 K//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
) ~( O8 {; t$ X//  ProgramCompareMenu.java    Provided by: DRS" }6 S, b, o7 P! {* N
//$ L# W- K- M3 ]3 K5 w4 o! I
//  Calls AuthorisedUsers.java and ProgramCompare.java, X  M% _7 T1 y; U7 _
//
/ r5 L% l2 D0 I/ W% d' d  e& s//  Driver shell for Assignment 2.
( u9 ]8 D; I/ z7 O3 W( p# A$ l2 n//********************************************************************
; k  s& J! i, \. ?
  N) W, r) G, Vclass ProgramCompareMenu
1 p$ |, i# q" ~0 T5 l) j1 i{! y, d7 `$ M5 }: n7 k5 m
    public static void main (String[] args)
6 _- Q7 S3 h1 Y            {
0 O; m! d0 c' n3 }                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable: W, r# g0 s. p+ ~1 R
                ProgramCompare reached1 = new ProgramCompare();
$ p: M5 ?* x3 z$ G/ z                AuthorisedUsers reached2 = new AuthorisedUsers();       
' {. \8 o% W  h1 j4 G. ]! P9 W                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
- W0 c0 E* C/ q& x2 ?( f                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
. k. M; |! I& s" y; P- I        }) B) y0 k* v' k8 g
}// end of class ProgramCompareMenu; s8 O( d4 k2 a* S! Y3 ~
, U9 e' \  G2 j* q  @8 `. J
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************: `4 I% G7 Q3 Y/ F2 R# ]* L
//          AuthorisedUsers.java          Provided by: DRS
+ ^* ^2 j' Z4 C! ^//               
" O  }+ T7 B# M# F1 w% K; `+ A//         Program shell for Assignment 2  D8 j. d0 i# Y# s' j2 L
/// N- u/ d0 m3 x6 b) z% A
//         Represents facts about an AuthorisedUser; n4 R+ L" s% N' O; V
//********************************************************************
' z$ u; ^: _/ U4 {& a" |9 ?+ I: k) c& A( ~; k. D; {9 _! U
public class AuthorisedUsers
* _$ g1 G* k' g! z* K    {% a$ t- h5 `) F  }

2 M) |& U7 [$ E. O& j- E        //-----------------------------------------------------------------! x: e  S: e5 l( [1 k; ^* J
        // Constructor5 j2 Q) h% Q% {5 e. f
        //-----------------------------------------------------------------
6 }) a  u# o/ N* j
# X& O* f# h/ o; \% b        public AuthorisedUsers()
5 r, D/ g/ Q+ p" e4 j1 |& y+ f                {
& G- j6 c, T0 _6 m3 o: k, I5 G                }
' w, a4 S' `2 [, h) [7 f& |
+ b% g4 i* \. ~  k5 j        //-----------------------------------------------------------------
2 v: e5 a- j# o0 G9 c" v        // Method for testing that class has been reached
9 j' v7 E2 I$ {4 z$ y        //-----------------------------------------------------------------       
1 M8 {. ?& R+ S        public boolean AuthorisedUsersReached()
9 x5 |# K( M: p* J$ p5 G                {
7 s# ?9 V" |+ R0 y                        return true;                       
. C6 t9 Y9 J8 ~. j4 y6 S                }
' Q" ?' a, w- ~' s3 Z9 C" @               
4 Y3 [# j4 b1 v4 D: Q    } // end of class AuthorisedUsers* E7 I: [: X8 i/ r  ?2 m
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming! S' Y8 B  n3 E# O5 a
Shanghai - 2007# B3 y1 k$ p3 h, H: F
Assignment 2
* z/ X1 w3 [9 H# K% A- ODeadline 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)
6 [2 [. D5 |' E0 ]4 F# Y1. 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.! K: d0 v; h9 a  B8 K
The staff must be able to:
" `2 O' R$ [' C' t# e Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
  S' p' m" {. B( O1. 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 X' q4 Z3 f# _6 G. B* r* D* b5 \ The interface should provide a menu so that the staff can:
1 d% [: I* v  ia) Enter the names of the two Java program files to be compared7 a3 N% O# n. G; n8 q' F5 G: O" t
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.! {4 B& \0 M. H4 Y
** 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).
: z1 ?+ ~2 ?8 m  kBSA104 Business Programming – 2007: Assignment 2
  m0 q; h3 n0 P0 bPage 2 of 52 b. x+ Y7 @/ V+ P
b) Print out to the screen all the lines of code that are the same9 @, X9 l% E' q; u) c
 Include the name of the file and the line number of the code being printed for each of the two files/ ?4 m3 ^. Q+ L7 C
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared6 W/ D! p$ {7 @2 O% a; D3 c
 the name, username and department of the user
. [( @( W2 I3 ?. _' e/ h the statistics of the comparison
5 _$ }5 Y0 I: v0 W- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
9 S2 a0 {- {! F8 q the recommendation for further checking; m$ g4 r" t. x8 o, y  H  Y$ G
- 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 closely4 u9 @- b, M( d! U
 the names of the two files compared
6 G. O8 ~* y- S1 A9 ?4 i! `d) Leave the program (exit)
8 k# A5 V; U8 S, KThe ProgramCompare class: (Total maximum 20 marks available)
* S& F4 V9 G$ S" t. b) G2. 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)9 w3 K' @0 t+ X' o6 a
a) provide an error message if the files are not found or there is a problem opening them
+ v1 T' z- F  a" d& V4 y, bb) compare each line of code& `) K1 n, s' E5 A
c) print out the lines that are the same
, Q! u; R, y# X4 ]d) count the number of lines compared / lines the same
' e& D5 V9 m: C' f3 }4 Q6 j& j, xThe AuthorisedUsers class: (Total maximum 20 marks available)
2 \+ p3 q# E0 [- Q" U: Y3. 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)
' G) o& a5 l8 E" C, I$ J" i4. Provide methods to:7 `  k3 O& U, u/ ~! v
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
. L, @$ s; f$ H7 g' R1 y% jb) return the name of the authorised user$ S. W2 N; Q! y8 Y5 t) G8 a
c) return the name of the department of the authorised user) j% A: t2 V3 y5 [
Individual Data (Maximum 20 marks available)
& J' _' H+ `9 t) j( C: f! M0 m0 j5. 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.; T8 P. {9 P) i" k- m6 m  l  j+ y0 V
Documentation (Maximum 10 marks available)
( h3 r3 k4 |: [, a6. 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.5 i0 B" I2 v( p1 v
BSA104 Business Programming – 2007: Assignment 24 _+ w2 j- @* Y! ?+ X# y/ J
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了; ]" ^" [! g# I; N6 j9 m9 ?! s
不过你要翻JAVA的类库说明。你有下载没有?
. D1 b% d9 n1 ^" z6 G+ |5 ~查询关于对比的函数。貌似关键字是contrast,还有compare
6 t2 V: @) b" a9 d  _3 a8 u
) i/ P7 x$ n1 D% Q5 ?; k& c[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -9 b6 b4 j! R+ B$ m; k
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。1 j7 ]# Y# U) a) z
可以下载到的 是 jdk-1_X_0-doc
! m  Q- P0 a1 A9 [9 v
/ f, e5 ]8 E9 Z8 [5 h[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-23 09:56

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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