找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1511|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急& t2 K! H9 B) Z: t& l2 @: i; b) D) l$ _ " z3 ~' i8 Y4 I( f7 _2 h) U
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
) o+ V( |& I: z( e) k, V% _; m//  ProgramCompare.java         Provided by: DRS' C1 d6 U3 `0 U9 S. c1 l
//9 V, Z  z; F( }; F2 x7 s1 I4 t
//  Program shell for Assignment 2
, G$ ^& J1 i' U//  f$ X  c1 \: q# A. k0 e
//  Compares two text files line by line5 V2 ^- t$ `; _' x. t. S6 W/ k
//*********************************************************************
8 h1 ^" \1 y# O& L* c, I6 F! l2 X' C- F: C( d4 f
import java.io.*;
5 h# Z4 {+ F0 \7 q0 Z  ~8 [
9 j( X. _1 u* P; v; L1 lpublic class ProgramCompare
/ {5 i* K# T" z8 I9 P{, G6 y( ^) |8 U  b' S3 d; S
        //-----------------------------------------------------------------
0 L% m0 {, G0 i! D( V1 v        // Constructor
2 C3 ^# p7 q) e2 p        //-----------------------------------------------------------------
. z- N4 w0 O# r' m9 E        public ProgramCompare()) A! {+ c0 |5 R$ [0 v! [
        {
* x5 G2 l3 V6 P0 ~        }6 M! N8 X4 F8 \! O
6 X; @  j7 B; S% T. _
        //-----------------------------------------------------------------
& ^) v! @6 B# [0 {- {# f        // Method for testing that class has been reached, `7 c* M# Q/ @2 f5 ~
        //-----------------------------------------------------------------       
; g+ X5 s, d3 R4 B& \" e! \( h9 B
        public boolean ProgramCompareReached()           B/ y4 y  h9 ^! ^& K( c
        {% H+ Q; ?# f# @" O
      try
2 l- E- h! c' f/ ^8 R9 i! D8 p   {         6 Q! [6 v5 }9 ]6 T
                        0 U0 {2 y& N; M+ }9 Q8 r
                //********************************************************************
1 ^8 A% e, @7 N* ~% N, w; ~+ Q                // Try-Catch Statement is used to handle exceptions - such as file not found
; L' `& I5 I' K& `- x- V! g                // Reading the files will need to be placed inside a Try-Catch - just like this one!6 I4 x* X* ]" p& z; m# A
                // For more information see page 534 of the textbook
& T* {3 M) D* x3 z                //********************************************************************
! U$ ?# G* Y$ i0 C                    
+ L0 H+ }* D! g( S( k( q9 o        }$ u. G0 O5 F* t4 _) T1 U
             catch (Exception ex) // Exception caught here and message displayed to the screen
: M( f5 k1 f- i, E( R          {/ A3 p% r! R1 R) @, `
                    ex.printStackTrace (System.err);& H8 R# m* E  ]/ o" J5 a; c* y' J
           System.out.println ("Error message goes here"); // Replace this error message with your own         
" u. c: h& G0 y        }# p7 N7 a! S& v% Y6 _
                return true;  W/ T3 j; Y/ E" O6 z
        }4 X4 f% u! |2 o! H
8 U7 y8 X1 L4 U% O& C& R# y* x
} // end of class ProgramCompare
$ `0 f: a( n( \8 J- X# w6 `
/ S$ `% O( k5 V1 T+ {% E//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
. G+ y0 G5 W7 z& C//  ProgramCompareMenu.java    Provided by: DRS
0 Y7 C* w" l, m4 \1 ]5 ?  x//
* M& X/ c1 p9 ?6 Q. F5 W9 Z* ~//  Calls AuthorisedUsers.java and ProgramCompare.java
- ?4 R+ d. B( N0 @$ K//
+ p9 h8 a* K) |1 s6 ]' q//  Driver shell for Assignment 2.
4 o" j8 j! L6 z% T. _. {5 q; ~//********************************************************************
' u6 c+ Y2 f1 i: x) w3 N  J8 x, {
! g2 b6 V5 H+ q  B+ Uclass ProgramCompareMenu
: n/ p) L- m1 s5 a8 V{
; e" @% G) a& ^: o. p; @    public static void main (String[] args)3 f. J" N$ |0 g5 l# \$ J+ U; r
            {
2 ?3 D" J2 }0 ]% _" R3 r! N                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
+ o+ \$ u& ^9 o- P+ K) q, }                ProgramCompare reached1 = new ProgramCompare();
3 P9 G: R' M5 u0 ^                AuthorisedUsers reached2 = new AuthorisedUsers();        7 {. u. X( a* `. |/ x
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
' m9 p2 ~- y# X: V- l                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        # G, ?* \! N. N4 P* W
        }! K4 N1 Z8 P, g: j5 T7 L
}// end of class ProgramCompareMenu
, h; G, i/ v/ U2 U
7 p6 N- ?4 G1 A$ p4 Q//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************: ?' |4 _: ~# X4 ?& g7 ]5 w
//          AuthorisedUsers.java          Provided by: DRS* r# @, N( Y! m& K: m" P* ]
//                / U& d1 Z/ p7 [, ?+ Q
//         Program shell for Assignment 2
: n& k. H, ?4 I4 _% D  t- p( ?( ^//
3 G) F/ |, {! A& x//         Represents facts about an AuthorisedUser" q1 {& m) E$ W+ e4 i
//********************************************************************
4 P( ^+ G7 k( a8 r0 o( [" f" Q' F) d: O  H' o7 q& v5 ?/ l4 i
public class AuthorisedUsers
& w! Q, H6 {. u5 r1 D    {
+ T% J! Y) q: W) k$ o$ i, {
6 a9 Z! X4 s, c; \        //-----------------------------------------------------------------
0 G( y- j6 k5 N* t3 T1 u3 q        // Constructor
/ T: g! Y: `. |        //-----------------------------------------------------------------
( u" ]" a; t! ~
6 b; C0 ?$ u3 F# o' h7 F6 c8 Q        public AuthorisedUsers(), p6 i( a# L; |. Z5 h* e
                {
9 B& V  t1 Y* x3 K* M                }9 K- y6 h0 g6 ?: I

% p  I3 t1 e) m7 y2 ]+ |        //-----------------------------------------------------------------
) ]: {+ f+ R2 q8 ~: w+ T, c        // Method for testing that class has been reached7 O) r) ~' ~, E/ ?& O' z
        //-----------------------------------------------------------------        . Z- a/ f5 w9 R( I3 l5 g! ]9 Q' G/ e
        public boolean AuthorisedUsersReached()( E% m5 P# N5 X/ f! j% i/ p
                {
$ t7 ?- V) L* @! T                        return true;                       
/ K' A, T% K8 ^! T! ^                }
& Q! ~( e- ]/ p# v                . w5 L; v/ F1 Y
    } // end of class AuthorisedUsers  F! m1 S8 x$ `  ~/ Z* e
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming& i9 w2 ]) q+ R" |& K7 |" M  c
Shanghai - 20072 S- T# i' r/ @# h
Assignment 2( u: ~5 r# m( i+ n- Z, h2 W  U
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)9 |) A6 w, ~9 n, P" f
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.& A; W7 y% g# p' \
The staff must be able to:+ u: h6 n, G# u
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
/ A) W9 e- S6 \4 S% G1. 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.  M/ k& S, R& _- f4 R) p, p  K
 The interface should provide a menu so that the staff can:* K+ m9 D1 {9 |# q5 Z8 M
a) Enter the names of the two Java program files to be compared. A3 c8 ^1 H9 i( a; S( ^& y  j
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.$ i+ {" }) X7 k! l4 ~5 x0 _2 S
** 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).) G+ |/ s+ O! h; {9 o; x
BSA104 Business Programming – 2007: Assignment 2
6 y4 L" V2 m9 _. J+ w& [Page 2 of 5$ {6 l0 ?, x* O' H6 H6 j. N6 D3 ?/ c6 H# x
b) Print out to the screen all the lines of code that are the same5 d$ e8 j4 m8 U/ s% C/ A5 [6 }2 N
 Include the name of the file and the line number of the code being printed for each of the two files3 ?0 w  s; M" \- d. z+ e/ d
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared6 O0 ]6 x6 I! `3 e0 D3 B$ U
 the name, username and department of the user. J' v9 a6 N9 g9 ^
 the statistics of the comparison" `4 q- f$ H. a  J
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different! U) E1 H% K! H/ ~- e, N0 s: K% B
 the recommendation for further checking& g( ^1 Z- X" ^8 a& q
- 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
. S5 @! t. Z1 b the names of the two files compared
. }6 |) E+ D$ b9 O  K+ Cd) Leave the program (exit)
. {4 S) y/ t7 V" |# TThe ProgramCompare class: (Total maximum 20 marks available)' t: p# m7 j$ w- i  Y9 m1 D
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)
: \4 P4 I! l7 C3 j) j" A' ma) provide an error message if the files are not found or there is a problem opening them# W; g8 @$ J9 }0 U9 C) w+ |, o
b) compare each line of code
5 R( `* B; J. M! A7 i* Xc) print out the lines that are the same" Q/ E% T: {7 {: f
d) count the number of lines compared / lines the same) C# S9 U- Y) z
The AuthorisedUsers class: (Total maximum 20 marks available)+ `: l# W, p* a2 F" I$ c* 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)
5 p+ [, O9 m9 g- j4. Provide methods to:
. A+ r3 z0 g0 \: V4 }, ?+ @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 match9 C: O8 B/ U: q
b) return the name of the authorised user
, C' g( h+ `5 j' ~c) return the name of the department of the authorised user4 T! t) k6 A. H* g4 f( T
Individual Data (Maximum 20 marks available)
* ^- Y) |8 A2 l; U- r( Y7 C5. 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.
+ i* S1 Z& ~/ Q7 x  NDocumentation (Maximum 10 marks available)
6 G7 {8 m) |! [6 J6. 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 j0 ~+ f0 f3 D4 C7 ABSA104 Business Programming – 2007: Assignment 2" \* a  Y; U" U' L6 K; B
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了# C2 U& P6 x5 t$ z* ]5 o, O! ]' t
不过你要翻JAVA的类库说明。你有下载没有?
9 h' g7 i& t# |" H查询关于对比的函数。貌似关键字是contrast,还有compare
- L% r1 ?* `) s/ @9 G) ]# @7 l9 N' c% |9 k% p
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -  t' c" |9 H1 q. ?/ j1 u$ p" h3 F8 @
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。9 C6 I3 o7 j; G' \7 s) f
可以下载到的 是 jdk-1_X_0-doc
2 [& r& X, \. J2 e3 F, X  C& k( l7 Q9 _4 V
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-31 09:44

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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