找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1804|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 # H( u u7 D0 c3 ? ) Z' a9 S2 W7 H8 {
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************. a6 G" H8 O7 S, a7 Z* a3 O8 Z
//  ProgramCompare.java         Provided by: DRS  e' e' G% O& S+ v
//- R5 y2 u* s6 Z/ z
//  Program shell for Assignment 2
! R! t: {3 W( k% [0 q5 G//8 _4 S% ~# P  t4 F& R) s, w4 I
//  Compares two text files line by line
& p6 K  D4 o# }$ L& W2 l; P//*********************************************************************
: z3 M1 }6 J# G+ `& _& q' E$ u# ^- F: w6 M% k
import java.io.*;
+ s! p+ S( m+ k; U8 r1 C# V4 m4 \5 A' i. M  V7 O* i4 C
public class ProgramCompare
: F5 _( t6 ^! h8 B7 c' p0 d* K{( R: ]; c- G, X8 h/ |5 |
        //-----------------------------------------------------------------
, ^( q% }$ s; f/ k- x- \6 p! a        // Constructor, g7 t+ v& F- o. q) t; k
        //-----------------------------------------------------------------/ e) v6 N+ {: k5 l
        public ProgramCompare(); r% e0 a$ d# V6 W
        {* r' y' v/ A/ y. s/ J
        }( H6 @5 l  N2 e4 e# B! N

2 [6 k! @; z% L1 p+ o) j0 L9 E  r& h        //-----------------------------------------------------------------9 y! [* S$ {7 {6 e# z8 r
        // Method for testing that class has been reached# o8 a; j% A* p. E. ?, `
        //-----------------------------------------------------------------       
5 x% B# Q+ l1 V' R- Z0 I( t# A" k' ?3 ?/ i0 w( l- L* ?8 d
        public boolean ProgramCompareReached()         8 t& v3 `. Y# L. {6 b2 V2 j* J
        {
( ]& z+ C0 R: e  s5 _: W      try
' x& i4 z1 D& d) h7 K   {         1 N9 j% \  K( \( I4 p+ N, h
                        6 q4 @- J) B. ^2 i! @8 H: f7 s
                //********************************************************************
' Q6 a! j7 s) p                // Try-Catch Statement is used to handle exceptions - such as file not found - L! y5 W! B+ P& L' j
                // Reading the files will need to be placed inside a Try-Catch - just like this one!1 }. \) H. P8 D& W2 D  i/ P/ O: ~
                // For more information see page 534 of the textbook
( Q" ?# G) J: k1 P9 t, G                //********************************************************************
% `( A1 x! A$ @* E# f! z6 W- ~                     " r" R* _+ _6 K7 A
        }
7 q( @+ g4 u2 L* K9 G( s             catch (Exception ex) // Exception caught here and message displayed to the screen 6 l0 ^' J# z$ e- y9 c/ W
          {
+ w) X/ N+ b; v0 J; ~: w1 T& G" h! b                    ex.printStackTrace (System.err);
7 c" h7 q4 w: j& v+ V           System.out.println ("Error message goes here"); // Replace this error message with your own         
! }! Q/ {' R6 A, T' ~        }
6 d% d0 n, K! _2 s                return true;
7 \/ g+ M4 W: O, E9 R+ ~" e        }
; y8 V1 j0 k+ r  ^) o/ F4 e/ j
7 s+ o1 K0 I( A: w. Y' I$ H} // end of class ProgramCompare
4 e) o, J# W& Z( P5 z
4 r* e, ?% \+ Y- p* V/ n" ]5 ^//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
1 u+ W# q( K# o! j# H, R//  ProgramCompareMenu.java    Provided by: DRS
. x4 k( I$ G5 K7 _$ j! Q//0 P& u: P- O9 x6 j
//  Calls AuthorisedUsers.java and ProgramCompare.java& P8 l' x& ~3 @* u8 a& q
/// B) S" ]4 f, w. M8 e5 o( h
//  Driver shell for Assignment 2.
8 I8 b. V7 L: ~, K) H7 K& t& K" P//********************************************************************
7 R, V. Y3 g& z; e# c
* G- F- g4 _4 q( V6 @class ProgramCompareMenu
* O  V  ?9 l( J1 I{
7 w4 @% J4 a( R( E  A# C+ o0 I    public static void main (String[] args); t: y& L7 L% r5 o$ Z# M
            {
9 \8 k0 _2 {7 Q( h                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable* J( ?8 t1 w5 k  |7 q
                ProgramCompare reached1 = new ProgramCompare();
' m. v2 ~3 p( \: y" _                AuthorisedUsers reached2 = new AuthorisedUsers();        : v  r% z! c; P4 W! a9 P
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
# d  s* N4 |) Q/ ?, Y                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
/ e' Y3 d8 `) [: f3 t2 b! q! I8 v4 K        }' K4 @. X% p' g4 G/ A! I3 E
}// end of class ProgramCompareMenu
8 H8 c# n; T3 U9 y. R7 o+ A0 i* W) O6 Y3 x9 I, U2 ?. t
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
$ K! e( C/ q% o/ ^* L* P//          AuthorisedUsers.java          Provided by: DRS
5 d$ d9 X, z  r: w//                : I# G% `) i5 T* ^
//         Program shell for Assignment 2( k  f: y- ~0 W8 `4 S8 }
//- S1 |& N# g; a# g/ P+ ?# t
//         Represents facts about an AuthorisedUser
" }  g! s+ b1 t" V//********************************************************************
* W! F7 D0 o7 {" Q& \2 `  ?/ c. C
/ b/ s, _) a: P+ H/ X- Apublic class AuthorisedUsers% m6 ^- z3 c+ h# O
    {( i1 [' w) ]: ~* o& J
& i) e3 u4 r4 ]$ i2 |6 `+ Q
        //-----------------------------------------------------------------4 w4 W. s2 U1 V9 k# _" U- A0 Q
        // Constructor% X; L9 t; \1 g
        //-----------------------------------------------------------------$ l% W: S! k" W* o4 I

5 j* d% y# p( k0 ^        public AuthorisedUsers()
0 y" p& O7 \" w: K' i0 I: t5 w" y9 h                {
1 j" v% H5 r& l  W) _2 R& H2 X/ [4 [* U                }
6 a  z6 I3 j( }, A+ j
4 u$ R- v: W  P5 ?+ D        //-----------------------------------------------------------------
6 L* A  ?3 E" ]. S        // Method for testing that class has been reached
! I" f3 K  H" b8 G        //-----------------------------------------------------------------        6 |) t2 [6 u1 c5 B4 }
        public boolean AuthorisedUsersReached()
+ g* N% y  D$ h6 p5 s                {/ l6 _6 p; i) }$ E  }& i
                        return true;                        1 a- ~( s$ N  o+ d3 y
                }2 `$ {' _. b# {) r) w
                & ^) V5 r3 R' _0 d
    } // end of class AuthorisedUsers
& t3 Z. Z) E3 s& N  o, l7 }* t9 i//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming# V' y7 `- Y: |/ d& I
Shanghai - 2007
: A0 F! y3 }( z) r  R5 G) Q5 v% OAssignment 2/ G7 X$ `2 c1 `) U
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)
/ r4 S& V" ~7 o4 R, Q( o+ @" `5 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.
1 r- J' \" i  cThe staff must be able to:( ]" n. ]+ ]+ O+ }6 {! F5 u7 W
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
* \4 C4 z; r" Z8 Y" D% D. s1. 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 Q" _3 Z( e6 t+ l4 H% h% o1 {5 X
 The interface should provide a menu so that the staff can:
7 w7 S- h: E" ?a) Enter the names of the two Java program files to be compared
" S$ I+ Q" p! H( T0 u# ^& D" w: { For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
8 E. T' p4 i0 w" {  ~4 O** 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).
' z# X  |1 w( ]5 T' S% eBSA104 Business Programming – 2007: Assignment 25 F. j: s( u" K0 @5 p7 v7 ~* O  y
Page 2 of 5
) Q! w; g7 b7 R* ?b) Print out to the screen all the lines of code that are the same
7 D( _4 t- r; S% `, r Include the name of the file and the line number of the code being printed for each of the two files& z: Q0 [/ n' t9 f# {' Y; Q' O# F
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared5 h7 e9 W* h/ I
 the name, username and department of the user
; f- _# Q# u  n0 W( D the statistics of the comparison
" [0 z  E% q+ y" E. K/ q$ n5 I$ X- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different; b8 {; Z, Y0 X# \: Q$ h
 the recommendation for further checking8 y5 c, }; w* o0 @9 f. k3 \4 B  k
- 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
/ T" f" U% g- U4 E4 x9 Z+ ? the names of the two files compared7 q& j% l7 c4 e) u
d) Leave the program (exit)& U2 A! e7 W6 _5 k, ~* Z0 T0 K
The ProgramCompare class: (Total maximum 20 marks available)
* r. F' c. o: u- i+ H5 Z0 j2. 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)' E# u- z' b6 U. r# P+ z
a) provide an error message if the files are not found or there is a problem opening them
7 _. G' N- ]7 F6 Q8 eb) compare each line of code
* D8 h- s: W* w/ x$ @c) print out the lines that are the same
& a. E8 @  d9 a1 v( id) count the number of lines compared / lines the same
' O9 z' p% x, F* M0 nThe AuthorisedUsers class: (Total maximum 20 marks available)
  }% W! p: z4 w- n$ Z3 `# m: D3. 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)
( g- q, [1 ^& g1 R' a4. Provide methods to:) _4 L% L3 [7 n8 g+ {( L
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. a" X1 c/ U3 c  S  m- k2 U. `
b) return the name of the authorised user8 J, }/ e/ y, C" v8 _: O
c) return the name of the department of the authorised user
+ X- n0 }2 p% {Individual Data (Maximum 20 marks available)
- r) a1 }6 ]' s8 t3 J0 j- ]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.
/ W) g: ]; t3 F) C; iDocumentation (Maximum 10 marks available)% f! z1 H5 Y+ g4 X' d' D- G
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.# I, C+ M7 b+ M: E# U( o' V
BSA104 Business Programming – 2007: Assignment 2
& Y  f$ t/ w7 T- P. }' m6 T; `Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
* a/ }2 M( {8 K- X& T" Q1 @  D* \不过你要翻JAVA的类库说明。你有下载没有?1 a' P! B9 [# P9 j* @( B+ R
查询关于对比的函数。貌似关键字是contrast,还有compare
" O( h' Z& X. a5 S: _5 j& B* C9 \+ U# t8 ?$ j3 f# H0 f
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -5 Z: ]" h6 p- y- A
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
) F; _; h+ C0 }% {" \可以下载到的 是 jdk-1_X_0-doc0 k9 \% u0 ?2 L7 ^

( _0 t2 h9 S  v. _$ U[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-6 22:22

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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