找回密码
 注册

QQ登录

只需一步,快速开始

查看: 949|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ) o: o( o) s3 E, U/ @2 T9 m+ o 1 q' p' G6 E3 R4 p% n7 T
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
( I( A$ G& D. J9 c: a( s//  ProgramCompare.java         Provided by: DRS/ L$ M! ~7 n9 p! D
//
, ?/ }' L* W' @, D/ d7 I. a+ M* V//  Program shell for Assignment 2
& g8 V9 G; _0 i  I8 ~( H//; O. x+ X$ q9 ~9 F2 u" N1 k% @! F
//  Compares two text files line by line
) E) P+ @9 T+ k0 \' \//*********************************************************************
. s2 m% z9 W* i! V! K8 g/ [
1 J+ F6 L+ c- Q: ?import java.io.*;5 I: Y, _: n7 J1 o, H" C9 q2 Y; r
" d) h! A. f  W; }5 G- S2 G
public class ProgramCompare) B# }. Z" X2 r2 P* |9 e
{
, Q8 B# O; G' D. I4 C! r4 {, e4 G        //-----------------------------------------------------------------: b: E+ ?& ~; o+ Y2 K
        // Constructor# T7 O8 S/ c6 d' w5 v0 ]
        //-----------------------------------------------------------------
( q/ }/ j4 o' o% m        public ProgramCompare()6 o8 x) X$ K$ W
        {
, U- y# y! N! I2 @1 q2 t        }. D- k' ~+ D; M% w' k3 m) ~1 y
0 _6 S7 A% C: S5 ~1 y9 X
        //-----------------------------------------------------------------# O, r2 r8 W7 w( n; s
        // Method for testing that class has been reached
5 s; m9 ~. h2 F" d& i        //-----------------------------------------------------------------       
% N, M5 ^3 y& u. v* v
9 A& b$ ?' f. P; Y! h        public boolean ProgramCompareReached()         : \) e  R* ~) q0 p4 V
        {# A& x% W4 d( |
      try ; X% x0 H1 `( x+ m7 G3 H- B7 H2 p  V
   {         9 j) M& Q4 Y0 g; M! e& r
                        0 E+ n: U( N2 E) C  ~7 ~" _
                //********************************************************************6 u" ?% x" o5 m$ Q+ E
                // Try-Catch Statement is used to handle exceptions - such as file not found , I3 L5 ]. T5 Y8 J8 E, e2 D# e  m
                // Reading the files will need to be placed inside a Try-Catch - just like this one!" o/ i6 K6 D& U+ K- A
                // For more information see page 534 of the textbook
& S% W# T- b" U* [                //********************************************************************
, y, c, C& b, O) w                    
( k+ E! b5 }: w9 d% V$ T        }
  G& j9 J2 @' U% _1 U. J' J& d) f' v             catch (Exception ex) // Exception caught here and message displayed to the screen
5 ?7 t( ~# d. e0 N0 Y9 ^          {2 y- o& ~8 [) G2 L8 ?, S0 S- c& M2 z
                    ex.printStackTrace (System.err);; q9 J) _8 F2 T, A, @: ]- f6 `3 a: V
           System.out.println ("Error message goes here"); // Replace this error message with your own            u4 d5 T$ k8 k: k! k' X2 z
        }  K1 {9 ~9 j3 A* f, H% w4 W
                return true;
3 b& n8 q8 ]) \3 [/ O4 {& @        }
& C1 E+ ?6 D2 t/ U, @; q, B/ K! r* C
} // end of class ProgramCompare
8 s9 t6 ~9 t& g& H
6 s5 M' G  n! @) i, O//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
6 Q7 e" H: H  L- |: j; |4 I! v, q//  ProgramCompareMenu.java    Provided by: DRS
. I! c8 g# f& I+ ]1 ]' y% {+ A/// G# u5 e4 x) K; H
//  Calls AuthorisedUsers.java and ProgramCompare.java% G& c6 h: u* {; U# J$ w" ?
//
. U0 G- Q6 A  I2 O8 r" X//  Driver shell for Assignment 2.
! }6 ?+ h6 k  q3 n//********************************************************************
) Q2 H5 R- A* P" @. Y! J" \& F# O7 K3 c
class ProgramCompareMenu+ e# l/ h# {6 _" @4 W( i( G
{
4 ~1 B" y! ]: B7 R% t, t" }' Q    public static void main (String[] args)
* Y8 B# I, ^0 h) ^            {
: K# L: }7 J- [0 s% b                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
* `4 T( {2 i6 }% [8 ^                ProgramCompare reached1 = new ProgramCompare(); / B: _' R2 k: x4 K. s
                AuthorisedUsers reached2 = new AuthorisedUsers();       
- t+ _- m" V3 I/ F1 y9 Z                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());5 i/ B5 t; h5 f
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        + r7 r! `* }2 C
        }
% v- l( b8 V4 M7 G) i% ?2 |# O}// end of class ProgramCompareMenu$ m9 l' k' a8 o% o

3 L# d8 R" D4 j- q//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************, m0 n/ G2 g* M4 e$ o
//          AuthorisedUsers.java          Provided by: DRS# H( I$ k2 o# n+ q( A6 X
//                4 f% d' ?& {. @* ^: Q7 z$ \
//         Program shell for Assignment 2- T- h8 n4 F% x2 T0 X; {
//6 W9 a/ J( j- \' L* a
//         Represents facts about an AuthorisedUser9 `7 S2 [/ Q$ j& O5 q
//********************************************************************
: Z/ m- X& p' m* X: q& ?
' b% ?' W8 [6 H& h# X. vpublic class AuthorisedUsers9 v! H: w; i) Z) t. F
    {
, ?" Q2 l) V! u2 W' Q' H2 y1 ]4 J' k3 o3 r4 u& `
        //-----------------------------------------------------------------
( X; _& }8 Q: y2 ^        // Constructor
7 p( b7 S% k% U8 N$ @. ]        //-----------------------------------------------------------------
' ?# e1 f& b1 T5 u- J! I6 ]. G6 x% S* h+ O2 e: Z( j& _
        public AuthorisedUsers()
  K9 j# g4 W% L0 h, O# |  t3 a' [" \                {
$ e5 }7 b  R* ?! H                }9 O1 ]: }$ {" p, G, m4 x! [. S2 T
& Y9 ?1 Q6 z" }  y
        //-----------------------------------------------------------------
3 L& z% Z- Y) t; [  U" D" y2 y" M        // Method for testing that class has been reached8 W% T; Z1 P/ e0 _1 s
        //-----------------------------------------------------------------        9 G5 W" u  f8 i# w9 c
        public boolean AuthorisedUsersReached()
4 B4 V0 `3 r) |5 w' f                {2 b1 r; f' q6 Q3 M+ ~* V! X
                        return true;                        # R, g4 Q" h- f# a$ N* I  W
                }
8 b9 y1 a/ Y! e                $ _! X( c! F+ t' W4 e5 s
    } // end of class AuthorisedUsers' `0 K) J! }6 q( L
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming( z. t# e5 k9 }* {) ^9 _
Shanghai - 2007
  [$ i6 L8 H# |9 a3 B5 vAssignment 2
1 E% V/ A4 r8 c7 {: m/ r# e+ Q7 m4 s! DDeadline 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)
- L* u0 {4 \9 {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.: F" h1 W  \$ K: d+ e
The staff must be able to:3 W' N1 B7 ]2 [3 h2 m) h. v+ P- V
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
% m6 _, V7 q8 o" F1. 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.
7 V) E4 p! [# }, n: A+ L* E The interface should provide a menu so that the staff can:
6 |' o& i6 o" y& m( a2 S; xa) Enter the names of the two Java program files to be compared
2 h+ L; h8 ]- S For this assignment, it will be assumed that the two Java program files are in the same folder as your program.: d/ ?8 L, J/ }& G- j2 E
** 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).$ e2 H9 T5 N1 G4 p: g! ?# a
BSA104 Business Programming – 2007: Assignment 2
& Y" Y6 U3 f0 A. O" m# x" X, ?Page 2 of 54 }, N# S; V" g+ d+ A
b) Print out to the screen all the lines of code that are the same" O2 `2 }- O, R" T7 F, A
 Include the name of the file and the line number of the code being printed for each of the two files
) B8 F. A, X( ~3 D  z; ]! bc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
" b& R, g7 M$ p) n/ V the name, username and department of the user
- H# w5 n8 e' G! n1 G! ~ the statistics of the comparison
) r; V& F3 [; l, O8 {$ t9 o4 a- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
/ I/ w, M" C  T9 _, Q) \8 e the recommendation for further checking- s6 M% [0 f- d4 m% J. V
- 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  X  L' I! W( S( g
 the names of the two files compared
: W% p9 f) h/ Y+ o. u) Hd) Leave the program (exit)
% k0 {6 I- P8 V. K1 ~8 m7 RThe ProgramCompare class: (Total maximum 20 marks available)
5 |! C  \" ~% s' ~$ Y6 H8 f( G$ X  Q2. 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): a5 o2 o* K3 D1 \: ~1 }" o4 Q1 m
a) provide an error message if the files are not found or there is a problem opening them! h4 O  L* j7 d$ ^4 ]
b) compare each line of code
" T9 q- H6 K0 N# s+ y% ]4 j; x) yc) print out the lines that are the same
. [2 N! V; r3 }d) count the number of lines compared / lines the same% ~0 x  U. @4 M& h" E. ]
The AuthorisedUsers class: (Total maximum 20 marks available)
& }, T0 [) O" W% n- x3. 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)- o7 w  }* E& w1 W2 [
4. Provide methods to:
2 T+ I+ r- S7 @* xa) 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% h$ \2 d% ?% W
b) return the name of the authorised user
: I0 W- S0 H! J* ^  o, Rc) return the name of the department of the authorised user
1 f- E* x) y; ~3 iIndividual Data (Maximum 20 marks available)6 x: @( D9 K; X! L8 G# c- p
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.
# F* W( R5 s" C" {6 A* UDocumentation (Maximum 10 marks available)
+ S5 h: f3 I0 A: Z* ], n9 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.5 L" T, z1 j- r1 U
BSA104 Business Programming – 2007: Assignment 2
0 d# F1 Y2 z' O; q/ d8 t: PPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了/ f- O7 R7 D4 Q7 n9 d; p$ A
不过你要翻JAVA的类库说明。你有下载没有?
% Q/ H1 O( x+ ^' Y9 w- T查询关于对比的函数。貌似关键字是contrast,还有compare2 M, t- I5 @+ H/ G! o) ]

; r& j# z+ u7 ?[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -( o3 l: q/ M$ a
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
1 y% S6 n* H  m* K( R0 _; R' {可以下载到的 是 jdk-1_X_0-doc: G$ t: v+ r# j' n
+ j& x4 H" n( Y* r
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-17 16:59

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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