找回密码
 注册

QQ登录

只需一步,快速开始

查看: 961|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急# D) T& N. s: u. i5 `5 E$ [ 1 U6 E! d% z/ B
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************+ Y" N0 u* I. C5 V9 x# s$ G
//  ProgramCompare.java         Provided by: DRS
) O$ d) i& [9 V5 o5 Z3 k//) j8 w* Q* n& _7 {
//  Program shell for Assignment 2
  o) ?" ?# o; z) r7 T- D, V! m+ @//
9 ~' R) P# T/ N# W& O% [9 O4 L//  Compares two text files line by line2 E2 O  k3 A0 F
//*********************************************************************
/ F$ E8 n; r' ?4 A, g4 P2 x9 ~4 I; l% P0 Y+ F9 |% ^2 z$ f: a) \" q; e
import java.io.*;  U4 [% T6 L6 O, q9 v. {

% n& }9 k$ M# Q! J$ z9 [/ wpublic class ProgramCompare; k" u/ Y& ^2 p6 |. ^4 O
{4 p: T; U8 Z5 y
        //-----------------------------------------------------------------
: l; t- v5 f9 a; Y1 i* L1 W; T8 E% Q        // Constructor
3 e& S* [$ v. U! ?        //-----------------------------------------------------------------
: x0 f# P. p/ p) @* U        public ProgramCompare()
' V! n/ z" g6 s1 C$ P8 v* A: Z        {
& c" N8 }9 f* ]+ e: K; Q        }
, D$ X6 V, ?7 Q7 L& Z1 p9 q
% A: C- P& ]  }9 x4 h        //-----------------------------------------------------------------. I' }$ x+ F  i3 w! r
        // Method for testing that class has been reached
  d; U* p' d, R6 A        //-----------------------------------------------------------------       
/ Y1 ~+ a- W4 _
0 t( [( w* k3 V  Y0 S) B        public boolean ProgramCompareReached()        
, o6 l5 l3 i" u" Q/ {. t        {2 J4 F) l2 |) O* h' M( W5 f
      try
+ C& `' z7 ]. a. e9 ?   {        
3 [: k% D# J( Y( @) {                       
8 O/ ~. h6 d5 d                //********************************************************************# E4 u7 B+ J. ?$ ~6 o# j7 g+ k
                // Try-Catch Statement is used to handle exceptions - such as file not found $ j% W- y6 ?: h6 |: }' d
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
6 M$ Y' X7 s+ _: G, V- a7 O                // For more information see page 534 of the textbook
. Y( O5 I% U# V- r3 v& u6 Z2 {. d                //********************************************************************/ ^% c: A" K  r5 x
                    
- R3 L  U7 \2 U2 }) D        }
* a* I( f/ O, }4 B             catch (Exception ex) // Exception caught here and message displayed to the screen
" Y: \+ T+ J/ Y0 C3 j2 u- \% E6 ], v4 c; I          {, y1 n: ?2 \- s
                    ex.printStackTrace (System.err);, U. i& D! R0 h( C
           System.out.println ("Error message goes here"); // Replace this error message with your own         
7 B* c( w6 Q4 O0 F        }4 A6 {% _# {& @0 }
                return true;
! v# I6 w5 f6 C. v: S        }
; f+ j5 d0 _5 N) {! e6 y3 c: L' j9 M6 b3 D4 @. }3 m2 B
} // end of class ProgramCompare; ]: S% \5 e/ [+ Q1 L6 N4 R: m5 U

( h! N5 t+ v* C( i( V+ t//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************' U$ X0 w: Q. E# O7 x/ ^
//  ProgramCompareMenu.java    Provided by: DRS5 D1 i& L0 s& G
//
1 K" q  y& @/ R" k6 R//  Calls AuthorisedUsers.java and ProgramCompare.java
; q+ C) [+ |. {+ L1 q" E6 j//5 |2 x( v) j  j9 Y8 K
//  Driver shell for Assignment 2.8 R/ v% c. Y& T+ v. x" @* k
//********************************************************************- E- M; s4 D( d/ n

3 X& b% A, F# L+ o  o6 Q- lclass ProgramCompareMenu
- w  S' L8 j. v- D0 u{
4 g( Y2 B& a0 t: B: G/ w    public static void main (String[] args)
7 P/ A  z, P- p1 X# ]$ }. u            {" T; R: \/ A8 J; |- ^; E
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
: u( B9 g' j2 ]                ProgramCompare reached1 = new ProgramCompare();
3 E' ?& I9 t* P/ t; X                AuthorisedUsers reached2 = new AuthorisedUsers();        / q3 z7 Z& w$ j/ s5 F8 `( E
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());2 a1 a/ r: l- Z& [1 @
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        0 e# e; F8 I, t: m
        }
% J0 w! ]& @2 X0 F+ n  {& e7 @}// end of class ProgramCompareMenu) l0 g& [' T! f
/ U3 H$ ^( ~7 _$ A2 w
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************3 {) U" B4 G3 f) M+ L' U: J( f' ~
//          AuthorisedUsers.java          Provided by: DRS8 q4 a8 k7 a' u  k
//               
9 E( P3 P* D6 }2 s//         Program shell for Assignment 2
" _1 H# s0 Q8 }//
1 U( K9 |# H8 ?: @//         Represents facts about an AuthorisedUser
% I" M: i& @- k. U4 t3 |//********************************************************************
. p9 C' I; S2 p& ^6 W6 z
7 I0 v  v: x/ |0 }. ~* ?public class AuthorisedUsers" |) y1 d7 t; c0 o1 ~& u) G/ M
    {7 d! S1 ?! a& T6 K/ f/ p( [
' i% D+ G$ j. y- p; f" R7 Q
        //-----------------------------------------------------------------
" }) e; R/ ]5 C! @' r' e        // Constructor) R8 B! Z% j: V/ ^
        //-----------------------------------------------------------------
. \: O0 |. w# x' M- D* H( h/ i; J  a' k' l8 z$ c, u
        public AuthorisedUsers()* P0 |# n; F) c- n2 _; a7 q3 d
                {9 r) t! u! V* H9 n; U: S
                }
: F+ f; e5 \+ b+ c6 [2 w7 z2 P: Q% O/ h* S, y+ I: X, k
        //-----------------------------------------------------------------
/ z1 Q& ?# B) u( Y* ]+ i        // Method for testing that class has been reached
2 X, u2 {" y5 I  s8 D6 O2 E2 X* J8 r4 x        //-----------------------------------------------------------------        9 w* C; J5 ], j1 U9 Y3 g
        public boolean AuthorisedUsersReached()
4 p' V: K* q3 X1 F9 d. h: y6 u# T                {! e- p) s' z1 Y* h" q6 J
                        return true;                       
5 d' J( [' G4 ?$ v6 n. P3 |                }& E2 A( h, G# E3 |
                - p' b! i0 M4 A" v- @
    } // end of class AuthorisedUsers
) e# v' B' Y2 V8 [" R9 l//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming2 t0 G) m, H" S, I
Shanghai - 2007
4 k9 d0 k6 u# ?" Q+ w  yAssignment 2
1 k. y  h( R4 k2 K% L2 \4 @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)3 z: N# y* _' H& C, N/ P' ?+ c
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.
8 \# W! W% S7 x0 c# t! EThe staff must be able to:# n& _5 e/ |' g2 Z
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.  h* U5 w0 \% ~" i* O
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.6 k; m' v1 _. x' z7 l2 m. ~8 g8 W
 The interface should provide a menu so that the staff can:! S3 K& @8 W$ }4 p; B) D
a) Enter the names of the two Java program files to be compared+ s( R$ X' W+ m7 A# E1 H
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.. x1 |' h) E$ c! d& u
** 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).
/ }, W, C, H# x$ {2 }BSA104 Business Programming – 2007: Assignment 2% E( m1 \; X* [4 j5 o; V/ g; j6 {
Page 2 of 51 @; b5 H5 p! R4 o2 ~# T! L& B& a0 n
b) Print out to the screen all the lines of code that are the same
4 o3 C, S) y1 x# M9 G+ u Include the name of the file and the line number of the code being printed for each of the two files. x4 L+ N8 |0 C+ O5 N( @, O$ W) Z
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared$ U4 G# R2 Z$ w# ^
 the name, username and department of the user
* @! ~2 n2 ]0 H' Q: F# a the statistics of the comparison& {3 ^, z& G# i$ L5 t
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
7 x4 h( l! n! J! ]5 U3 T; M the recommendation for further checking7 n* j. C$ W$ i6 g4 \: D7 ?
- 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 closely6 |0 j  Y* |; R) A7 Y9 N( F
 the names of the two files compared+ N! x' ?; P9 q1 b
d) Leave the program (exit), B; t2 t. ^) @7 X4 m1 T& y
The ProgramCompare class: (Total maximum 20 marks available)- ]& p  H4 q! {6 f) j. @' w' ?
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)
$ `' B9 F6 @' H+ t5 p9 M; t- Q- da) provide an error message if the files are not found or there is a problem opening them
% S  n5 X# k5 J1 ]b) compare each line of code) h2 L  f" }) q) p2 s
c) print out the lines that are the same  m- p2 L3 }6 k' h/ Y
d) count the number of lines compared / lines the same
$ |/ r5 g9 y- C( C6 [# R4 XThe AuthorisedUsers class: (Total maximum 20 marks available)" f; k7 c9 X' o' A
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)
( M  n. N( }8 g4. Provide methods to:
: H6 K5 w5 q1 Q. A0 N7 M0 C4 C. 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( J9 A+ `) S! j. ?7 \& i& F
b) return the name of the authorised user
2 b: }# J5 L$ |5 n! m- _c) return the name of the department of the authorised user
, a  j3 P+ u& m3 d2 C6 `8 vIndividual Data (Maximum 20 marks available)+ E1 B) Y( |" S5 U+ 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.' l4 j1 a, |) @6 V0 n
Documentation (Maximum 10 marks available), c9 A) ?8 B! u
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 p% @2 g# A& S) W2 E# k) A, k
BSA104 Business Programming – 2007: Assignment 2. r8 z6 E' [2 @, w5 N
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了$ ]/ ^  @& e  Z4 l/ J$ A8 {9 b
不过你要翻JAVA的类库说明。你有下载没有?
/ Z" k& E) B6 L5 ^4 ]% q& p查询关于对比的函数。貌似关键字是contrast,还有compare" o: @$ R$ j1 f; ~; b4 k

9 u4 _7 I; H$ L0 a4 P[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
  D7 @- @! o, Z+ E0 [/ y可以下载到的 是 jdk-1_X_0-doc
& ^& p( Q4 T! B; r6 k1 m; ~/ F- Q4 F. E( _6 `, ]" L# I! N0 A2 r0 Z9 {& f4 r
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-23 06:33

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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