找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1212|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急9 n# w' w- s& x3 h* V: c/ } & b- p. m2 R$ P
回复

使用道具 举报

 楼主| 发表于 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 r" e; ~2 K, u( m) J* n% E( l
//  ProgramCompare.java         Provided by: DRS
- G( {; G3 x2 B' t0 g; u//
% X2 y6 {6 f$ J' V//  Program shell for Assignment 2
+ H# @( [) ^* S5 h" B/ U) K//. D; ?- d* R( W( `
//  Compares two text files line by line7 q4 X1 Q* G; U+ g: t$ @
//*********************************************************************
) c& {- ]; |# h5 J
4 P. n, |) }6 m* Qimport java.io.*;
# o/ T) T- ]: Y+ H; S3 i- ~6 ^6 b
public class ProgramCompare' _% K7 z+ Q4 L' n' W! D
{* ~6 P1 j2 J! t2 ~
        //-----------------------------------------------------------------
) ?3 }9 M) [+ k8 u' Y3 `        // Constructor
2 G, R0 X+ ]; o0 [# y  T* i- |* S, s1 f. K        //-----------------------------------------------------------------
- B# V6 V" s  I7 H        public ProgramCompare()  e# v9 j7 Z( @3 K' y
        {. P, R; }: y, i2 j+ R
        }
+ R  H6 m# w8 H
3 B( w3 _! N5 p4 H& ?* m        //-----------------------------------------------------------------
5 ^0 v' m3 ?& I1 c7 Q3 m        // Method for testing that class has been reached
: X3 D) R! y7 ~2 `% e        //-----------------------------------------------------------------       
' B1 t/ n9 u4 O1 S4 [9 M5 ]% C* _. W* C+ V6 c% M: t, a0 _4 W
        public boolean ProgramCompareReached()        
( H8 f" m9 H4 o* W0 y  s! D. H        {
9 I+ m+ l9 I4 g: m      try
: Q- [4 y- u! P5 U' ~   {         / @# C0 p# Y, T3 L- o- j7 o
                        ' [$ D1 ~6 C( D
                //********************************************************************) Q- u7 `+ ?9 K' o% R5 h6 N
                // Try-Catch Statement is used to handle exceptions - such as file not found
0 w. }3 t+ R* e                // Reading the files will need to be placed inside a Try-Catch - just like this one!) K9 L9 }$ y, {; J7 G
                // For more information see page 534 of the textbook
4 l( \% A( N, v  ?                //********************************************************************" N; n8 w$ q, x, G! T! _6 p
                     , X) P7 ^; V! {7 E; Q
        }# z6 S7 ]0 f/ ]/ e  u2 {
             catch (Exception ex) // Exception caught here and message displayed to the screen
" ]8 I$ P6 z& R9 }; o7 P3 t          {
: a" Q) k# G+ m" [& T                    ex.printStackTrace (System.err);4 D, P) T& b  f
           System.out.println ("Error message goes here"); // Replace this error message with your own         
4 R+ @* h# {: ?        }9 ], }8 N) E! p
                return true;! Y! X5 I$ {6 v7 e0 |
        }  V- B+ s/ t. r, K
: k, I+ \7 y: \/ g" n: X' E; m
} // end of class ProgramCompare
4 L' ]3 t; U) Q0 K0 |  R9 P$ j
; N, G6 M5 c3 g1 o1 j//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************; A& H/ [; H9 D+ A+ L
//  ProgramCompareMenu.java    Provided by: DRS4 U  r& P/ {( d6 l4 @' }* r
//
2 O& G+ D5 {. z8 _3 S, T' F/ I//  Calls AuthorisedUsers.java and ProgramCompare.java
, z$ V/ I4 G/ r7 u3 \! M, H//
$ _) L/ i& n6 L- K# ]- H//  Driver shell for Assignment 2.3 d" b- N0 _1 l% H; G. n
//********************************************************************
! U% N2 R% u- w# E' [
! w  l7 v2 u! u4 tclass ProgramCompareMenu
- r7 H# L: o1 C  T% y0 |{$ d' y6 T9 U1 ^# k6 M5 j  D6 i7 s/ Z
    public static void main (String[] args)" t- R# T2 r: ]4 o5 d$ \% C' a) y
            {
" h* x* o: i* y( `* H5 k" e                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable8 i+ H2 m% _% y" e3 F7 y, _
                ProgramCompare reached1 = new ProgramCompare(); 1 T7 g" j0 p" p/ f" ~  h+ L
                AuthorisedUsers reached2 = new AuthorisedUsers();       
5 l' i0 A$ U! w2 o# S5 S6 M                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());  t! g" G9 h2 `/ C3 M
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
7 q. t9 r6 B- P0 W- `9 a9 m        }( ^$ r/ z0 j# y, _- Y9 p+ ^& W
}// end of class ProgramCompareMenu
$ V! A1 d1 R7 D  k
4 e: }8 T% U2 P; w//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
1 U5 Y; ?6 @% ^; V//          AuthorisedUsers.java          Provided by: DRS
  M) L& i8 W. `) Z//               
# }' u" G% f  L1 ^$ Z$ q: J//         Program shell for Assignment 2  u9 }1 [4 x' E/ J- L8 C2 }7 P
//1 D7 m+ K- \% z2 x! J4 d
//         Represents facts about an AuthorisedUser, S& O4 p% e* F( o
//********************************************************************
0 N9 Z8 `8 `1 i& ]3 L, ~9 g; u# _, F8 {2 n# C3 g
public class AuthorisedUsers
" X+ l0 S# L1 @& E7 U7 o5 a    {
4 P0 v) q8 f# y% |' R
* o4 M/ G8 z; R! y; r        //-----------------------------------------------------------------( I3 r- O8 u; ~  c1 K
        // Constructor
" ?/ [$ f7 J. _        //-----------------------------------------------------------------# j7 k4 J* Z# g9 s

- G) u' @. u& s  G        public AuthorisedUsers()' W4 X/ i. _% B! a
                {
" u2 p) s- Q6 N6 _                }
5 t5 Q1 S) Q1 [% E
5 m6 ~. o" h/ M1 Q5 _4 v8 O, N0 k        //-----------------------------------------------------------------4 }9 v; e1 c" C, |, T- P
        // Method for testing that class has been reached# |/ o8 I) x: f8 |5 @) P
        //-----------------------------------------------------------------       
( E, k7 w9 G! g; U. O3 C+ o        public boolean AuthorisedUsersReached()% F% L& b9 J4 t9 o. R8 ~% g; }
                {1 H3 U( U. m8 P5 [9 p
                        return true;                       
" E& Z+ D" n" d; ]                }/ h1 {9 u8 l: r& G0 u
                + W) e$ O6 G3 m  X0 I
    } // end of class AuthorisedUsers
% j3 x  {* D2 y$ J//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming; ?+ p, R- b- V! c
Shanghai - 2007+ S6 e9 P4 [, F% U7 {, o0 V
Assignment 2
# h+ n% q# F; S9 `' HDeadline 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)
$ c1 a2 i  r" `) a* 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 `; P& N+ P. G/ G$ A. MThe staff must be able to:
6 ?. ^* Y5 v0 U+ z Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **., f) ?. h. v# [
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.  [" l+ P1 ^5 D) i* b6 q) z
 The interface should provide a menu so that the staff can:/ e/ p& j. k+ ^; Q
a) Enter the names of the two Java program files to be compared
* c* W9 U, ^- u* N For this assignment, it will be assumed that the two Java program files are in the same folder as your program./ p3 T8 x1 D, B; I5 [. l
** 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).1 {8 `% r3 L' e* [( L3 }
BSA104 Business Programming – 2007: Assignment 2
2 l0 c' y2 _. j# x* ?Page 2 of 5
2 t/ n' P+ v. V1 |3 a1 i# a  Z4 fb) Print out to the screen all the lines of code that are the same' A2 X$ O; K7 D4 G! ]
 Include the name of the file and the line number of the code being printed for each of the two files" r: {, S; O$ U% q7 W( j
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared1 F' g" E+ Y, M, h4 D; p  C
 the name, username and department of the user
/ z1 K$ z9 ~7 C4 F the statistics of the comparison  \) v" Y3 h( t2 c1 `- I; g
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
% u  N3 T3 z  G* @0 {' x8 w the recommendation for further checking
& C- b, e+ _3 l* S/ N9 b- 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
' K, \6 i9 ?* m: T% N1 r the names of the two files compared) Y; d8 U& W: ]+ G
d) Leave the program (exit)1 R8 e3 T; y: J# u# g* c
The ProgramCompare class: (Total maximum 20 marks available)
, x; q5 h6 r* [. K2 h2. 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)  j4 U. ^  z9 S# l% I( H4 ]
a) provide an error message if the files are not found or there is a problem opening them
0 s8 e5 g2 d+ M" S/ yb) compare each line of code9 c5 ~! H# l5 S. O- `( r6 W& Z
c) print out the lines that are the same
- L. m9 a# k+ Z/ p. U+ Rd) count the number of lines compared / lines the same# s" I& m+ t* `0 k* ]& q
The AuthorisedUsers class: (Total maximum 20 marks available)
% T' u* a# W5 E8 G8 k3. 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)/ N4 v2 t1 e* B- X$ I% ~/ M( V
4. Provide methods to:
# z# C8 T- V+ p& I2 k+ Ca) 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
. p: x/ m$ n- z6 h$ m; G- hb) return the name of the authorised user
5 L& W. z- O! kc) return the name of the department of the authorised user3 \  `4 V# j* |9 N( m
Individual Data (Maximum 20 marks available)3 g+ g0 n& X4 {5 B/ g2 B) X+ a# S
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.
/ y, J; P4 `* u7 ^5 c) RDocumentation (Maximum 10 marks available)+ c- I4 r  x+ e8 p; K3 _( N
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.3 x. L, G8 r- m: c% R& ?0 Z- g
BSA104 Business Programming – 2007: Assignment 2
, c: g: P# b: j! a; iPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了8 R! z; g0 r$ ?4 j2 e
不过你要翻JAVA的类库说明。你有下载没有?
- d( G& Y. a2 N0 c& N" \查询关于对比的函数。貌似关键字是contrast,还有compare4 U# s, }1 @, p+ u& [0 X0 f
  |" r' M' [; _7 W$ A
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
# s- f' Z  A- h, n, H# ^痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。3 S8 k6 T) y* F4 S! A1 s
可以下载到的 是 jdk-1_X_0-doc9 U; ]( P& ]/ R% d( h

, g; q# t# W! |9 @/ ]) i, Z[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-19 05:11

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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