找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1483|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 , R. O$ [3 y, O2 }) L( D, U# `0 d7 x3 A, z5 A
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************& c8 }$ L3 S& a& e! w+ _$ }
//  ProgramCompare.java         Provided by: DRS
+ `& n4 s* N+ ^- q# \+ ^/// }0 ^* Y: A) p6 W1 u" B2 j! S/ T
//  Program shell for Assignment 2
4 O4 B; \' e6 E1 w//3 ?3 V1 t) _2 J
//  Compares two text files line by line
4 X2 q* q, i4 X- N//*********************************************************************" Y! Q5 y. o1 i- O; C# a# l* E

" |/ c. A& V+ x4 _6 y1 @import java.io.*;
* r* x0 f7 y+ A" P0 }; |9 {
1 _# q8 i! u8 {7 r8 t) gpublic class ProgramCompare& I% F/ ?! v2 R' f) R- b
{
: I- B$ n& I. U0 `; ~. z        //-----------------------------------------------------------------! M2 L8 f  X5 Z6 o! F0 J* o& M1 y
        // Constructor1 M: i9 N) R" S* |2 Z
        //-----------------------------------------------------------------
1 |- r5 d4 d& K6 A        public ProgramCompare()3 T- `* h2 n' ~9 |' R; M
        {
4 v, w+ U0 p, J/ E* b" s        }, {0 `' G. ?9 o

* Q# f' N! K4 `" l1 P0 V- U9 t        //-----------------------------------------------------------------
0 G) i4 {* _0 @7 F; a+ J        // Method for testing that class has been reached, h0 B- [- L  M! P7 A9 t6 h
        //-----------------------------------------------------------------       
; t' i5 s) x. ^8 a6 y& d7 Q2 M# O: F# w
        public boolean ProgramCompareReached()           a  E  g/ i: r% h1 Q
        {
: ?% A5 v* ?& X3 K) Q* @" [0 w' a      try # m) h$ a5 P' z: @5 ?* E
   {         6 [; `% i8 e1 R) a$ s- Q+ c2 {- p1 @# L3 y
                       
( Y! X# L8 B( K4 C3 q4 s) {                //********************************************************************
3 J3 {/ r( q1 U                // Try-Catch Statement is used to handle exceptions - such as file not found
# s- T& Q2 V3 f. C9 h9 r                // Reading the files will need to be placed inside a Try-Catch - just like this one!
8 `2 H2 l. T$ P9 J9 d7 m+ i: o                // For more information see page 534 of the textbook: U+ G# k5 v! X+ |. Z( @+ I& R, ~9 b$ D
                //********************************************************************
6 o3 G8 U& o+ T" f7 K                    
0 o/ u% ~& j1 ?  Q5 t' l# c        }8 K9 T& H; }  n* M5 a  }2 |3 y
             catch (Exception ex) // Exception caught here and message displayed to the screen
  w- P* d7 V, ~# ~2 _, l; G          {0 L% p4 a7 @. f8 u
                    ex.printStackTrace (System.err);- B& g% Z$ p& a+ t( P1 n  C
           System.out.println ("Error message goes here"); // Replace this error message with your own         
& ?7 n) p" K9 e! T+ [        }
- Z; h! R& `  H% X5 B                return true;
- B  P. T8 V; h0 Z$ {        }4 Z! V( B2 v+ |  A+ ?
8 m& @" f# q$ M3 U8 P% {& N
} // end of class ProgramCompare
. g7 U$ ]* w+ E; _+ C+ o1 A2 M  G4 [6 e! |8 B) K
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************. f0 J1 d! r  e8 U7 w$ S& e
//  ProgramCompareMenu.java    Provided by: DRS# P! }$ P  o) f) N
//1 r& t! z7 T2 D3 {
//  Calls AuthorisedUsers.java and ProgramCompare.java: j9 k/ S% z3 w
//
$ x  C; Y: ^7 P4 k//  Driver shell for Assignment 2.4 Y' v& w3 I& \1 r( m
//********************************************************************
; c6 v7 y! \1 u) h! y" Y* @( P  v* D* ]) _! E
class ProgramCompareMenu
1 h4 [' @1 \. @8 U# {{
) v8 o. L9 {. L& J. Y" S    public static void main (String[] args)  Y9 E/ n: ^  h' ?  H2 q& L) E
            {# V- d. h$ ]- k2 _$ g/ m7 P
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
& g; W5 V- n; s' E" X3 X( b                ProgramCompare reached1 = new ProgramCompare(); - P# s+ w# D6 `, q  e$ K
                AuthorisedUsers reached2 = new AuthorisedUsers();       
, m. F( \6 K" {8 V' r                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());# |% {% C! j- g$ P8 m. @" A' s9 k
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
& Y! [6 Z% g7 |& Y( F& ?- U        }
# C* [  B! J9 U0 J- U}// end of class ProgramCompareMenu- `: S' c, I2 P9 T

( ^# S* \4 P: y4 [//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************5 D9 p( G2 @3 a4 `. `% z1 j" i
//          AuthorisedUsers.java          Provided by: DRS; g# ?& g% u7 t! S9 P
//                ( |" ]4 s5 D0 A
//         Program shell for Assignment 2
& c; A6 P; v: o" s5 N/ G; ^* H//
+ C; Q4 a  y  Q//         Represents facts about an AuthorisedUser- s: |! @( R3 r& x, _
//********************************************************************
+ F5 L7 z" _* i  D/ J' _7 w
% C+ z( S$ ?2 Z8 k# Opublic class AuthorisedUsers
  O  ?0 }7 e' @) L2 a    {! q9 D# N7 i* n8 F

# O5 A, ]3 t& q, }  P, |( W        //-----------------------------------------------------------------
, f5 _7 n& A( |5 G8 A  h  O/ ]1 v        // Constructor
  Q$ ~' j0 S0 V- }6 q        //-----------------------------------------------------------------* q, a5 x8 f( l

6 O: I5 x/ @; ?& d* j        public AuthorisedUsers()3 q, j$ M3 p+ K/ `- T8 s) L0 o
                {
  s0 y# _$ m# N, t% x  L) P/ X                }
2 }: F5 o( {( f! h2 y
; n% s: c( h& ^4 \9 Q        //-----------------------------------------------------------------
) j6 \* c+ k+ o4 v* W0 o        // Method for testing that class has been reached4 L! D/ h4 E# v. G2 J8 A3 ]
        //-----------------------------------------------------------------        : `; y3 \. t- g# O; n# R, N5 D8 j' u
        public boolean AuthorisedUsersReached()
8 j0 q' p4 h& b4 p- G, k6 X/ i2 M( Y                {) z  Z, T  q% t8 ^" _$ t
                        return true;                        " E9 G7 M$ x2 e; [+ B
                }
' @" A9 f1 L* h7 x. ?- N* E               
7 Y6 Z, L, b* a6 s    } // end of class AuthorisedUsers# R( t4 Q; L3 e
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming5 x9 k. W  Y: ]- A  `
Shanghai - 20078 I9 @' M- W. l1 u* q- m( S; j
Assignment 2# r6 R8 H4 f! J: r' x* o
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)  K* m/ @, r- _' p3 O
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.
" t& a- T: o' M( _: j# M# K; pThe staff must be able to:
, P$ w( [& m% L- R( Z( Z; V Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
0 Q+ T/ J* [) D, H! l: K! S. V' w1. 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.7 T7 F0 ?3 {8 K! L) e8 B" y% C
 The interface should provide a menu so that the staff can:
5 n6 F! g8 `$ R6 w; }a) Enter the names of the two Java program files to be compared. r" {  R$ i, x0 ^3 |+ B6 u
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
9 k2 t9 c# _4 I3 ^3 B, }, U6 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).
4 d) a- [, ]5 zBSA104 Business Programming – 2007: Assignment 2$ Z8 L; a! |6 T2 j  x6 v, [
Page 2 of 50 I3 a& R" J8 K  {- R6 |2 m. ]
b) Print out to the screen all the lines of code that are the same
' r6 j0 b0 w9 p" q" `9 M* i Include the name of the file and the line number of the code being printed for each of the two files6 v9 T1 R: r- n$ g& S& b
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
, J% K* r- H6 j% T: m' k( s the name, username and department of the user
7 q- Z6 S9 \* x3 t+ Y) G( A/ c, N the statistics of the comparison* g# j. @4 R! h$ C
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different! D' z9 b! E! `4 g- e; ~
 the recommendation for further checking: h- A6 y% H1 g+ _( d
- 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
+ Y! m! h. W, n5 s; a4 ` the names of the two files compared  u8 S0 f* I7 ^0 E. I, Y8 M7 j& \
d) Leave the program (exit)) ^. H! n) d, E4 v. @
The ProgramCompare class: (Total maximum 20 marks available); h2 n6 ~1 J; I6 ?4 U+ C
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)
: b, q; Q4 @- I# r! W0 q: Ja) provide an error message if the files are not found or there is a problem opening them
4 h/ W4 v! Z# C  wb) compare each line of code( c. c& J' i( b+ {6 [
c) print out the lines that are the same
( a' t5 ^& C: Q' f+ `- }d) count the number of lines compared / lines the same
0 G% ~3 ]& F& \3 m; XThe AuthorisedUsers class: (Total maximum 20 marks available)9 ]+ O: |% U$ I: Y9 T  d
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)# Z4 Z" j( t2 O; i
4. Provide methods to:+ T' _& E# e$ W) d
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
- f( [# a: ]0 C0 Q5 u8 Db) return the name of the authorised user
( g9 _7 F: o4 T( \c) return the name of the department of the authorised user! S, I; ~$ z) n8 Z4 r
Individual Data (Maximum 20 marks available)2 B- g$ q- u1 P8 D& x2 {& y( M
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.
/ o6 k  L% u' r! T9 k% EDocumentation (Maximum 10 marks available)
* a# B' p; D$ G( x( R6. 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.( O& k2 r  W3 I. A
BSA104 Business Programming – 2007: Assignment 2/ q8 l! K0 c: S3 g) k% ^
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
' @* S- b& z) u8 I: V1 ]! F不过你要翻JAVA的类库说明。你有下载没有?/ m* ]5 ^7 k3 |+ b2 V' o5 c/ R: a3 T
查询关于对比的函数。貌似关键字是contrast,还有compare& B" ]" y7 T8 o8 w, p7 O7 J2 m7 _
8 b: Z6 n9 w/ g
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
/ j, A  L) u, [1 s痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。/ _5 f. u- j* i6 ]7 U6 b! c3 ?$ L
可以下载到的 是 jdk-1_X_0-doc" t" J( d3 A0 a( N1 O/ m. y4 H' u% u
8 ?9 _6 C# _" R
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-24 12:56

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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