找回密码
 注册

QQ登录

只需一步,快速开始

查看: 951|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 # M: q5 {/ j9 g+ u " N0 q: g$ C+ N& V2 X7 O, J
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************# c2 z8 O7 q" `; d; D* t
//  ProgramCompare.java         Provided by: DRS1 y2 W% _( K* |: C" c* l$ n5 y* N
//
" q3 F. B. L3 V9 d//  Program shell for Assignment 2
8 t" U- u7 `: @- E$ z, Q//$ q" B$ I! l1 X5 g
//  Compares two text files line by line
: n; C' B* T* a- h: ]; e; ^//*********************************************************************' z, u/ M) X8 [, L
: z* _: o# ?$ d: K5 ]4 ^0 m
import java.io.*;
. ?' e0 k6 k2 N; h/ h4 ^: r
' B$ _' N: g: n% fpublic class ProgramCompare$ H! z% X' e" f2 W( |! a) C" s
{
& d: U" j0 \( E% {$ a        //-----------------------------------------------------------------
: v+ V  v* V+ W" j# y, ]2 _        // Constructor  l  C! D5 `& s4 Q) d
        //-----------------------------------------------------------------
6 Y: o; L" P' ]        public ProgramCompare()
& f5 T% V  b  u) k! s3 A8 w$ a        {
1 ]- m7 {; x# Z* j        }% w  A& y8 z+ j# F9 a
6 |# C- w3 G2 @7 G7 E) c$ ]( S' s
        //-----------------------------------------------------------------& y* v; H) ]7 [% O7 k
        // Method for testing that class has been reached) g. z4 ^5 v: X
        //-----------------------------------------------------------------        / B0 }+ `3 O! T( e+ H, I
; @3 C; R! [3 D. Z, J
        public boolean ProgramCompareReached()        
* g! s6 g) u7 C- f$ D8 w$ X        {
4 F" n. C$ n0 Z$ _      try
+ z$ ]4 w; l" L   {        
+ c+ _9 ]# C" K7 s6 `7 O+ N                        , c8 a- P) f0 R- U( ?( z" Q+ t
                //********************************************************************
8 {. m4 s. k" v: J0 J, l                // Try-Catch Statement is used to handle exceptions - such as file not found
: ~0 R" }4 e4 D' f                // Reading the files will need to be placed inside a Try-Catch - just like this one!
5 B5 {& E* }5 k7 I- @& c8 S                // For more information see page 534 of the textbook: y6 O: O: v2 T# f* M: p
                //********************************************************************) q  T# Z9 c# e3 A  f
                     $ D7 j* w8 u5 p0 |: n8 b. T
        }
, z" {; o4 S* x3 g8 F7 R3 R             catch (Exception ex) // Exception caught here and message displayed to the screen
2 k9 x4 ]; W4 V          {
& H! E( ]4 r3 }$ R( s                    ex.printStackTrace (System.err);
* Q. T8 k+ ^/ s2 x           System.out.println ("Error message goes here"); // Replace this error message with your own         
  C- W# q' m! K8 s0 b' S; q2 u        }
! y4 x8 |3 @& x                return true;+ \4 L3 m4 v6 ]3 S1 O
        }
) H' L/ l. K; T3 q" }) |
( Y0 i! o( O( ^3 ]% M} // end of class ProgramCompare. _- Q9 Q7 T8 y# v/ Q% i4 k  L) B: W

/ j0 |  j  T! V: @//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
4 I: z0 g9 P  _$ d& W* i0 w, K//  ProgramCompareMenu.java    Provided by: DRS, A* k  C8 [9 x- m8 ^# P
//
& b# W( o" x' ?. A/ d5 Q. _//  Calls AuthorisedUsers.java and ProgramCompare.java
9 z9 g' M: ]6 t, f9 u" A# p//
9 b" X- x7 r' e! t7 c; ^3 I( U//  Driver shell for Assignment 2.$ M6 o, x) R: s) Z
//********************************************************************
: _, r( T+ w) e& T5 [" P
" J( A, U2 Q6 J# J# oclass ProgramCompareMenu
: f. p( t9 p! x* P. C% S5 \) K{
" G4 B  o' p: S    public static void main (String[] args)
+ C! X" \5 H+ B" N3 U1 N            {6 D1 Y% _- h9 ?% d0 w
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
3 N+ U: \: a) Z6 k- |7 p# w                ProgramCompare reached1 = new ProgramCompare();
, l5 M+ `3 m/ X+ |                AuthorisedUsers reached2 = new AuthorisedUsers();       
7 x5 I  \6 z; w& m6 _9 z9 V- {  @                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
% e2 I  k" z1 R- u# ]. m                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ) I* t) ?  R" g' s# W. u; t
        }& r6 i6 ]* a5 a* x' W
}// end of class ProgramCompareMenu' ^1 O' [2 b  R- w
; ~: n& V  x7 N/ N4 R
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
3 l4 p. P- o! _//          AuthorisedUsers.java          Provided by: DRS6 c# O$ \! W& U
//                : ?3 u7 s9 F, f2 B$ L5 W6 _
//         Program shell for Assignment 28 N4 c( z0 q4 D1 T# x( ]
//) d6 E2 u7 C) U' U  V( k
//         Represents facts about an AuthorisedUser& L. E2 d! @+ `( Z) k7 _$ t
//********************************************************************$ i2 D- {* m: ?$ z% i/ [* B6 G

' n1 ]# v1 u/ e% y3 p6 d" zpublic class AuthorisedUsers
" A) `( J9 Z- k# j    {
% ^2 l/ V' O4 B7 P) s* Q5 G, u3 X6 l. z1 D! @! _; e1 J) G
        //-----------------------------------------------------------------# A  J- Y5 E* K( J! p8 ]
        // Constructor8 I# j4 K) P% }& E+ p& C
        //-----------------------------------------------------------------5 L$ ~5 {% ~, D

  ^0 @1 j* S- y& ~8 q        public AuthorisedUsers()
; L7 j/ `+ {5 `+ e; b/ W                {& |& G2 W  s3 K5 F5 e! f& e( d' d# H) r
                }
1 |6 J7 v7 v2 Y* N/ ^8 u
) [# ?6 \  X. d$ b9 b5 P        //-----------------------------------------------------------------
" F6 @( H+ x. h4 y( N        // Method for testing that class has been reached
  A: Z" L& m; G$ o        //-----------------------------------------------------------------       
: U3 m% r. m: `, y/ M" _        public boolean AuthorisedUsersReached()
2 M3 q: Q, {0 X                {" `8 [. Z6 U" H
                        return true;                       
  E  N& K- D$ s3 a: {2 k9 `) d                }
) `4 y- L/ H' B  |7 G               
/ ^5 _: u" Z7 ~- z    } // end of class AuthorisedUsers
1 G/ U& u+ e/ C6 q# ?  y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming, x9 y1 p4 [9 K: ]
Shanghai - 20078 O' z' b1 s" Z2 [$ V8 ~  h
Assignment 2
1 b) g6 m% d$ w4 TDeadline 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)
0 v# o  l. o! t  i4 f$ ~4 y1. 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 S+ K/ G$ M( s( B& \The staff must be able to:
& o% k7 I4 Y0 H% h& q- b Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
9 Z: _1 Y9 m  F) d4 x1. 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.  M( c% S& h; U1 ]. K* i. Q
 The interface should provide a menu so that the staff can:' i# T- Z, q( i1 A6 P& B
a) Enter the names of the two Java program files to be compared
/ x0 y$ p) F/ _$ ~+ r& y5 s9 {( V For this assignment, it will be assumed that the two Java program files are in the same folder as your program.  H$ r$ R6 {3 ?9 e; v  N
** 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).
6 ]2 l0 H. _& Y, n( @' m& |BSA104 Business Programming – 2007: Assignment 2
( k: k0 |/ P$ `Page 2 of 53 _2 }$ h0 v2 P
b) Print out to the screen all the lines of code that are the same
% W0 w7 w0 q( j  k: Z/ K Include the name of the file and the line number of the code being printed for each of the two files
* ^: O3 B- Y0 a; S( j. ~4 wc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
* m$ r1 K' |: Q+ b& G% T* z9 Z the name, username and department of the user; A! x& u, w% L4 k- B; f
 the statistics of the comparison9 _: }5 Z" b9 h9 T6 z2 _( T
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
' F7 R" k8 M- D* ~/ W/ p7 w3 Q0 ~; f- M the recommendation for further checking0 X! o+ I7 K) V9 j
- 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
" u% c) Y0 o8 _- F6 M2 T/ A8 P+ C the names of the two files compared
4 _0 F/ A/ O4 ^9 Z+ w& g+ l% t$ pd) Leave the program (exit)/ V% L* t# r: Z& v: g9 X' n
The ProgramCompare class: (Total maximum 20 marks available)
) G. J8 e5 V4 k5 |* o  N: O2. 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 S* \( V/ ^/ p
a) provide an error message if the files are not found or there is a problem opening them$ q3 C7 f0 `( `2 \" p4 ^9 J9 v
b) compare each line of code7 D7 n( H' L. v# f
c) print out the lines that are the same3 Z- D4 @. b7 \3 i8 {* y3 ^
d) count the number of lines compared / lines the same
2 ~$ y0 y- b. k# M& c7 d6 @The AuthorisedUsers class: (Total maximum 20 marks available)
; z2 s4 N2 r8 n5 \! D0 b3. 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)
8 G! t, L2 x3 @; U- i7 b4. Provide methods to:) u9 W+ [% K) v
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
) b7 k8 r- n% R* Q) \' Ib) return the name of the authorised user" l: l" h9 N7 d+ \$ V$ F9 X" |
c) return the name of the department of the authorised user
4 U! T# g) b) h; a# G/ Y) q5 HIndividual Data (Maximum 20 marks available)( o8 v7 j) e: U6 y8 K0 @4 f5 f/ L
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.
& }6 e' x) s; P2 r( a  J1 {9 VDocumentation (Maximum 10 marks available)1 D# y( I, L! u4 B3 B
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.
" J9 C  s  W. T" @! |1 K0 qBSA104 Business Programming – 2007: Assignment 2, o7 ~  m. T& k2 I: e
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了2 t3 ]2 Z0 f4 `/ D, I; v
不过你要翻JAVA的类库说明。你有下载没有?* g/ R1 q  }4 A& N" r3 D! S+ n& U9 ~
查询关于对比的函数。貌似关键字是contrast,还有compare
& T: R! }5 f4 A  n  [8 D+ [/ C7 Q% s# K2 h
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -0 F/ U. Q5 }5 \1 \" u5 G! p
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。! m- Q/ t/ ~$ S) z/ ?
可以下载到的 是 jdk-1_X_0-doc) [9 Q6 ]! k5 G0 Y" w* B8 d, i
# a2 D; B' A9 X# E3 Q* p6 ?
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-18 11:46

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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