找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1581|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 3 }/ i) M0 W, O5 l: g9 e! F: ^, P& l
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************; G4 `. e8 a! I1 e- k, F8 F
//  ProgramCompare.java         Provided by: DRS3 Y& g! ]8 s6 y: G
//
9 Q( F. g+ Q' Y* T5 B' z//  Program shell for Assignment 2
4 x: a3 d! I: [8 O0 _# G2 I//" ]9 o9 r/ U1 w% j6 [9 `4 j
//  Compares two text files line by line) ?- [) r2 G0 i5 m* R# \
//*********************************************************************9 I* b" _" m, e; n

* Y# q. G3 O. y) u' Qimport java.io.*;" a$ S$ J$ r" w+ n

( a6 W, ^% w' f6 C( rpublic class ProgramCompare, d( R' H/ {6 D" N3 y
{2 W, d$ w* G/ |% ?$ l% X* A( T. b
        //-----------------------------------------------------------------
& M& x) v: ]! q; |3 o        // Constructor
) L/ V3 Z6 ~3 w& o1 f) h9 T        //-----------------------------------------------------------------
1 ?+ C& N6 ~* @( U2 l0 s, o( K        public ProgramCompare()
+ X/ e8 \9 v0 G/ f/ i        {, |5 D8 m! A. N) \( z; Q
        }
, Q1 Z- |3 S$ I+ U! h
+ o4 O8 x% B0 \* A        //-----------------------------------------------------------------% r. T7 B. I3 Q: U
        // Method for testing that class has been reached8 s7 `4 \# U/ P* A! g
        //-----------------------------------------------------------------       
: |/ b7 A1 o+ F1 }6 V. a' X) T  \
7 d# O* \& @& n/ l6 ]" Q2 \3 o        public boolean ProgramCompareReached()        
( U$ A0 a4 S9 l# `  ?0 e" `1 B        {
, H4 a/ a" G1 ^9 q' Z      try
# h2 A% S3 i5 Q$ ]: ^! O, X   {        
% F! |+ Z( f- B) [                       
( c. e% U6 H4 l* P3 H5 A6 T                //********************************************************************
& [0 n0 [1 @- F7 }9 p7 X3 A/ l. R                // Try-Catch Statement is used to handle exceptions - such as file not found ; z6 @, |' F" w- y3 f
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
* U9 `# @; a2 m+ {1 j$ M; y                // For more information see page 534 of the textbook
% W$ v! ?" S1 X" m" Q                //********************************************************************3 T( {0 `2 m" m" ?1 u/ @9 S- x0 G
                    
( R5 c4 L4 I1 t+ B8 V9 s3 T% ?        }9 Q: l. u* w2 T
             catch (Exception ex) // Exception caught here and message displayed to the screen
, g7 G; A$ b3 ~" x          {. E! ~- H' Y. K2 D
                    ex.printStackTrace (System.err);
/ _# T0 b* d+ J# c( R           System.out.println ("Error message goes here"); // Replace this error message with your own          9 b: q' X% x' O% Y4 B/ L' y
        }; `/ O1 O6 S2 D
                return true;# K( F! D5 y5 b8 @% a: n* q/ f
        }
+ E/ W3 v  k# y* S' N: _/ j
# f" S' K1 V  g' N' x9 r! n4 i} // end of class ProgramCompare
6 d! T0 d: J& m: e8 p! r3 C7 A& }) D4 |4 Z3 q8 n
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************, |7 ~/ f3 j% B& T4 `
//  ProgramCompareMenu.java    Provided by: DRS
1 l% u; B8 W# ~# L4 P+ m4 A//5 ^2 y  N. \* Z% @
//  Calls AuthorisedUsers.java and ProgramCompare.java
! G! L4 N8 r7 I//
3 P2 J4 X6 m' A' c1 P( Y//  Driver shell for Assignment 2.
* Z/ B/ n( R2 |" v8 A, v$ @//********************************************************************3 }. ?& I0 S. y; U4 Y
0 l5 V% j: k4 l1 s: Q$ H
class ProgramCompareMenu1 m# w) F0 t, d- Y2 m6 Z5 C" C
{
1 S( W5 A6 W/ V/ }1 @' V! l1 Z$ o: t    public static void main (String[] args)
; k; {- d7 b9 B9 z/ d            {
! @! X. c9 A: i+ ]  ]  g  f$ v                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable( }3 ?* P, W( G" P4 s& D0 D
                ProgramCompare reached1 = new ProgramCompare();   r. M' ^5 u2 l/ J2 S
                AuthorisedUsers reached2 = new AuthorisedUsers();       
/ J% g* D, u  b; F                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
) |9 x- a& {, s) ?! _                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
3 i7 k3 Z" S( T$ }* l$ y        }
7 Z* Z- ?6 v7 D5 h/ A}// end of class ProgramCompareMenu2 d# B% Q3 A+ V6 R$ i% n6 Z( h4 D

: V7 A! r0 u' B8 v/ |6 ~& ?- n3 m//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
6 i4 h6 c- X0 l( \/ l//          AuthorisedUsers.java          Provided by: DRS
+ M) F* X$ u2 Q4 c//               
9 F4 o7 Q1 ~- T//         Program shell for Assignment 2
5 j: }+ L; S. ]- V) d  F/ N//- L* U0 y, {- E5 F9 S. P* H
//         Represents facts about an AuthorisedUser! z7 Q7 A- M/ e; t9 [
//********************************************************************$ r& c6 O1 C8 H8 N
, b' C/ N1 o8 x
public class AuthorisedUsers
7 O* R7 F6 x- J1 I7 B" M; ?    {
: @; {& T- ^8 S) {" N2 Y* D
; ?& k" z; T9 n) p* E        //-----------------------------------------------------------------
* F) y$ B# j+ Y& v; k3 _        // Constructor
, k$ M. j1 e/ I% p9 D# X        //-----------------------------------------------------------------
' v7 M+ U' [. e& V& T7 e) I
' i! G8 W! m" z% Q; }- G' V6 C        public AuthorisedUsers()- h% Q  Y7 Y4 \: E' e. \! Z
                {
0 \- ~+ K8 `; K' [8 T                }
2 ~' T+ N# b. U- J  x
/ B8 j# L' r. p0 l3 B: X/ K+ M        //-----------------------------------------------------------------; y8 b# J' a' W+ O) l6 B# `: m# R
        // Method for testing that class has been reached( Z( Z8 A6 r# r, v- G- l3 m9 A
        //-----------------------------------------------------------------       
1 Q( O: w; c  ?/ B+ b0 L* W        public boolean AuthorisedUsersReached(), S. }& ]. Z# G) @; |; ^9 Q: w
                {2 S, ]% f+ g9 E3 ?0 h" b
                        return true;                       
4 h' L' y* Q: u& ^7 O7 k                }
  N/ b/ t1 F( Y3 Y5 p6 z                / x* z! s5 @4 B) J9 C0 C7 o
    } // end of class AuthorisedUsers8 \$ B8 o) G9 U" L
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming. ~0 ^5 O) D% h) t+ ?+ u
Shanghai - 2007
, P! U& [5 t% X- X) Y# OAssignment 2% K0 `  Q) B0 w& @5 D( Y2 ^7 {6 x
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)4 P! q; w1 t* S% m* S
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.5 C; D/ D# j2 O: n7 U. `: }
The staff must be able to:5 N7 y  r3 w3 G: d
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **., H7 A* ~4 `8 R+ K* B# x2 }
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.8 c+ P$ K5 ?# J6 b5 O
 The interface should provide a menu so that the staff can:1 E$ W% H4 j5 q9 b: w3 w6 X2 _" t
a) Enter the names of the two Java program files to be compared
- {7 N% j! p: H8 _. U" k For this assignment, it will be assumed that the two Java program files are in the same folder as your program.1 k" m' ]8 `4 M. D
** 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).5 `8 J3 K" t. ^4 [
BSA104 Business Programming – 2007: Assignment 23 B, z7 q9 K0 G
Page 2 of 5
1 E# V+ q- e$ {- u. A1 pb) Print out to the screen all the lines of code that are the same
8 h0 C7 c9 o' W; [: [ Include the name of the file and the line number of the code being printed for each of the two files& i& d$ K: ~- V+ C' I
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared& A- |( c* X$ g- I( b2 o
 the name, username and department of the user; @, M6 ?* H/ P
 the statistics of the comparison+ h/ {1 @  @* }) _1 M( H. |1 S
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
: I. S( P+ B1 X0 Q the recommendation for further checking
# I& \8 F" Y' G1 Y/ B/ [4 Y& \% h4 q9 D- 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: J7 ~( D' {3 a- Y6 x
 the names of the two files compared5 Q$ j& z8 R$ d5 n7 W) c
d) Leave the program (exit)
- ]6 b& H3 O8 t+ g( LThe ProgramCompare class: (Total maximum 20 marks available). J' D; T1 _7 O# b
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 F; _& Z' Q' r9 I4 E  ba) provide an error message if the files are not found or there is a problem opening them$ P$ F( F& [6 n5 d9 l7 s4 F
b) compare each line of code
1 P& @$ T4 A2 l+ d; n+ Nc) print out the lines that are the same
$ x# I- ^7 o* F  kd) count the number of lines compared / lines the same9 @0 `8 b) }- ]
The AuthorisedUsers class: (Total maximum 20 marks available)
9 p) i: B- v& N" M9 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)  o% ^1 v$ v/ j) X5 ^
4. Provide methods to:
4 ^( ~9 Z9 A) t. P! ya) 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+ z$ d5 R8 m, M/ v2 t& b
b) return the name of the authorised user3 k. l2 X6 e; {# O5 P
c) return the name of the department of the authorised user
# X( V. q* ]+ n# c' y- VIndividual Data (Maximum 20 marks available). x! V% y/ o, C% N  X, p  U
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.0 o+ E7 H, U5 q, u5 e5 x1 a
Documentation (Maximum 10 marks available)/ Y7 I' H) ^, O4 a" e) K
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.' N9 g) T3 U' E* b" Q: ]
BSA104 Business Programming – 2007: Assignment 2
" [& }( b* Y. v- }Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了$ x8 Z1 Q: u# I1 Z
不过你要翻JAVA的类库说明。你有下载没有?7 V$ t  ?6 P  B! Y2 r& X) z- T) ]
查询关于对比的函数。貌似关键字是contrast,还有compare
2 F+ h1 y& M( v0 k+ l5 }
8 [( v7 U$ q/ P3 a, q4 A[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -0 ^: I+ }! L: @
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。# h/ h9 z* a/ [+ b" f- U
可以下载到的 是 jdk-1_X_0-doc1 v- Z. r! z7 F2 {& B% z

! H/ o# a/ e) r) a[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-26 15:56

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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