找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1592|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 $ b# n: E8 E* g# l/ [6 ^4 L; M+ k4 Q 9 M+ R5 ?& o' W: b
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
* A/ {- p" {7 O. }& |: A* S//  ProgramCompare.java         Provided by: DRS$ a+ j* _# ?, N
//
% r- I: e  f5 m7 N' r0 h' `//  Program shell for Assignment 29 s0 b: g0 K3 e) Z2 {  w4 _5 T
//
1 h0 ]8 p( [& {//  Compares two text files line by line
: l5 c( O( w; C8 _9 {+ L: v//*********************************************************************# L6 P" y2 t0 W1 r
( K$ F! M" s  Z/ R
import java.io.*;" ^1 x0 U1 h9 w: Q- }
  p9 Q9 H" X" q, u, b: b# n2 @6 M9 }7 l
public class ProgramCompare# M- G  m2 N9 v& j' p+ x$ w7 i' x+ w
{( F: S" J, D1 b8 H- `
        //-----------------------------------------------------------------
0 H! O0 t; Z  [2 E        // Constructor
& R: s* p2 t& q1 ]        //-----------------------------------------------------------------( w7 b8 l) _. f/ q) t" D% W
        public ProgramCompare()2 i1 |! W% [) o- r/ |$ J6 S. ^
        {+ p, |9 W. h  T
        }2 q7 Q5 k( H8 v$ p* S2 x) f" J" |
6 p7 o/ ~% ?# D3 u# _! z! C% H0 ]
        //-----------------------------------------------------------------' n7 v& N& n2 t
        // Method for testing that class has been reached
# E) ?6 k% K! e7 n' I! B        //-----------------------------------------------------------------       
7 Z% N( Y. w( w, l& N
  _' L8 Y9 O7 @4 @8 @5 m4 E        public boolean ProgramCompareReached()        
) v; v3 B! G; y8 f/ a0 A; {- U( Y        {
' L' [2 z5 y% Y* B5 e      try
2 E" `- J8 o( {7 l   {        
: Q# R* z2 l+ h3 E                        3 f" v* K1 T- u* N
                //********************************************************************8 u* R1 C) K+ f
                // Try-Catch Statement is used to handle exceptions - such as file not found 7 L- A$ |: {2 K) K, |
                // Reading the files will need to be placed inside a Try-Catch - just like this one!5 v1 M- ?: o8 K: j
                // For more information see page 534 of the textbook
4 Q( }( j7 Z2 C8 h1 q7 h7 d                //********************************************************************: c" M3 `3 }6 b3 Z- G* q
                    
6 g) B, i6 w  ~" S! h5 N& q- T5 Y1 N        }
3 V: \' h. ~* ~- P             catch (Exception ex) // Exception caught here and message displayed to the screen
5 `: n  ?, t! l/ E4 I# F4 W, g          {
! n$ }, s5 x6 p0 ]. F                    ex.printStackTrace (System.err);/ d# w8 ?% L. H, K: \
           System.out.println ("Error message goes here"); // Replace this error message with your own         
3 J& j" A' Z2 S1 A, o        }! |% v7 T/ q9 Y0 d" E: n
                return true;
: Z& m* b8 T' _5 B& h        }( M: ^# g0 c, I* M0 T, _1 S

  l& T* ~# k/ z' T# G- f5 O3 `- {} // end of class ProgramCompare; A) U0 a; w. m8 z

/ F2 M* J" ?3 y( B9 }8 ~# z5 S//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************9 v2 X$ K' G# L  ~7 t' O
//  ProgramCompareMenu.java    Provided by: DRS: B( a# o# V4 z2 F: j  x
//
" C1 j/ w& J" ~! ]; X' e0 W//  Calls AuthorisedUsers.java and ProgramCompare.java
, _3 _2 f# ]) u3 Y8 [* V5 D7 M//( y3 ?. j* k5 s, d, F
//  Driver shell for Assignment 2.9 w5 r0 G" t9 ]4 g  f
//********************************************************************
, _. a7 ~( _6 n3 M- }1 O: h4 U- g/ W8 P1 D8 F$ B
class ProgramCompareMenu
7 X  [3 R" Q. `( r+ K( D3 a; F, t0 G{
' ^7 {0 `! S" u: G3 e    public static void main (String[] args)
/ M- v5 y' \& S/ {- w- x            {
$ ^$ G2 Q' W5 E1 Q3 r                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable7 d( P8 s1 [( S# V* o
                ProgramCompare reached1 = new ProgramCompare(); & i/ z4 m/ r+ s6 K1 K5 t, t! _9 ?
                AuthorisedUsers reached2 = new AuthorisedUsers();       
) g- [0 m* p' I" F6 |6 X9 O3 I+ x                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
5 {0 q. j7 ~1 m1 y8 J                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
0 H+ u; [7 i( Q- O        }
: K( b" N5 J, ~1 i; B}// end of class ProgramCompareMenu
& `& A9 E* [8 b9 K! h
' U6 X, y( \" b" y+ X/ a//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
/ p7 e5 J2 B  _, T: H5 E3 X( i//          AuthorisedUsers.java          Provided by: DRS# b6 D; W/ v9 z2 E' r
//                / g" R' |) J1 b) ?
//         Program shell for Assignment 2* [: C8 f# i* g: z# z
//& w) N+ x& `; A3 L& I. _" x
//         Represents facts about an AuthorisedUser* f% Y2 L- H4 \; c* p; A+ }1 X
//********************************************************************
/ }1 F+ {8 b5 _1 t0 Z' P3 Q5 k( q& R3 R  C) n! Z
public class AuthorisedUsers+ B: H, p. Y8 S, U4 L, K  |6 D, y
    {( U* b  n( m4 T3 b: W

- t5 l$ s6 L" }( l        //-----------------------------------------------------------------+ ~/ i& R5 Q; R$ p3 {9 w4 Q
        // Constructor
9 e! l  K, v9 i9 M% q        //-----------------------------------------------------------------
2 M3 R2 E( n7 W2 `
7 P7 G* r3 n- G        public AuthorisedUsers()) F8 ?/ A1 o0 k; t1 G0 h/ h6 ?
                {
- j) `) Z4 h/ G) b                }
' T" [  g2 b4 k$ O5 x8 `: t" [6 }3 w/ d7 P8 b6 C1 f* T4 U
        //-----------------------------------------------------------------! C* H7 k: O% C( ]- p
        // Method for testing that class has been reached
& S: U8 V  i9 N) ]        //-----------------------------------------------------------------       
$ z* i6 V* [$ \! H9 \        public boolean AuthorisedUsersReached()
" w+ v& b: N% k$ Y0 P8 F) b+ q. z) d( N                {
1 \$ v' Q. |4 @& N, X* |                        return true;                        ! o2 A- ~  c, o" p$ Z" u
                }
9 z4 k7 Z( M, l' I* C                2 q" u9 n  B2 _; [) v9 y# f
    } // end of class AuthorisedUsers, h/ N% E3 m) d, \
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
4 x6 L$ p, c6 c3 g4 @  SShanghai - 2007: n8 e* [$ }2 ^- w! s/ m
Assignment 26 U9 S9 ^. t5 {) \
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)
& ?( v. f) }7 k" _. s- J! 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.
4 }3 ]$ [3 q7 J$ k, f, x% HThe staff must be able to:8 x) j& _6 e5 N+ Z
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.% I* J: ]# d% A8 @4 v
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.
( R* x* y( V! P The interface should provide a menu so that the staff can:! ?7 Z. A) Y9 p
a) Enter the names of the two Java program files to be compared
' G+ V1 h  u/ c) A% \( j For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
4 L; I' u$ n7 e: w( u& E& ^6 e. M** 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).: q( C/ I7 E( o$ r: [& W2 }2 x2 M4 a4 K. Z
BSA104 Business Programming – 2007: Assignment 2
- o% `' _6 z! G' }  f7 S' ^Page 2 of 5: x3 s/ ~6 o; B
b) Print out to the screen all the lines of code that are the same
4 F4 K7 z8 K( q, ^! _$ o Include the name of the file and the line number of the code being printed for each of the two files: z; A4 F+ `( x& |. h
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared# C! s+ W; g9 `9 k% W8 p: G
 the name, username and department of the user+ Q& @1 a  d* \: l# I2 k
 the statistics of the comparison
1 F  t) G7 x6 s9 m- {! j9 b- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
( Y) c! z' K7 I# L the recommendation for further checking/ t  {7 c! a" b. M3 N
- 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
: ]7 \% {- O: J' A' o# \& a the names of the two files compared- z3 B2 `% z1 n
d) Leave the program (exit)/ n& v. ~" b. t% _4 g3 w' {
The ProgramCompare class: (Total maximum 20 marks available)! a) V2 @+ Z/ v+ y
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)
0 I/ E# P  i% n% t: ]a) provide an error message if the files are not found or there is a problem opening them! W$ l! \4 I: N
b) compare each line of code
+ S. D. T( t1 G; d, bc) print out the lines that are the same
) j; o* L/ V3 g: {2 V1 }7 }5 _; Id) count the number of lines compared / lines the same
4 T: n5 W+ m0 t, `2 sThe AuthorisedUsers class: (Total maximum 20 marks available)7 `& y7 `! p  ~. }& ?' O+ @; ~) L
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)3 M/ p3 Y5 S9 X" R
4. Provide methods to:& S9 F7 F+ j; a. 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 match0 A  Z$ h* M. W7 P; v
b) return the name of the authorised user
! c% B& b, v2 ]c) return the name of the department of the authorised user
( {' @( z7 h, o% IIndividual Data (Maximum 20 marks available)6 q& X% P3 i4 X4 ]  U9 g
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.
( p; Y! K' G& K* Y. EDocumentation (Maximum 10 marks available)
& {5 v: X+ ?* W" [( c6. 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.1 J( Z' }: _% N+ N+ S$ a
BSA104 Business Programming – 2007: Assignment 2
' R" q! h& [' c# h0 yPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了/ v& F& Y% K; r  S
不过你要翻JAVA的类库说明。你有下载没有?. q/ z3 y& ~0 s! y
查询关于对比的函数。貌似关键字是contrast,还有compare* j/ f* @* d- J6 f- r+ q# }

3 A5 d" W: X: y7 p( G# ?[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -9 G- b: ]7 C' c$ N4 R) t
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。0 G" L* q9 F0 h! f
可以下载到的 是 jdk-1_X_0-doc& ]& n1 d& t; g7 @
# ~. Q- K- J( Z# V- a0 i- G* b" H# _
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-31 11:48

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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