找回密码
 注册

QQ登录

只需一步,快速开始

查看: 937|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 4 f: L4 V( t3 G1 E $ t0 D7 Q3 i, A; |6 c' C
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************0 h8 b6 D9 W0 B7 L8 B$ z
//  ProgramCompare.java         Provided by: DRS
. j2 I7 W0 @8 r5 d" P" _' R//
: x, K2 q+ Q0 z( G/ N//  Program shell for Assignment 2- q  N6 _! L# d% a. u% t2 B
//
8 U) ^4 F& G( x4 Z2 g' [9 @+ O//  Compares two text files line by line7 t; k. l; R, R( E# D0 T
//*********************************************************************
2 Z) r( o/ b0 T) w
( C0 c6 D- y9 u4 ]7 T) ~import java.io.*;7 D% y1 u6 H5 ^* l" i
' K- \2 Z1 N/ C2 R' `/ p
public class ProgramCompare
- M3 x, f& V$ p5 W! R/ }: Q{1 u8 B7 z$ N* j( u$ G- t1 _
        //-----------------------------------------------------------------# @+ q) i2 d' U9 c5 ^( C( w
        // Constructor0 E" _9 i/ Z4 v0 U' w' l$ i
        //-----------------------------------------------------------------* f& |; V  D$ l3 V
        public ProgramCompare()9 ?+ N, E% O9 _+ a* s( ^  N
        {
; ]5 H1 H) p8 n  j        }* F, I- R( Y% W. e: Y
- f! D$ `- n+ v' P
        //-----------------------------------------------------------------
) p. e2 u% e2 P6 N3 u        // Method for testing that class has been reached+ {- Q7 A* ?- m6 c, @0 `. t: M
        //-----------------------------------------------------------------       
) z' u" e7 y+ l* A7 B; A! v& z/ j5 {, c: ~
        public boolean ProgramCompareReached()        
6 o3 Q- e4 R5 \" H1 r) p$ f" ?        {
+ X' p; T) |; n& F0 b      try
8 [5 |- O* ?8 Q9 ~  k. i7 O( e$ r   {        
' }% J, t; c5 o0 @/ r                        5 g/ _# ]2 |$ D4 |! O; L6 X
                //********************************************************************3 U$ }4 N# E" Q
                // Try-Catch Statement is used to handle exceptions - such as file not found
) G/ p- K( R9 W1 D. {" [7 V# }, `                // Reading the files will need to be placed inside a Try-Catch - just like this one!. n7 R# F2 E( |0 o+ D
                // For more information see page 534 of the textbook
+ h* }6 Q6 G9 D6 C3 ]  }                //********************************************************************
& q+ j+ r' e$ Z, I1 Q                    
, W; x  ?* @5 Y, P; X: T0 Z        }. e9 J( V7 m. m' m* |  p* E
             catch (Exception ex) // Exception caught here and message displayed to the screen
3 w1 r- X. c2 J# r6 E, c: i# c          {! I4 o2 v0 M" \2 A
                    ex.printStackTrace (System.err);
8 `' K) f$ H, h' \1 g( S& n/ M           System.out.println ("Error message goes here"); // Replace this error message with your own         
8 u) I. Y! p6 [6 \8 d; r2 R        }
4 ]6 ]/ p$ B/ Y                return true;  I- a) y, h" W, O
        }
! z. z; F+ X8 |1 l5 K: ~5 O1 c" U- Y
} // end of class ProgramCompare
" \5 C- O; y" Y0 b: }3 J! q. Q$ o  X7 I4 x7 y* I
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************$ W, b: P; n! |4 A' u- o
//  ProgramCompareMenu.java    Provided by: DRS) }# T. S/ Q9 j
//
8 V3 O6 m* P% Y//  Calls AuthorisedUsers.java and ProgramCompare.java( W& {7 f8 z. u. O: G, L+ V0 ?
//
% J7 ^8 _* g; S4 ]; L% J$ z# n2 f//  Driver shell for Assignment 2.
3 c( J- x3 B. x0 C//********************************************************************% z' Y# D% |) l: j7 G! }" [
$ s; A7 b9 Q* i& B0 z# a6 R
class ProgramCompareMenu
/ U" d& x$ X8 J9 w0 c{$ e/ g' A) Z3 ?
    public static void main (String[] args)
+ W4 N  ?3 j: b5 W; [            {
9 N  D8 N' G0 h/ J. l1 y                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable! m3 w9 b+ ]$ I9 n- x( m6 Q5 c0 [$ c& y
                ProgramCompare reached1 = new ProgramCompare(); 3 `& K3 D  L6 x% C6 X
                AuthorisedUsers reached2 = new AuthorisedUsers();        & W4 U& B  u. _" k8 L
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
" F( f2 T: N6 X8 ?6 E% O                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
8 X2 T6 ~/ q: f) w        }8 h5 R8 ^: K7 O0 e, e. i
}// end of class ProgramCompareMenu
  H2 ~" g; c8 O6 P% e# M
% B, j8 u8 r9 c! I; u//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
/ p. O4 J# n5 z- x//          AuthorisedUsers.java          Provided by: DRS$ V7 S; D0 r' Q9 j
//                6 [' \' Q# F/ V) w+ Z8 O8 t4 d
//         Program shell for Assignment 2' E8 r) `; d, D* r- Y. _9 K
//
3 j4 `# h. V3 [, A//         Represents facts about an AuthorisedUser8 p7 b2 j* s, M7 o! R" v
//********************************************************************% |) z, r' m# r; C  U

, C) u* m: L' X4 a4 v* vpublic class AuthorisedUsers& S$ c/ v. p' k* C, V# {
    {+ A0 \4 s0 X) W- j' y& T4 @
5 y7 V* V& Q/ ~9 j
        //-----------------------------------------------------------------
" ?: H9 d6 ~# _0 R        // Constructor3 S) o# P  m2 c" ]* t0 E) r1 n. p# v
        //-----------------------------------------------------------------
/ i/ T" f9 y) M  z$ [  |( C9 S: g4 P! R
        public AuthorisedUsers()0 c/ X/ v7 w+ v! l, W* e3 X: y( D
                {
# k, W7 _7 k* i+ d% r" ^                }3 m( j# J  Y5 p1 m& n4 _/ m% n
7 b) C1 P9 P9 U) r
        //-----------------------------------------------------------------
" p* k  A) y6 m8 @# ^* {        // Method for testing that class has been reached
1 X$ B! {" V' z! w( M% s        //-----------------------------------------------------------------        : R% @$ ^, ~; |& `  D* Z( P
        public boolean AuthorisedUsersReached()2 X. g: F1 U* @5 c( o2 U
                {; a8 n2 D) k2 j
                        return true;                        + b: i8 N; l/ h4 N6 K; i. l( K
                }0 N3 m' Y9 A& w% R7 a
               
2 _, F: P( @/ |6 V6 k  J% s    } // end of class AuthorisedUsers
( s* i8 S; ^/ O3 [$ H5 {) S//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming  ^6 E  g$ Q4 U- I3 `
Shanghai - 2007
& q6 S* N& N6 ?' J3 s! qAssignment 2$ M) O/ r$ N5 A$ b8 a2 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)
6 P- i: I( L3 B, D* D  m8 N1. 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.
/ f7 b& o" b  T- G" _The staff must be able to:8 E# W+ o# g0 t( k
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
( J# ?! R( M7 r( R. j9 [4 x1. 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.
+ T; q$ j0 b1 c4 q3 Q0 z The interface should provide a menu so that the staff can:) O/ {/ i* M4 z5 U$ s' F# |: x
a) Enter the names of the two Java program files to be compared: U6 j% U4 ~* U' H' J
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.3 n' c$ b# |, K
** 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).
, h7 C' E3 @$ b( S0 t8 ~' eBSA104 Business Programming – 2007: Assignment 2% A! p- ~; N7 U4 }1 ~' T
Page 2 of 5
3 B- g0 h5 j( B2 Xb) Print out to the screen all the lines of code that are the same' V  P5 `/ I$ u+ ]5 G
 Include the name of the file and the line number of the code being printed for each of the two files
: S) v" f4 ~9 Qc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
3 w! G! c, X' }5 y+ `, J9 {4 {, l the name, username and department of the user
; `5 T* V' E8 c4 M# S# c the statistics of the comparison& H: T( P: [  H( V
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different# `; }* w1 w0 E9 i6 P! F
 the recommendation for further checking, E$ X2 K6 O% c
- 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
" h4 E, M3 H* m the names of the two files compared
5 [- H) L3 {7 t6 n2 U; U8 Z' R2 }2 sd) Leave the program (exit)
3 Z) s4 C) M/ m  ]The ProgramCompare class: (Total maximum 20 marks available)
5 Z) ]6 O% b  L: B, h, F( V' f) d) X2. 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)
/ Z: G& c/ |* I3 [- B# [a) provide an error message if the files are not found or there is a problem opening them' ~9 q1 ~' ?" D9 A, c9 h
b) compare each line of code+ P% H0 o' _. u# \: N
c) print out the lines that are the same
: _0 f6 ]% B! _  V) q% Q* {+ nd) count the number of lines compared / lines the same  U5 F7 y7 ]9 N. @( [) j
The AuthorisedUsers class: (Total maximum 20 marks available). u& T1 Y" g3 A% y4 P  J
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)
% D2 c1 W1 ~: F$ D7 H5 G4. Provide methods to:
" J: W3 s, }' U3 Z( Da) 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
) G+ A$ r, U- u9 m4 Xb) return the name of the authorised user2 V! L* m- T( {1 a
c) return the name of the department of the authorised user5 k" E  h( Z) d
Individual Data (Maximum 20 marks available)
/ n1 v$ `6 i1 f$ K& B  Y5. 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.5 S9 P2 h# h" N7 K4 _+ L2 {5 m) Y
Documentation (Maximum 10 marks available)9 a7 D* Y  D4 b
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.3 H- X; }  N7 D9 a- I6 u0 \& l
BSA104 Business Programming – 2007: Assignment 2
9 B9 X( h9 l+ m4 z& A1 O0 @: C7 \Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
8 ~" `4 Y, {( Y# y+ g' r5 n7 I/ V) t不过你要翻JAVA的类库说明。你有下载没有?; E) z7 w; _& \9 b' b+ u3 F9 U
查询关于对比的函数。貌似关键字是contrast,还有compare
* t6 K) n1 G- g. c- d
% [; w+ R' e; a" [$ q/ B[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -# c& c! z1 F  l
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
8 _7 e6 g* U2 r- W. ~9 \; e( |- _可以下载到的 是 jdk-1_X_0-doc
/ j1 x+ M: S) n8 s. [. V4 X( \% G) ~4 A: ~
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-13 07:59

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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