找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1481|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 8 f- N7 L ~3 r) `" M% B6 K6 g 4 x' r1 H! ~9 o0 A
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
* ?& _+ r. u2 V/ a2 p. P( D//  ProgramCompare.java         Provided by: DRS2 |5 j% K5 R' j7 d
//9 w* J! [- L6 j6 J
//  Program shell for Assignment 2; s- e0 x6 V; Q
//* G/ |: q6 t- W* D# @6 m" k& _! C
//  Compares two text files line by line0 D; p# K* B7 A$ x7 ~, E! t
//*********************************************************************5 G- ^, N# F+ t9 h  t
0 c$ A# X0 Y% P( Q" w" d
import java.io.*;5 f2 M7 }; O/ D# z0 n# U) K

$ z/ S9 W9 @7 f7 P' Bpublic class ProgramCompare% ?' G: o- [4 }. a
{
% l. ?( q5 A, w6 g! C        //-----------------------------------------------------------------
% g9 q% s( q- N' D: J        // Constructor
3 {/ Z  E' k0 j' S# X* b* f0 v4 X        //-----------------------------------------------------------------: a2 V$ k% g; }
        public ProgramCompare()
; U7 T5 u# [1 N1 y        {1 r4 p1 q/ L3 A8 k5 I; t: D1 h1 C
        }
" i; S) V# o5 g1 q
1 B- n9 C* \. p0 U6 p        //-----------------------------------------------------------------. B" V. Z: j& u  S
        // Method for testing that class has been reached
0 y3 V; [' g0 g- M! h* J        //-----------------------------------------------------------------        ; f+ p/ [+ c: b# U1 g: e/ K# z

6 Z- B* L8 H' W8 c) B0 w1 Q, |$ O        public boolean ProgramCompareReached()         4 x" R$ b; D1 |
        {
. X4 }0 _' t3 ?6 M2 r0 e      try
( V" P" h- X  X   {           e& ?7 X/ F0 g" I. l; Z' e
                        & d, y) P3 k) g/ G0 Q
                //********************************************************************
. E% I; t, `  L. @# O                // Try-Catch Statement is used to handle exceptions - such as file not found 0 ?# X) N6 y* K5 u9 Q1 c: G8 v
                // Reading the files will need to be placed inside a Try-Catch - just like this one!) R# D. ~/ n" g# j: ~
                // For more information see page 534 of the textbook& E) J- J  f2 R' K3 P- m
                //********************************************************************* a( Q, ]; D- D$ s+ o* [
                    
# D; ]% M5 v) H( x* q        }
) N8 F  `2 @" g  j: ]6 N             catch (Exception ex) // Exception caught here and message displayed to the screen
: i9 H' l- \8 T) I4 |2 H          {
  D9 e4 T9 \7 ]                    ex.printStackTrace (System.err);
  w! M- v7 p/ J2 Q  j           System.out.println ("Error message goes here"); // Replace this error message with your own          9 X' _" ~# w( V. @  e  u- I
        }
( w+ N* w# H4 b& D/ z                return true;
8 `2 Z$ ^8 k: T' k) e        }
! ^* R' X; m5 W' u4 J' |; k$ }9 a& J" U1 R+ M
} // end of class ProgramCompare2 q# a9 D9 t' U7 f5 R5 l

: f' l  l% l: s+ `. s  ]//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************5 q* D- ]7 r( U& V+ I
//  ProgramCompareMenu.java    Provided by: DRS
0 a: E8 K: M7 V//, _8 J7 d4 }3 L0 [1 n
//  Calls AuthorisedUsers.java and ProgramCompare.java
2 d3 e  t+ M$ c) U$ [8 ]* U//
; b- f$ u1 |7 C2 U4 {- @4 e9 @//  Driver shell for Assignment 2.
# c  D, E8 s# y+ h: Q9 L//********************************************************************' D: b# F$ K. B, S
' l; N9 {) ]) l' Z9 d8 |6 d
class ProgramCompareMenu- f" }1 C! M) N) D
{
, ]( X! D! [+ [" _4 k" C& Z9 R$ R    public static void main (String[] args)
, y4 s9 y+ u# O8 K& B            {
- E/ {4 @# F2 M2 ^" z; V  J' e& v                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
! H- r) y. W& l8 e0 t4 P+ `                ProgramCompare reached1 = new ProgramCompare();
! X/ }) }5 W+ r" J                AuthorisedUsers reached2 = new AuthorisedUsers();        * ]/ c9 x. w0 Y" g' R
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());- K/ Z3 @; f1 z* [
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
5 G% m3 W. h; j5 u; A- u        }
) K* u5 x3 }) ]  |4 [6 ^}// end of class ProgramCompareMenu% h. u$ n. t1 R7 L  ]. u0 s4 @  ]
3 s* g; ?( Y6 R. z1 z
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************8 `" A  B$ [0 n' h. B
//          AuthorisedUsers.java          Provided by: DRS3 }" }, R( m8 |; ]# r, W# U2 ^! g+ y. r
//                ; `3 G6 Z( p; e
//         Program shell for Assignment 25 i- A& d) i* i# q) E
//0 ^. w) g3 K* U8 S& ]
//         Represents facts about an AuthorisedUser) r. ?. p9 y8 |/ @
//********************************************************************4 `0 R, A! h. e! B2 ?5 {' k- X
8 q* \+ h- C& c! f7 z
public class AuthorisedUsers5 \! j1 E1 G* q/ W4 X& |: J
    {
, W* l( U# B0 s) U; y- c; }* U) P( N+ b! ~( V# r
        //-----------------------------------------------------------------
. y: p; l- i8 X5 y% |4 m( b        // Constructor
1 t( j9 D8 X* c+ ~) V: n  h        //-----------------------------------------------------------------4 B  g+ D6 W4 J' X
% {) u4 E. M. n' J6 V; ?; `
        public AuthorisedUsers()* b% B3 r1 R( l2 Y
                {* m1 k! X1 O8 I
                }
, `3 o+ L& q/ O. o3 x3 q5 i2 n) G2 z9 r# Y* p$ C
        //-----------------------------------------------------------------* J, c# B8 x  c4 M% e* M; X6 s; M% m
        // Method for testing that class has been reached
2 |4 E* I6 \/ B, ~/ k7 m        //-----------------------------------------------------------------        " {  `. B4 {9 o  B
        public boolean AuthorisedUsersReached()' a' D- q/ x  K% G/ c
                {. x9 Z4 E+ D' u" B% G
                        return true;                        0 {( ^9 z. g  t
                }  v3 t. ]2 o1 w4 o, b/ W( w
               
: k" [0 d6 T: ?    } // end of class AuthorisedUsers' q% D6 r1 o: Y. T* ]) g
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
) V! |! n3 e$ ^& X1 [: G$ ^; ^. H$ yShanghai - 2007
' l" g. K* D( }* v, yAssignment 27 I2 t9 H1 ^2 E: O
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)2 S+ [4 I  g  k/ \5 D0 H
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.
1 H) X, J! F' C2 T" b, GThe staff must be able to:4 R3 K; {5 n8 u) b1 S* G3 x
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.& C3 ~9 E0 Q! N8 @3 M. l
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.
+ j: u3 d' J! d! u6 q The interface should provide a menu so that the staff can:9 ~) o( q! o0 B. T2 [/ s
a) Enter the names of the two Java program files to be compared9 k" U0 J$ H; P0 G8 E
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.. D5 Y1 H- O. B. o" |* I) _
** 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).* B. ~3 k/ c$ {2 a1 l* z
BSA104 Business Programming – 2007: Assignment 2# p, s" @. @7 p% u2 A' F
Page 2 of 5* [, ?! H9 o& u8 {( X2 `; F5 d
b) Print out to the screen all the lines of code that are the same1 Z# b. K6 k8 p# [
 Include the name of the file and the line number of the code being printed for each of the two files$ X9 q! z8 k: z6 K9 f- ~/ u0 t
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared) @  k! t0 G- [' B7 P
 the name, username and department of the user" T- M5 R8 O2 W9 T9 H
 the statistics of the comparison# Y! o* q+ c0 j! i6 s+ a, g
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different) ]$ Q+ l$ h- D7 M5 B
 the recommendation for further checking
: \, N4 ?, L' w  k! H5 G% A7 ^6 T- r- 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 closely8 `8 z- w4 j. c# D
 the names of the two files compared
0 w2 p. H% v% x9 [4 cd) Leave the program (exit)3 G) P+ z6 b# e8 U" ~: J2 I; k3 v
The ProgramCompare class: (Total maximum 20 marks available)8 y$ }/ c8 A4 ]5 S  R* Z
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); N' y  _; S* x! O5 |. y% u
a) provide an error message if the files are not found or there is a problem opening them& R( y: ?0 I$ g, E1 u! j/ T
b) compare each line of code8 ], x! ?( P7 R" H+ B0 G- K3 d$ l1 z
c) print out the lines that are the same
8 s* J5 H5 x) B/ U  I1 Wd) count the number of lines compared / lines the same$ D0 N" b6 N: E3 D0 D( @, Z
The AuthorisedUsers class: (Total maximum 20 marks available)' i5 N! b) m+ }
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)
- H& ?. f! E  o& ]) L4. Provide methods to:$ T* F! s* d$ g, |( |7 N
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+ B4 {! \# U3 X3 K: I5 D6 U
b) return the name of the authorised user
" {4 Z' ^0 P, U9 pc) return the name of the department of the authorised user3 ~8 I! `5 e, f9 m
Individual Data (Maximum 20 marks available)( K2 C7 z8 J$ |
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.4 [) S8 P9 Q0 ^3 @* _  z6 U
Documentation (Maximum 10 marks available)
$ x) Y: ]: _% c6. 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., L! f( W) h# G  u  B2 _4 g- c
BSA104 Business Programming – 2007: Assignment 2
4 p0 n) @5 h; n# q9 XPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了8 t! K. }  ]0 w4 \* n! ]
不过你要翻JAVA的类库说明。你有下载没有?
) K6 y; J& T1 V7 f( J. W) d1 P  W查询关于对比的函数。貌似关键字是contrast,还有compare
: i7 D, i$ S$ U5 }1 `/ g; g1 b8 }4 U  s
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
! p& E" x) p+ f, f  @; L% j痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。0 x4 V1 A& V3 ?
可以下载到的 是 jdk-1_X_0-doc8 r# p+ C: i, `

, r3 j1 E: o& f0 p[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-24 00:38

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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