找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1871|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急: q- O; q. F; q# P; ^4 _ / B" R5 F* y K
回复

使用道具 举报

 楼主| 发表于 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 L6 M; D  S/ F& E* W* [, g" ]' R//  ProgramCompare.java         Provided by: DRS
8 u3 U# F% x9 f* E//
! O" c. F5 @% E* n& [% m//  Program shell for Assignment 2
* Z' t" K, Z& b//
) d7 ]/ f' g6 Z3 s//  Compares two text files line by line
4 K* Y9 Y( Y. \; y& W& d//*********************************************************************
1 D- k! I' K( E- B% W% G0 `& o6 c. C2 m4 q! n
import java.io.*;7 o) v1 t, U9 R% G/ R" q. u
; y$ ]/ J6 U, q. O
public class ProgramCompare; h. M; N- D9 W/ q7 L
{/ i! @) v6 x% y' ?4 ~
        //-----------------------------------------------------------------
3 K5 |5 W! H5 U8 C/ i- b2 y        // Constructor1 Q  F' g$ A" O: F3 [7 b1 i; _
        //-----------------------------------------------------------------
' P" ~; o& k+ n- Q9 E& w1 N        public ProgramCompare(). w6 C" z* l6 G6 d/ r  A
        {
6 I  ~6 k- O4 C6 O" F$ {; J( {# N; c        }
1 V3 x! D4 m7 ]9 j" [; t+ E* E# E6 u6 j
3 Z3 ]; T% ?2 s. N/ h        //-----------------------------------------------------------------
2 P( Z! W+ i4 P3 A0 O        // Method for testing that class has been reached; Y4 X# n' z* X* V9 a# F
        //-----------------------------------------------------------------       
  ?$ D( |  I2 L9 K4 _0 F, T4 R5 d% g
        public boolean ProgramCompareReached()        
  B3 p5 X  d& p        {& C0 z" }* Y- R9 J) ?
      try
9 A: n# m+ _& C  m, [# Q   {        
+ E3 P! ]8 q0 T5 a4 ~                        7 H! r+ \  L0 Y$ z
                //********************************************************************0 d4 b" i& S' q$ t- m
                // Try-Catch Statement is used to handle exceptions - such as file not found % @& z3 a3 Z  r* t2 `( U/ f/ S
                // Reading the files will need to be placed inside a Try-Catch - just like this one!7 }2 D. ?5 M6 g. \
                // For more information see page 534 of the textbook9 m  H+ W: k$ |; @7 @* x+ j
                //********************************************************************  y* y; Y  c1 n+ |! ~
                     9 Y  e6 v' T% E9 W
        }; L+ m# S# Z, j" K, {
             catch (Exception ex) // Exception caught here and message displayed to the screen $ {5 N5 C2 x( Q0 p3 d  }* s1 J
          {
( C; f0 ]- {3 k& |6 [1 M                    ex.printStackTrace (System.err);4 }, e8 m3 K" u: ]5 {& M& j# Y0 z# i
           System.out.println ("Error message goes here"); // Replace this error message with your own         
( S! X! q4 ^# g: L2 x0 |        }3 T. Q& _1 e# v. |
                return true;" U& _. x8 {( t. h
        }
. t% [5 R1 j; F% v6 C- E+ |' m' C$ i; f# @. x3 o; A
} // end of class ProgramCompare) p4 P* j% Q$ z3 y5 A0 N8 C

9 U  H  i+ `. s- b* M//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
& f/ ]% O: R) g( L# \//  ProgramCompareMenu.java    Provided by: DRS
, m: e  Y! U* |1 i5 w0 U//) A) t) e0 x# c4 s8 R, H
//  Calls AuthorisedUsers.java and ProgramCompare.java
1 y' ^1 ]3 Q  T- h//( e! E* `/ n9 z( B
//  Driver shell for Assignment 2.
: \# a2 T1 w2 d//********************************************************************
9 K9 e9 W6 b4 I
# C9 i% \: d$ eclass ProgramCompareMenu
6 a4 S/ }5 X. y) ~7 }{( d9 w  m) |) r) ^: p$ m
    public static void main (String[] args)
& D/ T$ q* S$ b1 g/ I3 |; t            {+ \2 D8 C) W5 I- N% Z
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
- |' Z$ V' R1 t4 f1 v% g0 l& Z- [                ProgramCompare reached1 = new ProgramCompare();
* x; V& k' d, z6 V                AuthorisedUsers reached2 = new AuthorisedUsers();       
0 }. W4 [6 E! I9 {9 s: x# E                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
+ ~8 I: W; L* l$ P; o                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
- {6 `+ c, ]$ a4 r/ L        }# T; c  G- O2 g4 Z/ f
}// end of class ProgramCompareMenu7 F  q. S$ J# D0 C# j( g
' N" Q* V5 W% o! e" f
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
% x2 o4 q- g3 v6 r//          AuthorisedUsers.java          Provided by: DRS
+ q! P7 d# S0 R  W//                + E2 {! v% s# I' J
//         Program shell for Assignment 2
% t) A, {! B9 U//0 J; m; I! l) M! U3 @
//         Represents facts about an AuthorisedUser6 |4 P7 A% Q, u' Y, Z, \
//********************************************************************
' ^' r# d  P8 J/ p
  X( x; p$ u/ Qpublic class AuthorisedUsers
! Q& U  x: H& y- ~, ?7 f4 U  d    {
/ u6 `: ^& \. ?& C7 Q
( t; S" N6 Q& P; j        //-----------------------------------------------------------------
6 v2 R% D5 M7 D; I        // Constructor
$ h9 O. k  q! h& V        //-----------------------------------------------------------------
) Z1 g" W& G  t9 K3 a! {
4 b6 r1 e  \/ Y7 `& p2 l        public AuthorisedUsers()) E6 l: c. _4 B/ A+ r7 T) x
                {
6 a0 j. q9 g; W6 V0 t( ~                }
; N! }/ F3 J+ Z, b8 h( l+ c/ ]
' i: ?& r3 K) Y: i% f% D        //-----------------------------------------------------------------
* W* a; A* d6 i$ p. l        // Method for testing that class has been reached
4 e/ H- n# \, R5 M( @" n6 n        //-----------------------------------------------------------------        ) X( [. n8 ]. [
        public boolean AuthorisedUsersReached()
9 c9 u6 }1 y$ m" }" m0 E                {% n0 G) ]7 `9 ^* r1 E) g# f
                        return true;                       
; e( q4 \2 J3 E- F                }9 V5 _& [  }; h5 `& y% V9 b
                - }# w7 M7 J+ S* p
    } // end of class AuthorisedUsers% @5 c3 k- s* w/ J
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming5 \4 D/ ]2 N3 M/ M" E$ t" d
Shanghai - 20071 y% \5 M. k( S: I( E/ Q4 G7 F
Assignment 2
7 r% k2 k1 V8 w2 C. hDeadline 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)
9 @1 Y; r' d) O  }0 E5 m, {* J1. 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.( L- R( ?$ f1 V  D. d
The staff must be able to:+ A) f6 i# j. O( k; Q0 h$ y+ h
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
* r1 m2 W" _4 q- y# f' o5 K6 X/ ~$ r% V1. 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.) D* M" J5 m9 S. u. v
 The interface should provide a menu so that the staff can:3 }% Z7 R4 {/ a0 r2 z, _6 B; Z% ]
a) Enter the names of the two Java program files to be compared$ A; j2 Z# u& t7 W6 }& G8 Z
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.( b+ y4 O+ Z5 f* |
** 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).. A* e7 ^/ d; x. ?4 X$ f& Q! g
BSA104 Business Programming – 2007: Assignment 2
. u3 \4 I$ k3 o& X1 KPage 2 of 52 q- n5 h. }; L" H3 X* L9 f; W/ ]% g
b) Print out to the screen all the lines of code that are the same
7 p1 e! R$ m  }0 n Include the name of the file and the line number of the code being printed for each of the two files  C. z5 O. L" x
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared- W- B' O- Q( n! o& g  m2 b5 }
 the name, username and department of the user
) @% n# q! B9 F. L: b the statistics of the comparison( @  I+ R7 F: ]& r! Z! L) {! o# [3 {
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
6 U; @- A( F2 `; @$ z the recommendation for further checking: O# ~* ]0 |( L- V, i4 i$ T
- 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
1 A# |* T* C5 F1 e  V the names of the two files compared8 a7 e+ y& `" ]+ v9 i
d) Leave the program (exit)& ]' g5 E+ h+ Q$ w
The ProgramCompare class: (Total maximum 20 marks available)
4 [) v  E2 h5 u: b% v2. 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)4 A. I2 [( H* ^$ @9 x: P
a) provide an error message if the files are not found or there is a problem opening them, N/ D" W( c4 R- ^2 ]( q
b) compare each line of code
1 i: n9 i) s) D2 S- o1 Ec) print out the lines that are the same3 c# u) {; n  |. f9 D
d) count the number of lines compared / lines the same5 `# G+ G% \7 o- \) b" Q/ t
The AuthorisedUsers class: (Total maximum 20 marks available)
9 R! D6 B1 r3 L0 C0 _" t3. 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)
. h$ x: ~2 p. @8 C4. Provide methods to:& L  Z, D8 t2 e" C" B
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$ ^/ x; s- |$ a4 J3 J7 f5 P
b) return the name of the authorised user
) `) O# d) C  Y0 Gc) return the name of the department of the authorised user
! s' H" e: ~4 B6 _6 V( i! CIndividual Data (Maximum 20 marks available)
* \( v, k0 q! G( G1 O5. 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.
; g* K5 B& `( Q. U# @) vDocumentation (Maximum 10 marks available)
9 d' N" a6 w! _- q8 [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$ `9 X6 K$ `BSA104 Business Programming – 2007: Assignment 2
+ U0 ^* r+ O$ r$ q0 g& FPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了) A3 E3 C* p* l8 ^  \( g& t8 m
不过你要翻JAVA的类库说明。你有下载没有?  r$ [. i! J9 g4 e
查询关于对比的函数。貌似关键字是contrast,还有compare% f/ z$ n4 _6 H. J/ j

# K1 b: i/ ]5 u2 y[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
) V" y# k! a! N# H6 D' |& [3 R痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。# o8 j4 v0 p# C" m2 _8 @) U
可以下载到的 是 jdk-1_X_0-doc% N6 b5 C/ a3 |+ R% C9 `/ u9 ^( P

3 \) \% A" m$ R7 M. z* C5 a[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-12-3 07:39

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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