找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1813|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急4 ^6 Q$ f. Q3 T/ f 4 z) X& y+ B4 N w- s* E: 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 | 显示全部楼层
//*********************************************************************
  d7 l$ I0 c5 F: Y( P5 E//  ProgramCompare.java         Provided by: DRS5 G) r8 @1 X$ y
/// h1 P" L6 Y% F
//  Program shell for Assignment 28 Y4 L8 x) _9 k; h$ d$ H2 d
//3 s& t& R8 L% U
//  Compares two text files line by line) u1 q; m5 C, n# A
//*********************************************************************3 ?3 S& T9 e* c; }5 Z, `5 m9 n

/ R& i8 E8 e. b* p# J( Oimport java.io.*;
; X0 ?1 i% E+ f6 w3 }
# s7 W8 [7 p0 l$ |  s  n" L" `public class ProgramCompare) D/ j1 o. {- [
{1 Z& _. \; c5 @- d8 ?
        //-----------------------------------------------------------------
( o* M3 ^7 K# ]        // Constructor! R# S& q5 o# W/ m0 A7 M' ~
        //-----------------------------------------------------------------2 S/ s0 T- ?% W/ X# ?
        public ProgramCompare()# Q; g  `9 E* v1 }
        {
. p: R9 B* a& }4 g1 b& ^0 N        }
' u( M5 z' A5 y0 L4 ^% h7 v7 l4 v9 b" u3 c- H. Y+ v) _+ p
        //-----------------------------------------------------------------
8 n% W; d* t  G( q  V, Y        // Method for testing that class has been reached
2 _9 T9 a" Q; h( T3 e        //-----------------------------------------------------------------       
% I( c& P3 s- Z- Q! N4 Y# J! {; Q
- [. y+ \2 `$ A1 r3 f        public boolean ProgramCompareReached()         0 E; z+ a: Q  [8 v
        {7 U! V$ V) c$ o
      try - J1 o4 s' l3 A6 }1 A9 G; h: L
   {        
% N  s2 e0 ?+ {9 @6 ?                       
/ j, F, @/ t* ]( Y) P/ w                //********************************************************************
1 I8 }" ?6 j% g                // Try-Catch Statement is used to handle exceptions - such as file not found 3 L1 Q: k8 D( @
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
0 \3 W% \/ g& a7 o                // For more information see page 534 of the textbook& I  n6 g" d3 M. Q  Z# k9 u
                //********************************************************************
/ u" k" s( Y. A( b6 {                     ! z4 s7 V9 v! I. b( I5 Z0 b$ h
        }
% I4 G7 y5 X/ e& {4 T             catch (Exception ex) // Exception caught here and message displayed to the screen * @8 m$ e; S$ o9 d' d+ p5 V
          {) u+ ], b) Y: N1 V3 F
                    ex.printStackTrace (System.err);
2 E/ c6 N. ?% A9 m4 M* }9 V           System.out.println ("Error message goes here"); // Replace this error message with your own         
1 F$ H$ [' W+ ^% m: T( a        }
+ s9 Q, e6 ^# q: u8 t                return true;
: A5 A6 |( N! G! |        }3 Y, W/ j0 _5 m

$ a( K) ^% s$ F8 s1 r} // end of class ProgramCompare
+ ^$ X/ R1 R$ ]6 w: J
9 R3 N/ ]# I1 p0 ?, ]6 W% V/ r//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
4 F8 a# {9 h2 m* p3 T) |: V& ^//  ProgramCompareMenu.java    Provided by: DRS
& t) w# h3 v$ a' _//
( k/ f# a% J: z* a  b- e; Y//  Calls AuthorisedUsers.java and ProgramCompare.java
2 b& x2 n+ N: i( Q  Z- }$ q//! R; r% E, l- m  g- c! e
//  Driver shell for Assignment 2.$ i- ^5 I8 c+ k) h3 I/ h
//********************************************************************# X7 _+ g0 e9 d! C, i1 _6 J, F, _

7 A, C* Q2 q, i% I. A( ~class ProgramCompareMenu
" p! E* L+ w5 U$ _9 I{
  t( Z& x8 }9 k7 k8 `: p9 C' Z    public static void main (String[] args)
- @- S$ ~+ ?/ `# g' e9 F            {
- w1 @; |) E$ i. _1 ]                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
9 s3 f* e1 B7 O                ProgramCompare reached1 = new ProgramCompare();
) l* B' u& o2 [5 J1 J6 a                AuthorisedUsers reached2 = new AuthorisedUsers();       
8 ?6 Y. J7 O9 E                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());1 m8 H$ R9 a4 B
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
7 z$ X. v9 m/ Z3 f# D, T1 X        }
( b  ]% z7 X! W# g' J6 H}// end of class ProgramCompareMenu
* Z: s7 {7 n0 F# z4 o2 x9 O: b& W& _
0 Q8 p  K4 q- l( `6 D//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
( ?  {4 J) l  I9 [//          AuthorisedUsers.java          Provided by: DRS
5 e4 {, L* C8 `! C: ?//                / O+ ~- f4 ?- }  Y+ A
//         Program shell for Assignment 2
( D, r/ s0 `0 s4 \  S//
' e% o( U8 g9 E; T3 D& q% j//         Represents facts about an AuthorisedUser
! D" l( W  `4 k6 r//********************************************************************, S& ?) k) [5 z* R& e) s$ n

+ k! O- G$ e4 X+ S: xpublic class AuthorisedUsers( d  X7 ]& n. b
    {
) T' _2 j0 Q6 g0 K/ {8 s; y6 g6 x9 k6 v5 y( @3 C# v0 D' W' E
        //-----------------------------------------------------------------
' q. [: a% c$ n        // Constructor2 A& v0 }- P7 v0 P2 W3 T8 N) n! Y6 |
        //-----------------------------------------------------------------# n: J  D& J4 P6 k
5 I4 ^. t, W4 o# \' u
        public AuthorisedUsers()
1 _; i. m  H# T/ q6 k2 S                {/ S2 r6 E+ q5 Z( Y. t" y8 D- _* i0 F* c
                }9 O4 o# Y* d" v

& C1 w* ~  X5 [$ S; \; O# Z; ~        //-----------------------------------------------------------------
5 w: v2 p' w9 }$ M) y' S! g        // Method for testing that class has been reached
# L6 s2 y0 U: B- C4 m        //-----------------------------------------------------------------       
5 Z( E2 i7 e" ^+ z3 ?3 S, @% Z        public boolean AuthorisedUsersReached()
# C7 k# J2 O1 C1 \5 b/ P                {4 C0 N# x2 X9 _2 i2 `  X) R$ @
                        return true;                       
6 U1 h( }- U" U8 ]7 r' O& \$ P                }
* E0 n+ ^" Z' F2 i                " G) T% p& c: o! o, X' {
    } // end of class AuthorisedUsers
% X( f9 |/ e% U+ U//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming. P6 Y6 ]% A: w2 r6 i' G3 b
Shanghai - 2007& I& A3 x, S4 W8 Q1 i3 q3 B+ o
Assignment 28 |9 X/ ?" C1 }0 F* }( P$ ?
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)
5 @# d; T8 X- b$ n0 v1. 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.$ X+ m9 u5 _' ^  [
The staff must be able to:2 p! L) }- i9 M; u# F
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
7 ?) E2 k# [$ |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.
( w( `& f$ t& x The interface should provide a menu so that the staff can:' [! J" ?" P7 ?
a) Enter the names of the two Java program files to be compared
/ Q2 _7 J& }9 Z For this assignment, it will be assumed that the two Java program files are in the same folder as your program.9 l7 U) c" O6 e7 C
** 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).+ ?% k5 n2 w5 n0 h
BSA104 Business Programming – 2007: Assignment 2" m6 D( M% C' s
Page 2 of 5
$ {* q" K& ~% U# ^, Rb) Print out to the screen all the lines of code that are the same- W% B- G; L0 f* g/ T# {4 c
 Include the name of the file and the line number of the code being printed for each of the two files
9 `& {  b8 z* a1 U$ X/ {: o4 Uc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
& j% S8 p3 [0 h) k3 o$ Q( s, M the name, username and department of the user# O5 ?9 g3 R6 o; B3 ~& e* Y) e
 the statistics of the comparison; x, B8 s- J. ]8 @
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different0 u0 e0 y+ u7 x) Q; |8 K
 the recommendation for further checking
+ b" p" r1 k8 }3 \/ u: e" s- H% j- 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( L  Z& U* Z) w% N; }5 N- Q9 r
 the names of the two files compared$ P, @4 z+ f+ B& X' C* |
d) Leave the program (exit)
2 z4 |! Y7 S5 d8 U5 x7 N( u' t. {The ProgramCompare class: (Total maximum 20 marks available)3 c( X- l" w6 M" E+ b) Q
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): V* |, n' }" @% S& @
a) provide an error message if the files are not found or there is a problem opening them
" e, I; C8 G' E- C; db) compare each line of code
' K2 ?5 {2 z" Q3 f& |' d; i: lc) print out the lines that are the same5 j( t; r( ^# t# [5 D
d) count the number of lines compared / lines the same7 |. u- P7 _& e  N2 F+ m7 t" r
The AuthorisedUsers class: (Total maximum 20 marks available)
' R( F; S! a! ?  T( t2 I! G3. 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)
+ o2 F8 p5 m5 U$ Z  A. ^; M4. Provide methods to:
0 y2 _; u' e+ a  u4 za) 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
% ]9 A+ @* q/ A' P& Ib) return the name of the authorised user
3 ^* Z4 p2 g7 X" u+ k" N* n, s* qc) return the name of the department of the authorised user
& R3 i, @" D" h7 x( i! m" fIndividual Data (Maximum 20 marks available)
7 H0 f- U# ]3 c; G0 N8 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.9 G  F7 G2 ~) s& E
Documentation (Maximum 10 marks available)6 G' l6 S( [8 l
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.: B+ V" @; ^* ]& _" y# S5 _
BSA104 Business Programming – 2007: Assignment 29 H7 }0 Y" Y- W
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了& X* b: S1 d( p) R' N/ C$ e: {1 @
不过你要翻JAVA的类库说明。你有下载没有?
9 N( Z& H- @% Q0 }' {查询关于对比的函数。貌似关键字是contrast,还有compare
) F& U( B0 T. U
% t6 s0 u  I& v+ M[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -' B2 R; f/ A7 v( g2 g- P( X& s
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
; v' C. D: N: ^! r; v+ J1 I可以下载到的 是 jdk-1_X_0-doc* E! o% I2 J( n/ C& F' r5 ^- V
( f$ r, b1 z3 l: O
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-11 12:09

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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