找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1381|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急, ]# m1 i+ I7 }* ^4 N# t& S & [/ @2 {, O ]- l4 f d; Z
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************' `5 I3 T, `$ U
//  ProgramCompare.java         Provided by: DRS
6 j% ?( u8 R5 ]9 I, T//
7 k+ g+ }. [) F, _//  Program shell for Assignment 2
; T& b; ?! A. S0 k3 `3 @5 j1 l: l/ T//1 U9 f4 y2 Y; W" I6 M
//  Compares two text files line by line
/ c. c9 j8 k- ~2 F//*********************************************************************/ p( c- L3 X% P: [4 G! A+ k

/ e  X" C) f% g3 cimport java.io.*;* ^/ X, i  i, x6 D

6 z. a8 e) Q0 l' Z: O: Spublic class ProgramCompare  Y# B3 n$ r+ Y# T
{
3 @1 k0 K- Y0 [, G# D        //-----------------------------------------------------------------( N, }, a5 r/ j( R7 M  B" l0 e
        // Constructor/ v! S' r" h+ n1 y2 T
        //-----------------------------------------------------------------
" `8 K& P' ~# R% ?3 g# L        public ProgramCompare()* c; I" Y9 _; Z+ M; v
        {0 g) P8 z* I5 q# T
        }
0 K4 B( e$ N5 o* ~! I+ }7 Z7 A7 F# S: ?
        //-----------------------------------------------------------------
6 T7 l6 B9 o5 H8 C0 y: t        // Method for testing that class has been reached" `6 U5 g6 f: W9 p
        //-----------------------------------------------------------------        + H$ e3 n! ]- j8 l, c1 C; h7 {

5 r8 _' k% O$ ~# B        public boolean ProgramCompareReached()         ) D* r* x! q6 r9 F0 j* p" B3 L
        {
' m" V5 B- O$ D5 ~/ j% n: Z! H7 n      try
1 e) Y: ]- k& p) u   {         . r7 |. c3 i' |: K0 }( ^5 O: b
                       
# L5 v' O5 _+ F. p) w                //********************************************************************" C* ^7 v4 Y1 ~& [
                // Try-Catch Statement is used to handle exceptions - such as file not found
$ `8 A9 ]  x9 X, ~                // Reading the files will need to be placed inside a Try-Catch - just like this one!; J3 A8 i% ^: y. q; ~4 j
                // For more information see page 534 of the textbook) b3 l6 Q; a) h9 M
                //********************************************************************  N' h# q: \3 e" c# \1 J
                     1 I2 T. H  N! c  H4 b7 }
        }" W  p& }( Y- h7 H. o4 o$ s6 F
             catch (Exception ex) // Exception caught here and message displayed to the screen / a$ M3 M- `* G( [5 A& s5 @$ Y/ a1 P
          {6 E6 V# R5 N4 B
                    ex.printStackTrace (System.err);$ ^; N5 z4 ]8 W6 E6 f) ^
           System.out.println ("Error message goes here"); // Replace this error message with your own          + e3 X5 A" k% @3 U
        }
! N( j! y" \" Q4 e                return true;
& E  O: \" U. q4 F+ S2 f; j  u/ r        }
. h, Y; x- A9 N. V9 c$ w+ \4 x, ?, ~3 |
} // end of class ProgramCompare, d. m0 p- h8 w8 m/ T; u5 r. F$ I

0 z+ F1 ]; m1 Q7 C2 R//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
  A: `0 H, V% m. d1 O8 s4 T: d* p//  ProgramCompareMenu.java    Provided by: DRS9 d2 Z- L1 G0 b/ o- W
//
% U, h0 _6 n5 l% `- M//  Calls AuthorisedUsers.java and ProgramCompare.java
5 q4 _! S3 c7 Z# Q* _//
$ e$ w; h  {! G//  Driver shell for Assignment 2.
. v+ n" S$ U8 n4 E2 T//********************************************************************
- i& ]% m$ |; L, W' \& |
, r* V/ W  F) V# lclass ProgramCompareMenu- Q& ]9 v% `( Q4 [( {/ ~! }6 C
{* V0 @0 H( Z1 O! o
    public static void main (String[] args)" L" _! _4 X9 V: F8 k$ @0 t  m! l
            {& t: J( W, f4 Y% Z
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
. f8 F. m; k$ {! b4 q                ProgramCompare reached1 = new ProgramCompare();
4 H( G: s& K5 g7 Y                AuthorisedUsers reached2 = new AuthorisedUsers();        5 Q* V, e, X+ Z# Z( P* b7 @
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
3 }  L: d/ B! R- ~! `                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
! p: \- j+ Z. C/ g3 ?+ N        }. o. K  G. _0 Z! u. p
}// end of class ProgramCompareMenu
' l1 P( l# x9 T' e# v9 O% q5 o  P3 T# a$ ^0 |3 a, M
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
9 l( `* x" i' J7 L* J% I7 t//          AuthorisedUsers.java          Provided by: DRS- R" ]' p* n, D$ D9 [
//               
. y4 u# |3 N2 h0 K//         Program shell for Assignment 21 o! w' T. J  a" z; p% z
//
0 w9 v+ w5 J# n# y) B+ L7 L7 A//         Represents facts about an AuthorisedUser! f# e; V  s2 R% M! z2 ]* h
//********************************************************************& C  g0 N# P$ F* Z0 l8 E, ~! \1 W

' z. z; W' M& L  M6 @; Hpublic class AuthorisedUsers
/ H/ B+ g: t- V, H1 C% F    {+ \+ Z8 o3 N. i

, \7 u2 t) a1 j) |8 x; u7 I4 E        //-----------------------------------------------------------------8 c. V7 Z! i. b3 r
        // Constructor
0 P, G- Q/ i9 d3 A% d3 }& g        //-----------------------------------------------------------------0 C( o) R! t& ~+ U( a! |+ V# f# K4 h1 e
! y( f2 r  t  s' p' K- K
        public AuthorisedUsers()2 r" `0 O% R8 S. v$ n& H8 _
                {. f8 h1 R1 D5 H% U1 E- }
                }9 S# ]+ Q3 l" p

1 X+ T8 A( C/ X9 N& F$ r, u# g        //-----------------------------------------------------------------
8 P" X( K) g  Z) _+ ]        // Method for testing that class has been reached
! S! o! n* q3 U9 K. ^5 v        //-----------------------------------------------------------------       
' Y. P2 l* C" `" X( Y        public boolean AuthorisedUsersReached()
/ V' m# ?0 v/ v4 Q! U+ k                {4 l& @; A5 h4 i' G8 q: Z' o
                        return true;                       
0 q2 ?& S! L$ `                }
" p7 M' l4 {8 y8 d: S3 K$ S               
# T' \7 ~: t- j  ^6 p! ?: b* q    } // end of class AuthorisedUsers
* I/ V8 G# V3 q( R! y. C//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
' H7 v2 Q1 N% M: f. V0 N; m9 D# o0 [Shanghai - 2007
! C8 ]& ]9 ~/ DAssignment 2
/ u* J) ]: N5 y/ B4 @: ]* y" rDeadline 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)) ~1 p: a* l% s) 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.
! b; c) D! P, T3 t. l6 E% LThe staff must be able to:6 F6 k  G9 x: D8 n# v; {, @
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.1 t* k7 }8 N( {* j4 [4 P8 P& y' B
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., E+ E, t4 z0 p( J/ U
 The interface should provide a menu so that the staff can:
  [3 o/ I7 H* Y4 j7 z! ?a) Enter the names of the two Java program files to be compared
" a! f# |! a3 G* t5 K For this assignment, it will be assumed that the two Java program files are in the same folder as your program.2 B" ~* O  |+ g& n1 P
** 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).
4 F5 u( r$ j) Q4 }) B3 uBSA104 Business Programming – 2007: Assignment 2- O  c1 h: g* y2 G) H
Page 2 of 5
0 Q# X. L) }4 n. s4 Eb) Print out to the screen all the lines of code that are the same
" l& s( W+ }$ S$ w Include the name of the file and the line number of the code being printed for each of the two files
9 |& {5 e2 K2 U+ ic) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared! ]: [. f0 n5 W" T+ `2 q
 the name, username and department of the user
, r# G& }( i; X* x$ u: T3 X; n the statistics of the comparison
0 E8 K4 u4 ^# g7 k% J4 N- u- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
1 V2 ?9 q9 \) s* C( A- s the recommendation for further checking) `; p2 U" B& y$ W0 n
- 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 closely5 R1 F1 r7 @; d2 N
 the names of the two files compared! H* C0 G1 t$ i) v6 o. p0 ?
d) Leave the program (exit)
; j6 ~( }& ?; ]' y% t' k) E, FThe ProgramCompare class: (Total maximum 20 marks available)' h) ~2 Y/ y+ V4 X8 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)
& ?8 l: W3 R; e  F- xa) provide an error message if the files are not found or there is a problem opening them
, w+ i  \2 G# ^b) compare each line of code8 I( F0 K/ s9 n" H- j4 W: t$ k
c) print out the lines that are the same
; d" _; A$ W7 p) Cd) count the number of lines compared / lines the same
8 K  q# u1 {8 m. |; y3 |  zThe AuthorisedUsers class: (Total maximum 20 marks available)& [0 r! J) I7 v% ~! b" p, P
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)( I& X' p; F+ d/ A1 W( B
4. Provide methods to:
* T! S+ |9 a, U5 E; W) s/ }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, @2 [# [% k  P! x; Y
b) return the name of the authorised user4 c% D$ h0 {  L, Z! O, {/ D  @
c) return the name of the department of the authorised user
. G5 t, x" c2 M  uIndividual Data (Maximum 20 marks available)4 x. I' d# J, Z# ]: ^* }9 ^: @
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.$ k6 L% }; u7 Y0 A. _
Documentation (Maximum 10 marks available)
; a3 _( H. F0 z. b6. 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.
5 q) S3 y3 N4 y+ {: A! l7 I( a1 @BSA104 Business Programming – 2007: Assignment 2% _% M3 q2 Z) a" ?8 U% k
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了5 `2 @, c/ d; o7 K+ ~) X& m( k
不过你要翻JAVA的类库说明。你有下载没有?
' U/ P! ^- L$ d' K% B& t# r( E+ x& k; u查询关于对比的函数。貌似关键字是contrast,还有compare1 K8 P) A* a+ O( C% x: K# A" `

/ _7 l& _) }6 c4 H[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -7 i6 \; u; b  x; G3 Q1 Q. C
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。8 v$ e2 L' V  f7 B7 U+ r
可以下载到的 是 jdk-1_X_0-doc
$ Z: s2 i1 o+ v3 i) J" Z- s/ _" R. }. w; \* W" \
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-14 13:29

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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