找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1432|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ) u1 K4 o# A5 t- U3 k* Q0 S + w( j7 m: u4 O& s4 w
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
! A" ^) r. `, f2 _' [# M//  ProgramCompare.java         Provided by: DRS
. L5 B6 O5 b4 A# O//
% w6 m5 ]2 U- P2 X3 ?8 C//  Program shell for Assignment 2! ?& W) _' E" b* s8 }
//
) f$ I* `, b& H7 ]" _6 j//  Compares two text files line by line
2 Q7 F3 u( ~* q( @$ V) n7 `1 N//*********************************************************************
! ^+ l  u( Q  i( @0 e
$ H- _, R* {; O* u" limport java.io.*;# t& c- _- L; m) e. H' X

2 Z1 T) [2 _8 m: L5 F0 t) Apublic class ProgramCompare0 B( q$ T" I$ W5 H( p0 m
{  s; d7 f8 n6 R& w9 v
        //-----------------------------------------------------------------7 v1 X- m. t7 O, @7 B
        // Constructor
) q9 L! |3 l2 |2 X        //-----------------------------------------------------------------
8 n! r0 C6 ?2 S: x) r% K        public ProgramCompare()
9 w' B, q$ n7 ?$ x. o8 _: h        {
1 c4 W' m' @* z. T3 x        }
2 \5 M1 z0 r5 l5 A5 R! u  M. z
7 I/ a$ _" q4 ^+ p# A        //-----------------------------------------------------------------
; r  q3 e, ]! v) N& S" U        // Method for testing that class has been reached
! @9 R" q# Q4 K2 m8 M5 h6 L        //-----------------------------------------------------------------       
! e3 m! n4 L. x, v& p% \# r4 A9 Q( |) T# H6 c; W
        public boolean ProgramCompareReached()         7 n8 B) q2 z6 ^+ ], {) ~$ |2 A
        {! X$ B$ _1 N9 g: L, l
      try
! W% s7 v. U% v2 O8 o4 s   {        
# o8 N, w0 l  h2 ]9 p& [                       
4 ]  i. ], n7 t" K                //********************************************************************
% o+ G0 W* ]0 d5 H& l                // Try-Catch Statement is used to handle exceptions - such as file not found 9 _# @2 r3 r6 ^% a( r% u
                // Reading the files will need to be placed inside a Try-Catch - just like this one!3 ?' S( K$ y& U5 y2 @) P
                // For more information see page 534 of the textbook' K( K, u0 u: R- H* D  b( D6 u
                //********************************************************************
* U& S$ g' A( u5 C! y4 ]                    
" g$ S) I( l+ g) ]+ X        }+ Z9 j+ a- L& s9 L. [: W% H1 u/ i' v: a
             catch (Exception ex) // Exception caught here and message displayed to the screen 3 R& k4 e$ f$ A
          {
) G4 M! p! E  o" u9 Y& N2 c7 }                    ex.printStackTrace (System.err);& L2 H$ K+ e; @. Y" ~4 I$ F+ z1 Z; _7 n
           System.out.println ("Error message goes here"); // Replace this error message with your own          / H$ N6 W% e6 a: s4 _9 s
        }
8 o6 K. y; ]3 {$ a1 d. }8 S! P                return true;! q. L7 t4 Y" q; H& S. @
        }
7 s  P4 J3 G1 Z+ v" _! a3 B
) j7 `! n' L: T" o4 D+ m- q} // end of class ProgramCompare" g( Y9 ^: k8 i0 ^9 `2 }
4 ?7 ~, ~; |. [, l* Y& A
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************4 [  K( i0 n* R' S8 U- H; G8 [, m
//  ProgramCompareMenu.java    Provided by: DRS
3 K2 O4 O, T  f//& _' G6 N/ w& ~
//  Calls AuthorisedUsers.java and ProgramCompare.java
' |" s6 A" o( F' K//
7 p! }; _1 l# C( N: M" A4 E//  Driver shell for Assignment 2.5 i! B( z, |+ u3 L
//********************************************************************
9 X- n% |: \6 s6 O8 O3 `
8 ^/ P* u( P. S3 Wclass ProgramCompareMenu% b0 N. X( _4 v" `2 [
{1 X' D: G# G2 {4 I% S  K
    public static void main (String[] args)
! k5 E! R9 h: W# m% Y7 E            {8 _' @4 U( ]3 j1 \/ I1 U; P
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable. m2 ~- F1 p: L+ I) H
                ProgramCompare reached1 = new ProgramCompare();
. ?9 p2 j& I" G) u* B1 I- ]                AuthorisedUsers reached2 = new AuthorisedUsers();       
/ M) F7 k* w" p+ ^# F5 O: u# N                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());+ A+ H" n4 S5 I1 l; H5 M" a
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ' H; r6 Z  f* }3 m$ S
        }
7 Q* h0 R$ i! x, {& e2 O) w- W}// end of class ProgramCompareMenu
& P: S+ l' x+ b! k2 p6 F6 G' w2 R0 g# q7 Y) E
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
) K, Z3 ?6 U. j5 I  n  {, a//          AuthorisedUsers.java          Provided by: DRS. c3 R' N1 ^6 B$ w7 e, B
//                2 D# v9 Z/ _" H5 w  f
//         Program shell for Assignment 2% H( z! @2 c: s
//* Z0 N; H" o$ B( N9 v, ?6 t
//         Represents facts about an AuthorisedUser6 U2 b) t% ]0 [7 I2 g
//********************************************************************4 i7 k: s  G1 b
+ A; H2 a* {/ q* G5 Q
public class AuthorisedUsers3 _: E" S' U! n3 P& R. F5 c
    {4 \) y- ]! E0 I% G+ g

5 ~! z# [$ a% Z/ ^        //-----------------------------------------------------------------, k. |7 b) ~; p* q9 N
        // Constructor7 D0 n+ Y: N; W* ?* ^
        //-----------------------------------------------------------------
4 i$ a; f* _  n+ u, n/ p3 Z. n; _+ M8 Z( `) Z/ u3 T
        public AuthorisedUsers()
  \2 o: l1 {/ ^9 z5 t                {
/ \6 e8 z1 c% V4 o- {2 G: c& g. R                }
( }; d0 j9 ?  \
" z9 V' C2 c% q        //-----------------------------------------------------------------
7 ~4 V3 L5 B+ C1 {        // Method for testing that class has been reached
- e1 u1 M6 V, I$ ], {( K        //-----------------------------------------------------------------        / I1 |0 q1 F- E; c$ L0 E8 W+ U
        public boolean AuthorisedUsersReached()7 q, ^, b6 ]+ q: ^4 c, `3 [: v; A
                {6 x' m% D2 o) n, _6 P1 t. p1 Z2 k0 I
                        return true;                        2 i0 v7 [# A# A% s; a
                }
3 O1 C4 D, P9 N               
) W1 T' q( N) d2 ~5 s  K/ X% y, i    } // end of class AuthorisedUsers
% ~, D2 P) L5 B, U; v% P0 J5 `//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
0 o5 z& f! ~  }% g% |: xShanghai - 2007
9 D4 Y1 m" r; V+ K8 LAssignment 2
8 o% ?. R* E9 p9 ]) \# n. TDeadline 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)" ]- Y6 E8 I1 E( J+ w
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.
2 M4 U/ ?3 k( }  KThe staff must be able to:
5 ?7 v* r+ s- Q$ J8 l" D Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.* Z0 v; I9 @% q5 g$ p& z) C
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.1 u* s) x7 c. h- x- F$ _, w
 The interface should provide a menu so that the staff can:7 t4 l+ _. f4 l, C5 L  N: Y! K
a) Enter the names of the two Java program files to be compared
1 M/ ], k9 P# P7 p  ^ For this assignment, it will be assumed that the two Java program files are in the same folder as your program.) i7 K9 X- m0 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).
- S8 W) Z3 |  }9 Q3 T& W+ fBSA104 Business Programming – 2007: Assignment 2) Y0 F# d1 L7 _* h* J* i5 z
Page 2 of 57 D* Z% S! g/ I
b) Print out to the screen all the lines of code that are the same
' f9 l# [; _+ }: R1 z: C& K. d* w# Q Include the name of the file and the line number of the code being printed for each of the two files3 C1 w0 J# w8 h2 q
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared3 ]0 \6 n, i3 q9 m
 the name, username and department of the user
0 ?3 J  j5 i! ^* B# {: e the statistics of the comparison
) y6 u9 Y9 v) u' v- g# J) k- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different; @4 V' Q- S: h7 a" M
 the recommendation for further checking5 h* M" Z( m0 u% R8 o2 n8 \
- 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 closely0 R5 q' P- K$ [) t/ _
 the names of the two files compared
6 i: m* g1 u7 \  G$ cd) Leave the program (exit). s2 |. c) e. T. a" P/ l
The ProgramCompare class: (Total maximum 20 marks available)) y' w  s$ T: i0 a
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 d. P3 j9 `8 Z7 g* f+ Ea) provide an error message if the files are not found or there is a problem opening them
( p* s' B& V8 m8 H7 o2 Y3 M% n' k9 Tb) compare each line of code
( U; h% N, x4 K" o% }% D1 Z& Nc) print out the lines that are the same
* w5 p2 [( I, m& B0 J4 Cd) count the number of lines compared / lines the same8 H2 _- L( o# N! M0 @
The AuthorisedUsers class: (Total maximum 20 marks available)
3 n6 O, D0 A/ A! Y: W3. 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)" X8 @, t. @3 n2 ?
4. Provide methods to:
% I8 F: I- W* U. x' g5 Y+ X. Y: ^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 match3 u! {. K- k& w% o4 A0 u3 V! T
b) return the name of the authorised user. h2 m& A7 w9 G& q( q7 t+ d
c) return the name of the department of the authorised user
: G- I4 `* j8 J! D' L0 J/ K7 DIndividual Data (Maximum 20 marks available)
$ N3 X" ^" _- J! B5. 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.; I0 T" _( U1 q" i3 K8 }
Documentation (Maximum 10 marks available). W; h, X( B8 N  H
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.
8 t- D0 l( D  K% pBSA104 Business Programming – 2007: Assignment 2
, x/ M' x* A- D2 h1 j/ k/ A5 gPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了/ X% H2 w, V8 H( X+ A' E9 e4 m/ ?6 T
不过你要翻JAVA的类库说明。你有下载没有?% g5 |5 Z  v% m
查询关于对比的函数。貌似关键字是contrast,还有compare! [' ]2 l0 [, Z5 _
( g" O/ W2 s* t& F0 N" z
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
( ~! u9 D7 s5 {* `$ O; T痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
- ], M3 B4 g) h/ i+ @9 N: V可以下载到的 是 jdk-1_X_0-doc
; M# B. W' T$ ]/ f
7 m% O  W$ [: |6 y6 n; A9 R[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-2 23:25

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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