找回密码
 注册

QQ登录

只需一步,快速开始

查看: 941|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急4 z" l H$ @! c+ G i Q , {3 M/ v3 F0 C7 j
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//********************************************************************** |9 s% k; g  V$ Y/ F% ]) Y
//  ProgramCompare.java         Provided by: DRS7 ], [! D( ~: Z3 u5 t
//
. x( M: e. d8 e//  Program shell for Assignment 2
. K2 c1 I5 D8 X6 \3 `. _8 q//2 y" h  w2 Z' {/ Q# M; f9 L
//  Compares two text files line by line
- q9 w. f, y; c! M//*********************************************************************
7 J! ]9 G3 O5 V; a' d& |: g. a$ }) @2 P+ M, x9 \5 m
import java.io.*;8 T7 K6 M) {1 L0 }  }/ ?

5 f/ g# }& k! [0 Bpublic class ProgramCompare
" S+ I' T: K. s8 }5 P# \- M" h{! H+ ?+ b4 }! ~) X! s/ X4 {' Z
        //-----------------------------------------------------------------/ y! o) u8 s2 v( h
        // Constructor7 g* k6 P' v6 t
        //-----------------------------------------------------------------, a4 R. W& E* p7 t: t) a- e
        public ProgramCompare()& y# ~9 I$ G% N) f
        {! L, w5 C( w& q
        }
3 _% Y9 R) G  I" e0 ~6 L
% L! h- G; q8 X        //-----------------------------------------------------------------
3 f- @& T& B+ M& i        // Method for testing that class has been reached" C% m: q5 O/ K0 R0 h, f1 O
        //-----------------------------------------------------------------        + X+ }- Z" i7 j/ N, D8 W/ R
0 c+ D$ T! h: V) p
        public boolean ProgramCompareReached()         5 g8 i" e" {* T3 b
        {
: L4 T% W. f+ h; v7 l      try + A% ^! `  k0 v4 j1 G
   {         8 I2 \8 C, V5 C* f
                        - g  ~* {4 Q2 Q1 _+ L" n
                //********************************************************************
7 h. s8 @0 ]- U. o& Q4 s. h                // Try-Catch Statement is used to handle exceptions - such as file not found / w) X9 i3 x* u; Z" U; @2 a6 Y8 e
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
. m1 _6 f* c- R' B3 I& n                // For more information see page 534 of the textbook& D# \# J5 l; {4 _/ R
                //********************************************************************6 ]* y! O3 o3 c4 P8 }
                    
9 ^3 k0 J1 q1 {: m+ L/ S        }. n( O/ U  @! Q0 C/ B
             catch (Exception ex) // Exception caught here and message displayed to the screen " K. ^: h' G3 t
          {1 l8 o/ g+ J. t  N1 w( h
                    ex.printStackTrace (System.err);
: ?5 z2 p3 D% R" C           System.out.println ("Error message goes here"); // Replace this error message with your own          4 q: N/ F! R- [/ f5 p2 t/ P- R
        }; m9 B2 ?/ f1 b4 M4 c5 p, K
                return true;6 f5 i4 f0 V2 t/ l
        }
; h2 g  L6 r6 |* R- U( S$ p$ t
! L9 O6 _' ~* [3 o0 \( F} // end of class ProgramCompare' d. ~. d. q: T9 e: N; \9 L2 V
$ F7 r" z& f  L& Y4 s+ i! L5 U# i# h
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
. w5 n! H; {2 N6 g  u  N/ a* |( Y//  ProgramCompareMenu.java    Provided by: DRS& Q9 L+ E- y& ^; z7 B. c; [
//
/ v: ~& ]  V( a2 l3 ]4 o//  Calls AuthorisedUsers.java and ProgramCompare.java
+ U- m( s9 o$ q3 N. J& N+ U9 A//& b1 [4 P  d. {2 q5 T% ~: a8 m
//  Driver shell for Assignment 2.- S7 ^2 \6 _; G! C
//********************************************************************
7 y: G2 v  H) E3 x3 D
) V+ B  ~/ h" Lclass ProgramCompareMenu
* S, ~8 t' n* c, z) X{
6 H$ B9 Y: W  W/ d+ L    public static void main (String[] args)+ R! k/ r$ [" q# t4 [0 v
            {
6 {& p3 i$ _! J9 z% ]1 S                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
) [- e6 `- e  R: P                ProgramCompare reached1 = new ProgramCompare();
7 H8 a. i) l; w# l9 R9 f! L                AuthorisedUsers reached2 = new AuthorisedUsers();        + k  n% G1 Y# x% x3 t# H
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
5 i3 }1 n& R1 [1 V                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
3 _) x  S5 H' C1 v: e% s% |        }! z+ b8 o/ _9 B" m- l% f
}// end of class ProgramCompareMenu
3 P: t& V) N) `4 ]
# h6 o5 i1 F0 ~$ p! W% o. L& |//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************4 o  I! q; g! m- C  ^+ N5 O) X
//          AuthorisedUsers.java          Provided by: DRS
5 S  n- U2 y) H6 B//               
! h) |6 n3 P0 x/ e//         Program shell for Assignment 2
( n. D$ J; p8 W8 g7 J, \//
# |2 @) W& [# B//         Represents facts about an AuthorisedUser
. |6 j4 J* |* V//********************************************************************
4 [) `8 n* c/ v4 b% d) H
$ R4 P* p! H( m: V4 Kpublic class AuthorisedUsers
/ X0 L0 S# B3 n, R0 F    {5 E5 l8 T4 b( ~' {- W, \+ z8 q1 z- r
$ r3 Z1 o- f9 t& R  n- A2 y! T
        //-----------------------------------------------------------------
# \% P9 g% Z( q2 |. N        // Constructor7 _6 ]" I" ?3 x8 K/ B, l0 i' o. f
        //-----------------------------------------------------------------
, `* M7 I3 O0 @0 x: P9 b+ l, D
" E6 i" ~$ k5 S% \# Y        public AuthorisedUsers()3 f7 z2 V2 X: k  s1 l- B* u, e
                {
) e* x+ |7 i# ^& b& V/ L9 N, z                }
$ X& G$ g* Z  u
& H8 B9 x1 N: G0 Q" K0 b  L        //-----------------------------------------------------------------
8 I6 b3 J# F+ l; c7 `8 K( F        // Method for testing that class has been reached
9 X! h. L- {, z3 i' ]0 m; R        //-----------------------------------------------------------------       
& {2 w$ t' J) I% z1 e& }: n        public boolean AuthorisedUsersReached()7 f, ^* |1 M7 n) O; Q
                {
1 o+ y% ?0 d; h7 ^0 O$ T                        return true;                        # o% w  \8 Z/ W% K( N( L( Y. F6 L
                }* q! y6 c9 ^* m+ v% G  u& c
               
# d' x) N+ V+ J: i9 h! T1 B; d    } // end of class AuthorisedUsers! ^4 S% v/ F% r% c8 I- x
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
$ n( Z7 R# i; p/ S, b6 F; |Shanghai - 2007
& F$ Y0 T/ Q, JAssignment 2% g) R3 [+ C/ 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)- t! Z, W4 c3 y# V3 M* O
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.3 l- o7 o3 S# r, h. q
The staff must be able to:
+ ?: @% ?; F0 e Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.3 d6 R) ~' P- O- i) y. {3 P) V0 O  s0 K
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.$ L2 M, H1 z; L' V( ~
 The interface should provide a menu so that the staff can:
5 v0 d' u7 ?; B0 Xa) Enter the names of the two Java program files to be compared
" B7 w; f# z! ~- O% c9 }" t; _ For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
, k2 `0 a: D* {6 ]# z** 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' v- g* |0 R$ x/ u' u' _. {* BBSA104 Business Programming – 2007: Assignment 2
; p) c. c2 G. D, B$ p2 uPage 2 of 5- J* B; W' h" M' Q# u9 q* I, {
b) Print out to the screen all the lines of code that are the same, I( u/ n" @' E$ {7 _
 Include the name of the file and the line number of the code being printed for each of the two files& @; Y) n$ C: K# ^, ]/ A' I
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
5 w7 \6 P/ F$ \) w6 Y: a- p the name, username and department of the user4 ]# ]  W$ M' C5 O- E2 @$ W1 s- U0 O
 the statistics of the comparison3 U) J6 g* S' w6 \9 M
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
" n' L2 p7 [1 R the recommendation for further checking; W2 J+ P7 q8 K5 x+ _2 ?% n
- 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! i& F+ `9 H: D5 @& X3 x: K
 the names of the two files compared
# A: q# l- P4 ~) Id) Leave the program (exit)3 U1 {* t# R- s) k: @
The ProgramCompare class: (Total maximum 20 marks available)
* ^( H% O8 u: {9 k$ j' K7 B  o8 w2. 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)
) `' A8 J6 d: [3 L8 Pa) provide an error message if the files are not found or there is a problem opening them
9 ]9 J/ U4 s  `b) compare each line of code
3 P% t' m& O  B- a) @/ Wc) print out the lines that are the same
/ \+ c1 t. Q$ X! A, zd) count the number of lines compared / lines the same' `0 B: j2 V3 m4 J
The AuthorisedUsers class: (Total maximum 20 marks available)
6 ^' V. v. d0 c3 h# b: \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)
, c/ I# @: _: Z3 h+ a4 S# O4. Provide methods to:! H% w* i' z( P% z
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
; }) X8 l) m1 n4 w$ G* J: s0 U' }8 Nb) return the name of the authorised user
7 y7 M) M1 S+ Wc) return the name of the department of the authorised user; o0 L" X5 \. r( m( y
Individual Data (Maximum 20 marks available)9 ?: H8 M. U3 e4 t/ N& F8 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.& X4 g0 o0 w& K: h5 H
Documentation (Maximum 10 marks available): _! v( I& @7 L6 z  N! `, F
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.
" G+ ~9 t' ]! s. E3 F' j; L3 G  kBSA104 Business Programming – 2007: Assignment 2
: N6 Q+ a: D. @& [( J) aPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
- m) E) Y" ~; W9 }不过你要翻JAVA的类库说明。你有下载没有?
0 M) L8 }6 i* l8 Y- F  n查询关于对比的函数。貌似关键字是contrast,还有compare. G) |% Y8 ]- v

3 P( X; H! ^4 V( L[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -4 t4 I2 ?% y; v7 K' E
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。+ |* {' ]7 Y6 n, i. J/ V
可以下载到的 是 jdk-1_X_0-doc7 Y. w6 ^2 l5 A( B9 ~3 H$ Y

5 a. ]  A, E* R[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-14 16:57

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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