找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1437|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急$ j' ^. t/ t9 o5 j! K6 I# V M & [2 z% _8 d2 i
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
& e. t# |7 N' O! w8 T//  ProgramCompare.java         Provided by: DRS% M, s8 ?# H& y
//
. M  m2 U+ x' V- X5 y& J//  Program shell for Assignment 2
: \+ d, g$ {; d2 H! r# X2 }0 F/// ~; s; C" s! b6 N
//  Compares two text files line by line/ {  S- L! s2 u) p4 i6 r
//*********************************************************************
, q9 h" o" k- Q0 S5 p% G# S: h+ {" X/ F
import java.io.*;
/ }( K( z! |: D! `7 i$ r7 U
" A; `6 G" ]+ ?8 \9 u, [$ kpublic class ProgramCompare
7 ]' ]( G# ?1 V, g{6 K. N$ ~$ T  p, V* f$ _# P! K
        //-----------------------------------------------------------------
& D. F4 v7 ]! e  c9 ~( c/ ?        // Constructor; y& M; |$ U& g9 B: C
        //-----------------------------------------------------------------
% F* M" Z! }1 e; _5 n5 k        public ProgramCompare()
% M# v; x1 ~& A$ r! u) `        {& s+ ^, \- ?. ~9 A) v* ^
        }$ H: a: l0 M% P! z* [

, R) X! z. h4 _! V        //-----------------------------------------------------------------
2 V, V" F9 b7 O4 ?  c, h        // Method for testing that class has been reached
& W% z- {1 I6 Y0 `        //-----------------------------------------------------------------        ( M, l+ c2 V  y! f# \+ q  K
8 {, H0 s/ A! z6 {2 j, C8 X7 ?1 \
        public boolean ProgramCompareReached()         6 A0 n/ }& b" ^
        {
' Y6 A+ O- l: `      try ' V7 |- i+ y, X2 s1 a
   {        
4 @2 I8 L; s6 }9 D                        ( x' k( ]9 U% l8 |
                //********************************************************************
% ?  J$ t( D, W, R9 t; Q) I3 s: E                // Try-Catch Statement is used to handle exceptions - such as file not found
* Z6 p* N7 n7 r. y                // Reading the files will need to be placed inside a Try-Catch - just like this one!" g5 q; |; W5 k% l! A% z
                // For more information see page 534 of the textbook
+ K5 H4 B& p: p9 p  ?# f                //********************************************************************
9 z) W$ |! [$ k4 m( Q+ ]2 U                    
8 q! T/ J6 ~; W) d+ A        }
5 ]( l  w8 k+ w& U1 v             catch (Exception ex) // Exception caught here and message displayed to the screen
1 d! A; c& f' a3 o3 _4 Y! }1 y0 O          {0 D. P, q1 ]9 B; k6 S1 I* H; N
                    ex.printStackTrace (System.err);' l6 S$ t. r+ s2 Q; r+ t
           System.out.println ("Error message goes here"); // Replace this error message with your own          " i  s  Q' {2 k9 _" M
        }
) F6 f  Y$ ?$ \) y( k3 `                return true;( O. [( [& z' Q7 A
        }
- o' @+ ]. M. U; t/ j1 K, ~4 X6 y' |) G. _
} // end of class ProgramCompare
: E) ~0 D6 i3 c2 Z2 h' q- O
1 q2 h) P/ k5 B% n$ a, ~7 }//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************9 j: H/ Y- H8 e" m( s
//  ProgramCompareMenu.java    Provided by: DRS
* x$ W! f2 D. R! c7 i6 @3 S3 b' s//5 G" r3 t* P0 n
//  Calls AuthorisedUsers.java and ProgramCompare.java  q6 ^+ ~. k9 o7 q
//
4 X5 Q! V4 u) _9 H" Z* n! U4 c( \//  Driver shell for Assignment 2.# c# a8 `' B6 ?! r8 q4 M; r' m
//********************************************************************
# O  Q1 P5 |0 N  U  T6 Z& g9 R9 A0 ?4 b0 u2 m
class ProgramCompareMenu' D) `: N* V$ ^
{
' y/ c2 n1 w& w4 D7 w# N$ A    public static void main (String[] args)
# k* D4 A: Q+ g+ F8 M            {6 b' n: A# Z2 z
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
0 Q2 u3 Y, F: `5 @" t: M                ProgramCompare reached1 = new ProgramCompare(); * c; N% P# C$ l  Y. G. A2 q
                AuthorisedUsers reached2 = new AuthorisedUsers();        7 ~" O7 X! j$ v, E) S$ ^5 `
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
& U1 p" [/ [9 I! _# ?                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        , t( d  i5 s" @3 J& W+ q5 L
        }  p" A. `, y8 B9 y! G1 u5 i
}// end of class ProgramCompareMenu5 f, w+ h1 v) c! x% u, x' {! W  K
  ^6 g/ X$ w9 ?$ [* t* [( ~
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************4 V& C5 B% {: u4 v, n- l, E' a
//          AuthorisedUsers.java          Provided by: DRS# M- x( c; ]5 T- G6 N- f. D
//               
2 G7 \3 s$ q1 y! v//         Program shell for Assignment 2
# Y' M( Z- \8 i( Q6 x* ~2 C% |& `6 H//: Q, Y! Y( P1 X2 x9 N) Q; M; T' I8 }
//         Represents facts about an AuthorisedUser
* j8 P  E. f' g4 y6 g; ?//********************************************************************
! q' A7 x# _1 l9 g; ]- X8 o+ x5 z1 L# J
public class AuthorisedUsers
* F$ x# y* n5 l' Z% O    {
+ Z" ]) f3 U" a2 v# S5 z! ~6 @$ v: D
        //-----------------------------------------------------------------
2 n, ?: ^9 e- B        // Constructor; X6 H0 |6 K8 ~( a, I
        //-----------------------------------------------------------------0 }/ G$ p" Y; ?$ h! O. c

$ O5 M3 J9 ]9 e$ T9 N        public AuthorisedUsers()1 X) i3 v1 R5 e# M1 f5 O, U6 R- T
                {, F/ |4 [7 r( u
                }
, e5 U8 K+ l7 a9 H* k
- B5 \" D$ ]( K9 a# @        //-----------------------------------------------------------------2 C  n  A+ b8 t
        // Method for testing that class has been reached0 b4 ]. X9 p: r0 o; k2 K, P
        //-----------------------------------------------------------------        4 e* U% T6 g  U  I* O
        public boolean AuthorisedUsersReached()( `) q/ [+ s/ T4 `3 K+ b
                {
3 {: E5 u9 V$ U% J3 z                        return true;                       
/ }2 B) r9 X" L; y                }
1 e- v0 z3 D2 T& Y+ i& [# U9 p1 L& j               
+ o0 z5 [3 n- G: E- V    } // end of class AuthorisedUsers7 V" d1 n  B" f/ w. O# Y
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming# K; I& y7 V  y5 o2 s! y) Q
Shanghai - 2007; @) ?) M) q2 r# t& n7 ?
Assignment 2
$ q* a# Q' L1 u' C0 FDeadline 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)0 H! O! B# P, T) a+ |
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.
( _% E8 [$ X' h' k7 |; u& J" UThe staff must be able to:# _1 q' ]: B7 w" W; k* |$ J7 j
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.* y5 \) m* Q; V. r. W# l* W
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.) P/ g, r. ?8 h/ e
 The interface should provide a menu so that the staff can:
6 Q  i1 j* N; h' ~1 ha) Enter the names of the two Java program files to be compared+ c2 k' P9 p' ]: t. G
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.) u. c$ q: Y  O0 r# h# f( v
** 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).0 v; S2 w# b5 W- N
BSA104 Business Programming – 2007: Assignment 2# g) G, |. W6 j( T1 e' k9 \/ M
Page 2 of 53 p) t0 w/ a3 ?$ z% r2 q
b) Print out to the screen all the lines of code that are the same2 P. U5 I' H- {
 Include the name of the file and the line number of the code being printed for each of the two files# T! O; J# O2 z8 t! e5 m
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared, Y0 A; ~# p$ ]) e
 the name, username and department of the user
( |" x9 q8 L0 t- ]; ? the statistics of the comparison
3 {6 d$ T$ ?  I: s! e) Z- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different7 r3 h) M+ M9 l4 m& a, O$ {% T% L
 the recommendation for further checking
7 {5 }$ T3 m& g: a8 l- 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 closely9 G: d  t7 \; g# v
 the names of the two files compared& o/ K' N6 p/ w  v* o) m
d) Leave the program (exit)
  J. c* ^* M* F/ G$ ]The ProgramCompare class: (Total maximum 20 marks available): W  K- m- X3 f1 _- p
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)3 r5 l( b' I/ Z! E: `( e
a) provide an error message if the files are not found or there is a problem opening them- m+ n  H. ^% [5 {
b) compare each line of code7 G  a" Y5 m- `- K5 U
c) print out the lines that are the same
; q- P7 M1 u& Y/ [d) count the number of lines compared / lines the same
# h: N& d+ S5 r' V4 @( o; uThe AuthorisedUsers class: (Total maximum 20 marks available)
2 V- ]6 v  \# [1 g$ b9 b! K: `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)
* h2 J- f7 P+ B5 z4. Provide methods to:, `+ J. Q# j4 ?" {
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
$ U& N4 H. e* H" P' F( d* Wb) return the name of the authorised user
3 A. q# i. @: q5 zc) return the name of the department of the authorised user
, J" U& [9 B( f. Q9 ?3 I# j* oIndividual Data (Maximum 20 marks available)( v$ M/ I# k6 z! v
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.
/ f1 d$ s: i" H7 N% G/ S+ xDocumentation (Maximum 10 marks available)
0 f4 ]* m- t5 ?5 _7 n) 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.
  d& T" t+ ?4 s( L/ F, RBSA104 Business Programming – 2007: Assignment 2
) {2 p! L- L, v3 }8 n5 L: C5 MPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
$ p9 C' Y- {- e' m+ q不过你要翻JAVA的类库说明。你有下载没有?
( n% \: A- a' X. B4 L# D查询关于对比的函数。貌似关键字是contrast,还有compare, W) }  H9 `9 W5 l: y6 i- m

2 R9 C  K7 d3 T4 O8 z[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -$ j; b8 q* I3 @: {
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
& e7 s, T/ j5 Z) D可以下载到的 是 jdk-1_X_0-doc9 \' N8 T3 E; j5 b' X4 {
, m$ u- ]4 M' w- V2 O
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-5 17:11

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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