找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1004|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急# [' A. x6 Q6 V9 N( e9 Y8 i 4 P% v, V T q* G# H( e1 j5 f
回复

使用道具 举报

 楼主| 发表于 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 q) r7 u1 p: `, X( N//  ProgramCompare.java         Provided by: DRS
4 J. v+ p$ k( u+ p' D! ]//
9 C6 i+ L' V" S9 I( A4 a" `//  Program shell for Assignment 2
' g9 z3 C! A) ^- f1 L1 n//
5 j3 Q) \/ o6 h* E+ D//  Compares two text files line by line
& f7 s! y$ x" \% F: q. x/ o//*********************************************************************# f% m% o$ \+ Y3 n5 x
7 J; |3 o* x; s/ i
import java.io.*;! w6 y" f1 J4 [1 ]# V$ x+ ~- v

9 ~3 g# B* F/ J* M) P4 V) Hpublic class ProgramCompare
, X# j- b7 P1 L% T{
/ i: f/ w8 ^, y        //-----------------------------------------------------------------
1 r) L7 H. A+ C  I        // Constructor
; f0 `2 e: s# g        //-----------------------------------------------------------------
2 _( Z1 p$ h1 N3 f4 Y; [5 h- I; e        public ProgramCompare()- Z4 a% \& q) @. g3 i4 N3 N1 {
        {5 ~8 I: F8 R6 w1 {1 }% \
        }
3 z$ `( t( ?$ E. _% Q9 A+ \% o. P/ A$ s7 a1 T! K, W1 K
        //-----------------------------------------------------------------
$ z4 ~$ ]4 l/ u' E7 n        // Method for testing that class has been reached
4 W2 a" T, e7 M6 x, c& e" Z        //-----------------------------------------------------------------        1 O* v% Z. d2 j

2 A6 X, ?+ d7 g2 k: E6 K        public boolean ProgramCompareReached()        
6 Q: E7 M' N1 Q+ v6 ]) a( n9 w+ I' m        {
8 a( ^6 j# \; P      try # T" e. W6 f% H7 u9 m* i% R
   {        
' |4 P  |* q5 h7 N                       
. ]6 W) w# o" |+ Y" r+ t7 p! A( [                //********************************************************************
; ~; Z7 k$ w* I                // Try-Catch Statement is used to handle exceptions - such as file not found
6 ]9 m3 G+ }( U$ h& Q                // Reading the files will need to be placed inside a Try-Catch - just like this one!0 ^% @4 ~, U! X2 u& U) I
                // For more information see page 534 of the textbook- q2 t+ S5 J2 A8 W; V  ]
                //********************************************************************: u8 _! b4 D. f: ~& x1 g0 m" ]
                       y) a" j" H, x! w; m2 P2 v
        }
# e# O) U" P2 V- r' |; g3 c             catch (Exception ex) // Exception caught here and message displayed to the screen / G" Y# }4 I. k3 o' J/ W
          {4 B- S  _2 Y- e6 Q# J$ y+ j- K- t5 C  x
                    ex.printStackTrace (System.err);
+ c, K- o5 b; d3 ]" j: u! V           System.out.println ("Error message goes here"); // Replace this error message with your own          1 t- {/ @1 h! Z+ ^% S& f" O
        }
' O0 R* o2 a# v* S% V- L6 e/ L                return true;
/ k9 k! m7 |! n8 u" s( S' Z        }
3 m* s* x7 B2 ]& b. ^! [
6 a* ^8 e  g9 n% k. w, f  x} // end of class ProgramCompare
) E! L5 M4 r) `; ]
8 q$ c4 ~0 |  K2 s7 k1 d9 m//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************8 e1 S. ~5 i0 O
//  ProgramCompareMenu.java    Provided by: DRS
/ V% {1 M% {" k: }  P, J" Q//
. H+ V. A5 e# V; E! h- `//  Calls AuthorisedUsers.java and ProgramCompare.java
' t+ p/ c( W; z, k* t3 U//# J1 e  p2 J4 Z* u/ k
//  Driver shell for Assignment 2.
# I7 p/ V2 R% b8 [( q- S8 r//********************************************************************
, t  ^# Q* @6 j' @" N. z4 U" n3 J7 Z! P% q
# r4 a' N, v) r/ r0 Nclass ProgramCompareMenu( ^! Q. t* \  u0 ^8 i
{4 j4 w6 l, J& O; p0 f% C
    public static void main (String[] args)
, [7 q7 P1 ]* _, h) ?            {4 \: A* E5 ]7 T9 e* w; P+ G* s9 I
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
* o, X* _0 b6 ~4 c3 j                ProgramCompare reached1 = new ProgramCompare();
# P0 _0 j3 ~' r3 r' ]  y                AuthorisedUsers reached2 = new AuthorisedUsers();       
7 P. @5 d2 |  S- `8 n                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
) X+ w* p9 b; B5 R                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        5 I1 l2 G1 X; z  }4 y
        }
1 Z' l8 y3 l1 k}// end of class ProgramCompareMenu' L1 a4 y" O) N; I( \" q

7 q& [" ~  `, p. X' y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
4 H' N2 T, o- @9 w+ Q//          AuthorisedUsers.java          Provided by: DRS4 i3 {5 U4 k6 g7 o2 \1 m" n
//                / K5 q% g0 @( x% e3 e9 b# J
//         Program shell for Assignment 2
* k+ Z  z2 O: m7 \" N& G: p//; U2 ^7 R  D3 k+ G; ]0 S0 K
//         Represents facts about an AuthorisedUser
4 V8 D6 d% _; |0 {. u: V5 N1 d//********************************************************************# R% T3 t) r" e$ X. G3 u
! {/ b; x/ \+ Y' {1 V3 \
public class AuthorisedUsers
, U  {  P! N% M# F    {
/ [  c) O1 h9 ?0 E9 ~* U0 p  v& ^
" T. z2 p) p6 m  Y        //-----------------------------------------------------------------* i1 D, E3 p, y/ n8 H! m
        // Constructor
$ T2 O. O  s2 o9 A        //-----------------------------------------------------------------
( U. [- {8 H1 X! p& _+ G4 p; ]/ x+ T1 N1 C# f
        public AuthorisedUsers()
* ^+ o2 v6 j  ^7 V9 I                {4 w$ V7 m. c4 g- ]* S
                }7 H$ @7 }3 I% o

; h5 v" I  X) U) q& H' ~        //-----------------------------------------------------------------. E2 {0 `# D" C/ V0 w: A
        // Method for testing that class has been reached* l- l: d, r, C/ r8 M$ k. u
        //-----------------------------------------------------------------        ; I& |$ P/ B. H$ ^7 p
        public boolean AuthorisedUsersReached()
$ H2 H& @" u7 ~2 A                {
0 m! i! {9 ^0 f- ~                        return true;                       
# Z7 y1 ~, V( ^                }
6 p, C7 t4 \# w% v. g  T+ m% Z               
0 ~9 M' A7 D  |1 o4 o    } // end of class AuthorisedUsers
& @* ?$ \; d. }# I//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming* _. G4 ^) O2 @# _! R- X
Shanghai - 20079 b5 \+ k2 z3 `$ ]* u% F7 `
Assignment 2
+ L, h" K8 `' 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)( W5 W" w( h- u: @5 _
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.
1 E5 W  ], c7 oThe staff must be able to:
5 C# }! S4 A& A4 J" L Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
! p, p7 {' k- o/ j+ |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.: d+ s$ _) n% b% W3 f' c/ f
 The interface should provide a menu so that the staff can:
0 e% o: {* T" y4 L, y6 M, a( Ca) Enter the names of the two Java program files to be compared; |4 T* c9 i8 G1 c% M. i+ C% |
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
6 p# ^2 K' c$ F# e7 I: h, L** 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).4 L- c& w# M" d0 P5 Y
BSA104 Business Programming – 2007: Assignment 2# P/ N, G7 R% W5 e. g
Page 2 of 5
6 X8 A) H& [- I* E3 |; u0 Y( j' Rb) Print out to the screen all the lines of code that are the same
6 ~/ i; @. \# x% ~3 M Include the name of the file and the line number of the code being printed for each of the two files, `0 B& I* K- K) d! w# r
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
2 i( r. P- m5 T1 P the name, username and department of the user8 c! P4 F, V% J* ~8 s
 the statistics of the comparison
! k3 e+ m% h( F$ I/ _: `- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different: g6 T) [0 v" }0 o* c% w% O, h4 }
 the recommendation for further checking) M. t% ?( L) T" g! {9 m4 `& g
- 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
3 O1 r* I' z$ d5 }1 m5 L9 R the names of the two files compared
( g2 I+ [7 t: ]9 z/ I1 E8 nd) Leave the program (exit)
# y0 p6 }) u# MThe ProgramCompare class: (Total maximum 20 marks available)6 x, H) v' Q! [' f3 n" _. U$ y) O
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)/ \2 F& q4 P! f6 `, l/ m* d" }
a) provide an error message if the files are not found or there is a problem opening them
- B) h4 w& L  Q8 C' {+ X& {b) compare each line of code" \" }/ q4 L/ |9 p( L
c) print out the lines that are the same0 X' j) h1 T' i! c
d) count the number of lines compared / lines the same
& `% O9 ]) ^. X" l! t: w+ Q) T% MThe AuthorisedUsers class: (Total maximum 20 marks available)
0 [7 L; ]# \6 _7 K$ l% Y# |2 a: p3. 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)6 s1 }; C) }8 x* u% W
4. Provide methods to:* _/ e" V1 V/ J7 k- g( R3 _
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 S. S* _" c+ P6 R
b) return the name of the authorised user. x1 P! x0 \% ?* q; c
c) return the name of the department of the authorised user2 k7 U( A! i/ l) P
Individual Data (Maximum 20 marks available)
; u: z' f$ h( q9 N- t% t% ?# M0 n5. 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.
: O3 i+ B7 F( r+ q' q; yDocumentation (Maximum 10 marks available)
7 _; ~( |5 j3 |8 t6. 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.
  ]  D( H* n" [6 ]# b# ~BSA104 Business Programming – 2007: Assignment 2) f7 @: E% x$ @1 q, B8 D
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
8 H1 s, @8 f2 O不过你要翻JAVA的类库说明。你有下载没有?+ x! j% n) t* |6 q0 e+ p+ P
查询关于对比的函数。貌似关键字是contrast,还有compare
' g7 c% J  M: y0 p$ y' H* c+ G, z6 e8 D3 O* ]
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -5 x# V' r, e& i2 |
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
8 D' L; U2 t4 s' g' K$ l$ p; L* x可以下载到的 是 jdk-1_X_0-doc& h8 g1 D- y( v: n' T" U8 e+ A6 ?

$ j% P  U4 [8 O9 n7 _[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-8 02:45

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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