找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1153|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急& v7 a$ J R0 \6 M- ?: `0 Y! x - U( [6 V: W S! \* v
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
4 @" i; a/ ?0 ]! l. a  @8 R% J//  ProgramCompare.java         Provided by: DRS' i- a3 d8 ?4 T5 @) {6 G
//
; ?- g* D& Y1 E& {5 X. l4 a//  Program shell for Assignment 2
9 [8 H: V: P; X/ r' V/ g) c//* I- J4 R3 `+ p( l3 |3 {# l
//  Compares two text files line by line& D* S  z% F2 B$ D; `2 D. S( ^9 C
//*********************************************************************- `0 ~5 O( w" J# k$ s
* O" d: [7 s7 w& t/ P# b# I. V
import java.io.*;
' U- B6 u% C" ?2 x5 X4 r1 k& u9 K8 a" I. c6 b
public class ProgramCompare
6 V/ e( @+ H8 f" w2 P  N{
) p. G: A- Z- R2 D# ]4 s        //-----------------------------------------------------------------
% ~7 {) o0 H$ j5 \, n( l        // Constructor
# W# r$ v5 s3 I6 @& H, n* ]! y        //-----------------------------------------------------------------
# u" a. i% C9 G" g- f5 ^8 C        public ProgramCompare()! t& P6 q* p+ u6 ?1 f0 Y9 l
        {1 r) k5 @/ ]9 r
        }4 Q' T2 J4 l, A& q5 a1 D8 O
* N7 J5 S3 Z9 z
        //-----------------------------------------------------------------
* U  Q$ F1 O. z        // Method for testing that class has been reached3 I$ O: A( g! i+ z- {$ }7 _/ o
        //-----------------------------------------------------------------       
6 ]+ {. B& b' T. I- M/ Z1 q) }' j  F) o( b0 Y- z$ y; P
        public boolean ProgramCompareReached()        
0 V& }. z. T; M; X' G+ j        {; }' v+ e" i, a% g% h7 h0 B1 D+ P
      try
4 o+ ]0 z  ]- G) ]. _. }0 y& e   {         7 m6 i: S: O$ A
                       
' c. x6 u  B  t% |                //********************************************************************/ F6 d9 _' @( i
                // Try-Catch Statement is used to handle exceptions - such as file not found
& S6 S' G- M4 k) ]* U0 \5 P                // Reading the files will need to be placed inside a Try-Catch - just like this one!
% x3 g! K: J2 M1 A1 H* l                // For more information see page 534 of the textbook
( x* ~7 g$ n/ n( T! P: q9 ?" x) w                //********************************************************************" I; E* y7 b3 y
                       ]# y# F* x4 D" q9 B
        }& Q) a1 |4 U! m5 C8 J" {  x
             catch (Exception ex) // Exception caught here and message displayed to the screen & |3 {& X) z. w/ D& b
          {
3 a7 C7 b. L$ k. ?5 W                    ex.printStackTrace (System.err);3 N2 P6 r/ f) e! Z
           System.out.println ("Error message goes here"); // Replace this error message with your own          , h! Y. I2 \! H3 [
        }5 F( E3 v# X# Z! P) Q
                return true;" d8 \9 c9 N- Q# M, `/ W
        }
1 a7 q: Z8 P- {' \! B; {1 |- G. }+ S2 h% c
} // end of class ProgramCompare' f9 e2 |6 S1 S7 o0 A

" K3 |0 K# l  r//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************! r' E, O) {1 X' O" N; [
//  ProgramCompareMenu.java    Provided by: DRS3 ~* r7 Q7 M( f0 H+ j
//1 ~0 W8 C* T! O# r- K7 R# [# B
//  Calls AuthorisedUsers.java and ProgramCompare.java! i/ p2 u  s+ [6 `* r/ `
//% v( v7 g) w/ r; o* D5 v# p6 g4 j
//  Driver shell for Assignment 2.$ w( @; l) G. M# K. a
//********************************************************************. v# @2 a* w  U( b( J$ f

% T8 o' H) y+ C0 L7 j# c/ y7 b) k; f0 K4 Qclass ProgramCompareMenu  Z1 ?1 f' ]' w1 B& R
{
% ]/ B$ j) q1 p# C/ B3 F. ?    public static void main (String[] args)0 L1 ]9 k7 W* s- ]
            {/ U' x+ H' M3 I& q  K& b! \: n9 E
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable' C" \3 F6 U4 v
                ProgramCompare reached1 = new ProgramCompare(); ! W3 n* b4 ~, H3 ^3 {, }
                AuthorisedUsers reached2 = new AuthorisedUsers();       
* ]/ }6 ^- d6 h, s+ c7 b. B. F                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
1 u! P; S  N, [* }$ C3 D8 }0 N% f                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        & @- }; U- g8 i( l& r
        }
7 ?" f1 G1 k4 h1 Q% @5 W: C9 B/ I8 \}// end of class ProgramCompareMenu( {& Y/ |- _# G3 t9 w
' E8 [: f8 n8 m6 I+ S  }
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************0 h* P1 J( f! c6 [& ^- D
//          AuthorisedUsers.java          Provided by: DRS
7 ^- `2 g, i! b3 ~6 F+ ~3 x//               
$ h0 s  J) ]- @: V" |3 I" C% h. z//         Program shell for Assignment 2
  \9 c" M# ?4 }; N% r//; J5 g+ R0 K! V/ l
//         Represents facts about an AuthorisedUser
& r) A/ H0 c2 f//********************************************************************  s; O% j! D* @) m8 ?+ z

: I8 e0 I' R, y: o# e, P' opublic class AuthorisedUsers  P" P% B+ b- o. {7 m  `6 A
    {7 t3 i0 E$ x5 x  j% F
6 z1 a9 ~6 }7 b) t; }
        //-----------------------------------------------------------------
7 v/ q) U: v" {        // Constructor. k: r: T0 M8 o8 L5 J' I3 @/ Q
        //-----------------------------------------------------------------4 M, r* Q( d- b- ~$ P+ Z+ p1 p
7 h" ?" X% ]7 h
        public AuthorisedUsers()
( V# f( O! X/ y4 F4 S% I1 T- O8 h  {                {) H/ v8 I* p( O. _# ]% I$ F
                }' Y% O3 }1 ~- ~  ~( ~
& V% F, }6 @2 f/ m% |& U
        //-----------------------------------------------------------------+ p, w8 e* D# l* e) k; ?0 K
        // Method for testing that class has been reached
3 m8 ^4 \, O; e1 H3 {( X        //-----------------------------------------------------------------       
1 W& y- B6 v( v' E8 O        public boolean AuthorisedUsersReached()" A; C. `; `( m' p2 p  P
                {
; N2 a; `- O* F2 D! g                        return true;                       
9 ]6 x( f4 M7 ?  `2 K. E1 `                }
# e9 y" H. }  S9 h4 ?2 D               
5 T4 Y$ x8 ~0 u3 l    } // end of class AuthorisedUsers
( m$ b5 v1 y! O7 Q9 A+ I8 F//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming. K5 X# _6 k1 D% A- X3 M' t
Shanghai - 2007' n$ U! a  L+ x9 \) e" x
Assignment 2
; S( }# I5 R% L/ IDeadline 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)
: X/ d. S2 t! f; K# z/ a% n& q5 ~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.
9 `. x" K* h! T: Q7 ]The staff must be able to:
: y9 [# f+ d: F* H# p Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.9 x( Q6 o4 s" @
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.
* H3 S6 Y+ @0 u6 z The interface should provide a menu so that the staff can:
, Q; ?& p0 W, R& l: Z7 }a) Enter the names of the two Java program files to be compared$ x# v. G2 M  I6 G' J2 s1 s: R
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.0 V; R3 F9 [6 ]6 D0 E( r) d
** 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).: g0 W% ~9 `: r# u4 ]5 |
BSA104 Business Programming – 2007: Assignment 2
8 ~8 ^' D2 k! C+ N$ G, W5 N, @Page 2 of 5
1 k0 l8 s1 Z& V5 T; h/ r- db) Print out to the screen all the lines of code that are the same8 n* O9 l- f" w) C/ j% G# h3 `
 Include the name of the file and the line number of the code being printed for each of the two files9 c3 p8 }! G& M6 O: d" P
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared& i3 ?" M* F; |# }" m( `8 j3 f" g
 the name, username and department of the user8 L& k  S8 D- d9 G6 A9 _: S
 the statistics of the comparison
3 X. _, l+ g7 |- W% C: l  g5 x- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
& Q( p6 L4 T+ g8 J7 ? the recommendation for further checking" Z! o* B: u7 c9 B4 j6 A
- 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 closely3 }9 k" A& b3 `0 o% D* P
 the names of the two files compared0 [9 v; K; Q/ n  L
d) Leave the program (exit)
, P5 v2 n# A! c2 lThe ProgramCompare class: (Total maximum 20 marks available)
( m' a' A4 D0 }) ^* u4 e7 B2. 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)" y, c8 J+ H1 S5 @
a) provide an error message if the files are not found or there is a problem opening them
. a" V: x: o& P% I4 U6 |. t/ U# Wb) compare each line of code/ ^, A; x7 p1 `. m
c) print out the lines that are the same% u8 R. a3 o  {" F& C4 z! Y
d) count the number of lines compared / lines the same5 f( @3 C/ P. L/ Q/ G0 ^
The AuthorisedUsers class: (Total maximum 20 marks available)
( P$ e! A, I2 \5 Q6 a7 i" y3. 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)
9 B- r: M5 i, A. ~1 ^3 j( E: ]) x4. Provide methods to:
7 g  y7 E) f3 }4 u: k8 Da) 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* ]/ q4 Q7 R+ D2 n0 Eb) return the name of the authorised user
2 K1 }; J8 r% oc) return the name of the department of the authorised user) e' N- d$ p  H/ F( c1 e
Individual Data (Maximum 20 marks available)
: ~* ^! i7 l7 v, r5. 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.
! d% @& r6 |: Z5 nDocumentation (Maximum 10 marks available)
6 _9 j' w# P: Y# y6. 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.* [( t8 ^4 c* C3 W
BSA104 Business Programming – 2007: Assignment 2
0 r9 O5 B* M# W& `' kPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
+ l; e  V! G" S7 J: E+ p2 w0 w不过你要翻JAVA的类库说明。你有下载没有?
( A& O: v( o( r, d, _! }  U查询关于对比的函数。貌似关键字是contrast,还有compare
1 u4 t: l  h1 Y- P1 T/ O+ T# [3 N& \$ J  E& W( x5 O0 M0 k1 a( H
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -6 A3 N) @) U" m
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。% ~3 g  ]( {% z5 J
可以下载到的 是 jdk-1_X_0-doc* U7 n- {3 a) U$ T
# \2 o/ K* T# v) _* ?! N8 h
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-2 03:36

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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