找回密码
 注册

QQ登录

只需一步,快速开始

查看: 972|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 * H3 j; t" _; p. ~/ g, b9 X5 v. F( w/ |' J3 x6 z3 ?
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
% i; x7 m% [9 T//  ProgramCompare.java         Provided by: DRS& X- y- X1 U4 e/ `- n+ L" H
//6 l3 s$ k: o5 V, v" a/ U0 L
//  Program shell for Assignment 2
' [5 g, _5 {9 ?* j1 P1 F4 `//
' r" f' ~9 _( Z% L- ~//  Compares two text files line by line7 O$ |) ^; x; a* S" ?2 C& i
//*********************************************************************
, n6 e$ F) y2 J" l/ T/ |: X/ d* @' P; o/ \5 @
import java.io.*;  r. L$ a- m$ {4 g

8 |. J1 e4 P+ z1 I8 u5 J9 w, fpublic class ProgramCompare# s5 U5 H4 q( e" c6 @
{
) d- f' J: d; i$ C        //-----------------------------------------------------------------
8 Y( m1 q4 U  t, K# K        // Constructor
8 Z; |2 h5 {4 a        //-----------------------------------------------------------------$ i9 w4 G6 e* X) d1 J5 u
        public ProgramCompare()0 I2 \( F" W# }0 b
        {1 x  b# B9 M* E0 a5 W
        }1 i% E0 o2 ?% P
2 v' ~1 e& j$ z+ y  n# p
        //-----------------------------------------------------------------
. w- \" ]# X: l3 e0 T        // Method for testing that class has been reached  p  ~4 C% i( z+ }' t
        //-----------------------------------------------------------------       
( I4 |) p9 o0 y" n3 M, {1 U9 }% t# o+ X# Z5 G7 G
        public boolean ProgramCompareReached()         " @2 b, O; {* i; |
        {
2 o) o; k- C. `8 w2 R/ [7 t8 Z$ T      try - n9 B% `' l" _5 T8 E9 J
   {         # O; d; v' L2 s6 F
                        $ P6 g( w3 K; |( `$ K9 {- z
                //********************************************************************
# v/ H' M: ^$ l. G/ L8 m+ l- j                // Try-Catch Statement is used to handle exceptions - such as file not found
& E% ~. y7 d9 `2 y0 e8 q! ]. G                // Reading the files will need to be placed inside a Try-Catch - just like this one!
4 u6 s" t9 Y0 T* t1 g. x                // For more information see page 534 of the textbook
3 `) X/ P# ?- a. C                //********************************************************************4 M" P( J2 R$ B, S* z: u
                     4 u" Q4 t) }" X" O
        }) r* w& Q6 B1 B: }9 @
             catch (Exception ex) // Exception caught here and message displayed to the screen ! ?! h+ F+ l; B) w
          {9 H1 r. r6 }6 \* d
                    ex.printStackTrace (System.err);
! @" G$ J. V. Y; @( d1 }           System.out.println ("Error message goes here"); // Replace this error message with your own         
8 S# A( `: R5 p+ H$ S        }
* S# }9 [) A* Q                return true;- M& C+ L9 K* P; Y  O
        }$ `" G& j; H# [" u

2 a2 t( n% W$ Y* h3 D3 ~# z, |} // end of class ProgramCompare
# L8 O- ]" y$ U3 B; F; n
+ Z& A! S2 A% r6 `4 Y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
4 x, o' y% ]2 v8 D: h6 X- Z7 s//  ProgramCompareMenu.java    Provided by: DRS2 ^3 T9 P4 X5 ]
//1 p- X2 ]8 S4 G! {
//  Calls AuthorisedUsers.java and ProgramCompare.java/ X( g/ i4 K% o) `- Z2 a7 y
/// D+ l3 ^; u- @
//  Driver shell for Assignment 2.
4 G% J" S* O6 H4 F+ L; R" ^//********************************************************************
/ D2 z! }) n# y, x. A0 H" r, u3 C( H
- i7 Z; }/ ^3 qclass ProgramCompareMenu7 u) D/ g8 M- F+ ]9 B  h
{! Z# ]% o$ }7 G$ E* Q+ M( k4 \
    public static void main (String[] args)
& c, K9 T7 ?/ |2 B) Y& H& V: A. |  ~            {6 x* z8 y- B) }6 q$ {
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
3 D9 [. u. J1 n( e( q                ProgramCompare reached1 = new ProgramCompare();
- m& Q9 o. H! F6 u, h4 r5 ?4 v                AuthorisedUsers reached2 = new AuthorisedUsers();        ( p5 F, H7 K4 P0 |1 }  d/ Q
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());4 P7 ]7 x2 i' d, ]* \
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
1 L& D  p; `5 \" X0 N+ s& V% N: x$ Z        }
( S' q2 i' T0 e. V  S- l}// end of class ProgramCompareMenu
& q% l5 @' V1 p$ X  X8 J0 h9 k) q" [" m
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
5 L4 `  n* y1 f4 O  L+ l' W! y3 f/ k//          AuthorisedUsers.java          Provided by: DRS
) F8 l' t4 b+ g) L% w% H//                ( V; q8 g' M8 k$ n$ N9 W1 M
//         Program shell for Assignment 2
% Z, n0 ]4 K% _% u8 D1 S/ _3 @//
4 I9 P& U- |0 S. Q//         Represents facts about an AuthorisedUser) }/ G- a, ~7 @$ `" T
//********************************************************************3 F2 y, v/ K- s2 a3 B0 S
; Z9 S+ ~" y" Q" U: ?% @
public class AuthorisedUsers
2 }4 y  c: ?9 [* D, @+ x! i( @8 r    {
( I0 m5 i! x- g1 G* l% U/ ?* y8 B, B% P% m3 T& g, @5 a9 K
        //-----------------------------------------------------------------
! m6 S! N+ j  i# F        // Constructor
. o; U! p3 l: {5 X* k        //-----------------------------------------------------------------
, s& y) _; B2 i& a$ I9 t% q& X2 U* D
        public AuthorisedUsers()$ R3 b! w, R. s4 z: H8 b
                {& B( G( v' j; w( i) l2 [' e) J
                }
# U9 g& \: o; ^" ]0 g6 D' G
% ^8 i. t- V# n4 h# j        //-----------------------------------------------------------------
: L2 `) c7 ?7 O0 O        // Method for testing that class has been reached
/ y/ T1 g& C& i/ U3 ^6 L        //-----------------------------------------------------------------        4 S) ?+ Z2 W7 B  N- B
        public boolean AuthorisedUsersReached()' L0 x' b" }. c/ e  V' X
                {
% ?& Z+ d& B7 {! h                        return true;                        6 s# h0 c, n+ B' k
                }* F8 e; i) c$ T5 V4 P6 ^
                ( r# v% [  q+ R9 D2 X1 z
    } // end of class AuthorisedUsers
) u  F0 a8 A) G. N! X0 B* ^" M$ K//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming& T! n! Q3 x4 ]
Shanghai - 2007
6 P( O( u0 T2 H) R( M- [7 ?Assignment 2
  b. ]( T2 v% L: g& t6 B; ]3 gDeadline 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)
* ]: Y9 s9 [- |" O8 }$ d0 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.% }4 u* ~# o, p
The staff must be able to:/ U8 ]4 e2 r: e. h1 k; q
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
. ]' S9 Z2 c8 \( S* o1. 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.. ^9 H1 n# t; H" l1 T! a+ N
 The interface should provide a menu so that the staff can:
2 g  K6 y, X& S* p4 A" ]a) Enter the names of the two Java program files to be compared4 j5 v' I1 {8 s
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.' ]$ {( g4 o1 u9 c1 h$ g! s/ V# ^
** 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).
8 }- J) j  ?/ ?. R# r$ bBSA104 Business Programming – 2007: Assignment 2
  o/ Q6 ^& A7 YPage 2 of 5
, J# S7 I1 V9 S3 a3 P! Bb) Print out to the screen all the lines of code that are the same
% F4 [# `1 J$ ^ Include the name of the file and the line number of the code being printed for each of the two files
# g6 L7 S5 M( b* ?8 v3 H" Y; O. ?c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
/ n2 B0 d8 D8 H# A the name, username and department of the user. ~( n2 Q% i7 p  F5 B( U
 the statistics of the comparison
5 r9 C; {+ w7 |/ f% h9 G- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different+ Y/ v. _( b' _2 l1 s
 the recommendation for further checking1 ^! U( D3 k) E: s
- 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, j, a8 F8 r; w5 [
 the names of the two files compared
, z& s. J4 h. ~. H- Id) Leave the program (exit)' Q4 a, d- {. c
The ProgramCompare class: (Total maximum 20 marks available)6 \& s. E+ ?( T1 Z: ^
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)
5 X4 Z+ _: q) Ma) provide an error message if the files are not found or there is a problem opening them
7 _4 ]5 y  U9 U% Z  W8 P( P3 n( Rb) compare each line of code0 o- n& Q, P0 y8 ~, j
c) print out the lines that are the same, ?3 l: G2 L9 _( H
d) count the number of lines compared / lines the same
" W. U+ Y& I# X7 s: yThe AuthorisedUsers class: (Total maximum 20 marks available)% x2 N' A/ V/ K/ J! u
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)6 C  T* J8 p4 z. @; p. o
4. Provide methods to:) q( d9 p$ l# Q, X/ \$ m
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 match
+ b8 I7 ~' R- |b) return the name of the authorised user
) o. r* p+ B7 R1 L1 Cc) return the name of the department of the authorised user
9 C8 Y' _, g- i) ]Individual Data (Maximum 20 marks available)4 O" c0 h3 v* D3 o
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.
4 U9 D5 l) n/ A+ Q  @7 B; bDocumentation (Maximum 10 marks available)
2 |) p7 f* w: V) P- |( j! v6. 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.
4 h/ n) L  ]- u# P. Z8 RBSA104 Business Programming – 2007: Assignment 2
- r. C: c3 b: v4 QPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
+ W. J# q- P+ M8 @+ R! K不过你要翻JAVA的类库说明。你有下载没有?' u4 w# p* e$ Y3 G
查询关于对比的函数。貌似关键字是contrast,还有compare% b/ i& Q( J9 n! j% l& e

. o& d% x/ }& f* @: Y" G[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
' E; b- N: A: p- o. g痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
% |. N) x* w1 F可以下载到的 是 jdk-1_X_0-doc: `) c7 ~! f( d7 R* u

- D, y; A* w' l8 x4 X[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-28 10:51

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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