找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1573|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 - l+ H, u5 n2 E9 C/ p 8 E p5 S4 V* b6 G: `! y
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************8 O* v' @" h% O9 }
//  ProgramCompare.java         Provided by: DRS
! A3 S  c" W( C$ u* @//3 c- o7 E2 F2 P; L$ V, \( N4 P
//  Program shell for Assignment 21 ], V  q9 G2 k4 f- b: ~9 I
//5 C+ U' n; p. D9 e4 F) I
//  Compares two text files line by line' Z$ _) W# j+ @/ v6 T
//*********************************************************************
, g4 g. n2 \6 ^. [2 t
0 P/ ~2 g+ f3 ?) {' V7 ^import java.io.*;
7 N& N# ~! ?' N$ C! ~+ P! F. x  Z, @: `* |  p
public class ProgramCompare- _. R+ i4 ^( f& l0 e, f4 J& t
{
9 U; u( q8 E0 L0 q. d1 r( s( q3 x$ I        //-----------------------------------------------------------------
  o. |( `; B/ n6 W& u( L        // Constructor
# i+ C  x5 p( L. D/ q3 s7 T        //-----------------------------------------------------------------" d! Q) B; M: }# W/ L; x
        public ProgramCompare(): y6 R# O4 W* u7 ?/ G* r9 G1 M
        {0 @: V$ S# m0 e) t5 |+ I, b+ E( C; d
        }$ x/ k+ s/ R" k$ S7 |

# A, |* L$ G3 E2 C+ M- v4 `        //-----------------------------------------------------------------
5 M  E, q# ^# B! F6 [& ^4 g: J: z! W        // Method for testing that class has been reached! l( g. C; @$ Q3 U
        //-----------------------------------------------------------------       
+ M8 Y. X6 H/ }& x1 F7 C
% z$ B! T! h% ]0 @$ g6 j, |7 z        public boolean ProgramCompareReached()        
+ @0 p, |6 d, g        {4 V5 \" l% i: V/ n* V. |9 E
      try - O# v, _% `' d7 g6 z
   {         - _* T2 d+ v, y7 N6 |2 D
                        8 k3 W- p' E4 I
                //********************************************************************& _. X9 Z9 H/ g- w3 u! x' V
                // Try-Catch Statement is used to handle exceptions - such as file not found . Z$ c! t' \2 H, {: [
                // Reading the files will need to be placed inside a Try-Catch - just like this one!. Y$ c0 ?7 o/ x8 n* g
                // For more information see page 534 of the textbook
. Q' F6 Q# J. W9 V                //********************************************************************
6 J# n( A, E* `                    
9 |( [, c) V3 p" A2 B$ L+ l        }3 c# K! e. ^# d6 S' E* Z0 \
             catch (Exception ex) // Exception caught here and message displayed to the screen 5 Z7 f$ b9 h0 |3 [* H
          {
2 O2 \1 H' S6 h                    ex.printStackTrace (System.err);: k6 i3 y* U+ I; T" A- X4 [8 r
           System.out.println ("Error message goes here"); // Replace this error message with your own         
; j6 G( o, L6 d( y/ \7 C4 y        }
* f* E6 W8 F" o: b) T                return true;
! m* D1 {$ N; X* ^  c' J+ o        }( f# O  C( F2 P1 H- ~8 j
6 e0 T# ]! ^0 \$ u7 ^$ f6 e( Z9 Y
} // end of class ProgramCompare/ h9 R! f2 ~7 P. `& }$ D; g" ^
$ E% ~5 j1 B0 V: z2 F
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************) h6 G1 P7 _/ V" x! _/ Y
//  ProgramCompareMenu.java    Provided by: DRS
  I+ J1 z/ b, Q  l//
0 i4 u4 p( f) G. x, t" {1 U  X//  Calls AuthorisedUsers.java and ProgramCompare.java
+ W7 E6 b+ N- J//# }. e( Y9 ~2 y" L
//  Driver shell for Assignment 2.6 O4 K' o/ Z! |$ B5 t
//********************************************************************
3 a1 y. x; F( z/ t; g
6 {" S3 [+ |1 s) e+ A& uclass ProgramCompareMenu
7 `+ C: ]- y1 {; s0 C' {- }# H, o6 F{. t5 ^) v- }" W
    public static void main (String[] args)
0 D+ u) u1 B1 H' A) G4 K" ^            {" h2 B4 T1 Z5 j* e
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
8 }/ n% Z( C0 G; M7 I% U; t& K                ProgramCompare reached1 = new ProgramCompare(); 5 g; j2 E& Z. m1 o9 H& W
                AuthorisedUsers reached2 = new AuthorisedUsers();        : H9 E- R$ x5 b+ {
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
$ F8 U. l) ~9 ]; E- L                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        1 L' X9 c$ R% v- \( J
        }; |( m8 P# f7 B4 v) X6 g: u
}// end of class ProgramCompareMenu: n  u' p2 i0 t+ c& p- ~
% t) l0 s; d: W) `( Z" u8 c
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
7 S/ L/ _! z- N! v//          AuthorisedUsers.java          Provided by: DRS! j6 K- R/ {2 q. V& G
//               
' W: H) X! g5 E; T/ N' q//         Program shell for Assignment 2
9 V7 Y/ _) i6 A8 |5 s//- x2 I& q4 ]) x, F, d9 S, ^
//         Represents facts about an AuthorisedUser- n0 ?4 a; S7 X* K
//********************************************************************
7 p- D' t" h2 Z: d" o
3 r6 P* W. O* b7 Wpublic class AuthorisedUsers
2 b7 d  H1 l  Z+ I0 X" g& C8 E    {" X( i+ a: M8 v, h$ q4 z

' z5 p' u" N2 d, R8 a: O        //-----------------------------------------------------------------& o" F9 r! }1 z" C
        // Constructor0 ^0 E: L, b" F2 B+ `
        //-----------------------------------------------------------------0 Y7 m" c% g7 ?. K  U
4 o5 Q7 W: Y3 k4 s
        public AuthorisedUsers()
& s/ V$ M: Y, n* O3 s" H                {. i, H( |: n  R  \: H
                }/ w/ D, D8 g% D' m

$ \2 ^) E' t! A1 t        //-----------------------------------------------------------------; K( h. n  p+ G$ j3 }9 M6 U; @
        // Method for testing that class has been reached6 s" A7 ^+ g+ _: [6 d* A" _+ o$ i& j% K2 m
        //-----------------------------------------------------------------        & S. Q0 q3 n" o! B, I
        public boolean AuthorisedUsersReached()
7 P0 e( C5 h- }! K$ c2 F7 G) P1 L                {
9 G* G/ R3 ~& Q0 D                        return true;                        , @. a1 Q( ?) ~: C, h
                }
/ i+ N& f  a( a               
4 h* \) B) V1 B7 Y" |    } // end of class AuthorisedUsers
+ K; m7 P3 }! k  u0 }* ?//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming1 m  b2 V7 y1 l# u' H1 C& e
Shanghai - 2007
/ y% e; M2 L* JAssignment 22 |& j$ W; r# C! _' Y3 W1 T( z- I
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)
8 @/ h* p( u/ k0 N  _9 e1. 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.
- v# F, Y8 E% U! ]) `$ n; uThe staff must be able to:
. `! M& P  {: H* d3 H" j Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.& g+ q* T$ z4 o- s- d# m+ ?- Y, D
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.
$ N( F% B7 |5 i The interface should provide a menu so that the staff can:3 s( h% D4 w2 i1 ]+ e1 w" D
a) Enter the names of the two Java program files to be compared' J; H  o' ~! j5 `8 T0 y
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program." H1 Q, x9 B3 ~8 Z0 L/ 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)./ F2 a& U  R- `. f& p
BSA104 Business Programming – 2007: Assignment 25 y0 l2 Y- O7 y5 C
Page 2 of 5
" }& m, q9 \$ R2 Q' O7 Db) Print out to the screen all the lines of code that are the same
% L! S- J: ~* l& F Include the name of the file and the line number of the code being printed for each of the two files
  D/ e. s" |! Q1 H: _5 Qc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared* X  Q: f7 \8 f2 F4 }& Z! u6 `
 the name, username and department of the user2 S0 T- ?1 U! A9 |2 K
 the statistics of the comparison
0 A4 L/ x" v/ t$ }, l% [- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different+ S. s2 J* a$ r* z  O' Y- i
 the recommendation for further checking
9 w# A3 G, p, t% D) `5 q/ T6 O- 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
+ k& @6 g" }) b0 h/ p) ~ the names of the two files compared6 {8 }; G+ `- y/ d: X6 H) l( q
d) Leave the program (exit)& F: f7 j& z* b6 p$ q
The ProgramCompare class: (Total maximum 20 marks available)9 W) b/ G5 s( C$ E4 q; Y
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)6 v0 t9 q# b+ c! ?+ q
a) provide an error message if the files are not found or there is a problem opening them
0 g& ~) b! R9 P& I6 P& ]b) compare each line of code2 J; x4 O8 T- A+ |) f' z
c) print out the lines that are the same$ V' N2 T, a* d8 A
d) count the number of lines compared / lines the same
3 G$ |% u( R9 [6 i& O, mThe AuthorisedUsers class: (Total maximum 20 marks available)
9 R5 y+ b# r+ ~* c0 X: P3. 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)& X! b( q( a& M+ g# E' W( M/ R
4. Provide methods to:
4 C* {  K7 I0 b& c' Ba) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match0 a+ J. r2 L; c+ |$ i3 @
b) return the name of the authorised user5 C# r# N% k+ n' y
c) return the name of the department of the authorised user
& J1 t" ?8 E% R- r; r4 w8 MIndividual Data (Maximum 20 marks available)
! y6 c; {' U9 o: \; I# ?9 s5. 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.
- W" n2 V& K) k( Q5 x: mDocumentation (Maximum 10 marks available)
# u4 B# b7 z1 P0 v2 L7 |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.; f* Q; |4 G- @, |( l! }
BSA104 Business Programming – 2007: Assignment 2
% g5 k6 p9 e! iPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
, a, d- Z/ @( U( @8 G) a不过你要翻JAVA的类库说明。你有下载没有?
  K' k6 J* T2 N, ]; D% b( g* X7 N查询关于对比的函数。貌似关键字是contrast,还有compare. q0 W1 S0 }, o# r) y
* {1 Z7 U# [6 y8 T; n* t0 A( Z
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
! V* W8 Q$ D/ Z0 q/ L) Z  a3 t痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。9 t4 Y4 Q9 A6 T7 G7 c" L
可以下载到的 是 jdk-1_X_0-doc8 D7 N/ ]7 K3 E8 H

3 Z' D9 E0 j4 _% B$ `" C[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-24 14:02

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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