找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1570|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 0 K7 s/ y, }+ o1 T' e& i; s+ v# y. b) T! k% k7 @# O! U/ i% m) f* y1 W
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
7 @; A% K& ?) B% z+ |//  ProgramCompare.java         Provided by: DRS
" Q3 Z" K8 N7 [) i; i$ {5 @//
# t5 L/ [6 o3 s//  Program shell for Assignment 2
5 g+ V4 [7 g1 B2 p4 o//
9 [4 @% O1 r* v/ E) _! @( U$ B% ^//  Compares two text files line by line
* T; D- X) ]2 d$ C. |//*********************************************************************
* R* N$ L% s, F$ p0 k: T+ C2 T6 Z" ~
import java.io.*;
3 X6 J' s# H8 ^/ j# C. i8 Q' l* H2 g7 A, r, O7 s( x; O( G/ {9 S7 H
public class ProgramCompare
  t; n1 d* D& K0 b{+ L3 x" d% }! \  m
        //-----------------------------------------------------------------+ ?$ p" d. G3 M, R
        // Constructor! {# `2 q1 Q+ `) D. ]. a4 g# ^
        //-----------------------------------------------------------------% v: W8 q/ n; }5 U! `
        public ProgramCompare()% \% F9 o7 V" e) f, A& X
        {
4 @8 |1 g* R4 S: d        }
' a: e$ {1 U! Z* d8 G
. t, u  H7 h# V$ J1 N$ u( r! ?% U$ ]* j        //-----------------------------------------------------------------! A4 d  [( }0 r. y
        // Method for testing that class has been reached7 o& \5 f  F" V. A/ d; V
        //-----------------------------------------------------------------       
" x" T" x9 i3 H  i5 y: j9 c
( A- s; @% J$ p8 u2 F+ O        public boolean ProgramCompareReached()         ) z) O# X$ Y% w
        {
) K1 |2 N) S/ r1 ^6 ~8 S1 a( G      try
" a; R2 }2 B3 S0 y6 m   {        
; J$ b( M' J8 ?2 t4 |. s                       
/ x2 f- F6 S+ b# x                //********************************************************************
! j7 Q. v$ m0 ~! C9 g8 p6 @                // Try-Catch Statement is used to handle exceptions - such as file not found
0 t6 S5 z/ ?* h7 j                // Reading the files will need to be placed inside a Try-Catch - just like this one!1 J7 t9 x, }) P% i1 r
                // For more information see page 534 of the textbook
/ k- W. V3 P2 G* i                //********************************************************************$ d# C( b/ V& u( c
                    
7 A, z- a, a6 _, ~% |# x        }# H6 x1 ]* n7 @% x. N
             catch (Exception ex) // Exception caught here and message displayed to the screen , I7 |$ l' z! R9 V
          {3 A' b$ ?. n0 G+ o2 P
                    ex.printStackTrace (System.err);
3 N" w2 X8 h# F           System.out.println ("Error message goes here"); // Replace this error message with your own          . K  ^  t5 Y! B* w* J
        }
  v0 B) }& J7 r9 \. ]                return true;; B  A+ R# V* A* l
        }7 K7 e3 U' y. Y

$ F% `1 t2 B2 \} // end of class ProgramCompare9 r9 o- o  m2 m7 ?

( C& X3 f: b5 F//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************6 [5 Y) b# ^( N; o# S1 H$ h8 h
//  ProgramCompareMenu.java    Provided by: DRS
1 q' M7 U* W" _: w/ a//
+ h- N( I: `( E' f5 I//  Calls AuthorisedUsers.java and ProgramCompare.java
; }2 [. C& v7 v" C" `3 e/ ]: |//
! \5 v' x: E+ \! \1 k9 n//  Driver shell for Assignment 2.
: ?4 ]6 G0 o/ Z) e; ?* g( z2 S( T//********************************************************************; ~0 Q- S1 ~3 [

: |" i6 [5 \7 o( K+ qclass ProgramCompareMenu
/ S& g  c+ O! f$ u9 f{& z; y  |% H, ?0 N
    public static void main (String[] args)/ V9 Z; r9 U) D9 x
            {
5 }. Q  h' ]2 m. f( C. p  \8 w- K- p                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
0 i0 m* I, ]' F. ?% ~                ProgramCompare reached1 = new ProgramCompare(); ) Q" W' z( G/ \1 J! L1 c
                AuthorisedUsers reached2 = new AuthorisedUsers();        9 T7 ^! Z/ W, V* J/ U) I; W" M  L
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
: }* q; E2 [  }: z                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        . v" v! l( K& G" s. ~; l) L6 }
        }
. w+ E3 Y2 {" s7 u5 D}// end of class ProgramCompareMenu
9 f) ?/ i5 c4 t
5 b( U8 o+ L& [8 {6 o, z" l' @//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
7 E" Y. P1 n" N$ S! W//          AuthorisedUsers.java          Provided by: DRS
4 d% ?7 V3 r0 e& z/ M" _//               
" p, P. u9 e3 \//         Program shell for Assignment 27 U4 F, o5 l" {% y( r% W
//0 P$ L7 ~# D  `: ?) O6 z) i. G9 {" R- T& e
//         Represents facts about an AuthorisedUser
# ?* L+ o9 y" a! b5 j! y//********************************************************************6 u9 Y7 \" T2 D- U, s8 T8 h+ W
0 ?% r8 x% G8 n' X$ q
public class AuthorisedUsers! s9 p, o3 V0 P6 J- y+ x& F
    {
. X' h! G& I% K- M0 a: z$ `
- K& t7 R9 v* _. z        //-----------------------------------------------------------------! Q3 j1 q8 Z5 v0 V7 N9 J  d
        // Constructor4 c. A- W& k! N5 E% A: S( ~
        //-----------------------------------------------------------------+ \2 J  n/ G  ^/ _# H: |8 r" n3 P

  D, |3 f0 d  `1 c  i        public AuthorisedUsers()
4 R' [, y7 T+ u6 G' i                {
1 T- n# ?/ \" a* a                }
+ t1 w0 C) b+ h, w( X' v3 j/ D8 U' ]0 A- \
        //-----------------------------------------------------------------
- _( M0 ?/ A. N, f9 C6 P        // Method for testing that class has been reached7 D' t+ C* G% o3 Z) ?1 L
        //-----------------------------------------------------------------       
3 `! I( D+ h  \0 l+ r- J- F        public boolean AuthorisedUsersReached()
* x1 ]* l- {8 k6 P                {" J" X3 B4 J* \. [! c
                        return true;                       
, Y2 ]3 R* v. ], N, ~                }$ g8 H8 B/ U# s7 f3 C
               
+ v' X! @$ h* j, ~' N5 q0 b  _    } // end of class AuthorisedUsers
7 s1 s( A2 V2 `) c% a" `, q. Y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming- ~8 Y: I' h+ V) s! |
Shanghai - 2007- W8 S3 X  A( t! y5 y' ?# K8 w+ y
Assignment 2
1 I" W7 y, g6 H% H5 ]6 y* }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)+ f  W* r- l: ^  k7 O  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.6 [/ }" x! B0 p; R6 C
The staff must be able to:
' q0 |3 u3 X- G$ N" Z6 Z6 F' ]6 v5 r Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
5 D: w1 A9 i- j, K2 r( _/ ~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.0 ?7 e& S+ W* T4 B
 The interface should provide a menu so that the staff can:
; z# _  Z- a$ o4 a& f7 ?- ya) Enter the names of the two Java program files to be compared. c1 T/ K9 x. E
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
" u) P- Y- e7 L- H** 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).
. ]! v5 z! \1 |BSA104 Business Programming – 2007: Assignment 2
3 n- t! K5 e# g8 X# i. ~Page 2 of 53 x, h- f" J' h( E9 f+ e( C
b) Print out to the screen all the lines of code that are the same
% I: [/ @' ~3 v Include the name of the file and the line number of the code being printed for each of the two files
, e# Y' g" X& r. sc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
; w+ M0 l3 a5 y5 m the name, username and department of the user
8 A# i0 }, X* ^5 n4 L+ x: a the statistics of the comparison9 ^/ B! f+ e2 {4 z5 M$ k" e( S
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different% ^( Y7 t" k0 z$ M& |
 the recommendation for further checking2 D1 J8 H! @! t) W
- 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. S# L& L' s( `. F
 the names of the two files compared2 C7 O, T7 G: s, a- w3 u+ D3 s
d) Leave the program (exit)$ R, S1 J) P( T' _+ l
The ProgramCompare class: (Total maximum 20 marks available)7 }; w4 P# v6 q
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)
! c0 r% e- M1 J5 S6 h! ma) provide an error message if the files are not found or there is a problem opening them
6 h/ {  S0 L: i) y; Tb) compare each line of code
, L4 D: j0 L' F1 U( s8 G& v( @3 \c) print out the lines that are the same1 X% _, {0 s$ a5 i# C
d) count the number of lines compared / lines the same& S, M) |  }: n! Z1 l1 F; V! {
The AuthorisedUsers class: (Total maximum 20 marks available); Q' E" D8 c& N
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)
' {( ~8 J, T5 c% Y/ {( @: J$ }1 t( `4. Provide methods to:; K) U# f- w: K& y8 i/ c/ 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: l/ b+ _$ ^' t* T
b) return the name of the authorised user. T6 w) ?  ~- S2 g
c) return the name of the department of the authorised user8 Z& |; _% F: E* L6 I
Individual Data (Maximum 20 marks available)- O0 d6 A1 a" P- c0 Q6 ?
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.
; H. w; k  I0 }* z% ~# KDocumentation (Maximum 10 marks available)
$ Q/ L$ E5 Z2 U6. 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$ U% U  B, e  {! a8 C% |BSA104 Business Programming – 2007: Assignment 2; r) A2 q* @+ ?2 E
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
* j1 l2 z. y' X7 l$ I: C: I% Z6 [不过你要翻JAVA的类库说明。你有下载没有?7 c0 n% o$ s& n8 |. _: b
查询关于对比的函数。貌似关键字是contrast,还有compare
. |; ?. B/ x) w" Y" O# W: v
. B* G4 c! V! f8 v. L' V[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -' J# |3 K' x' d+ C# k( U
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
) ?- B# D7 ]  Y+ u可以下载到的 是 jdk-1_X_0-doc
1 ?6 c( g1 z2 g) x0 ^" \6 r
1 p) o; o4 @1 y4 {2 f8 e9 i[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-24 11:41

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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