找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1158|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 8 B9 k. [* o; q. X9 ?$ C/ S B1 c6 T" v; Q6 c l0 a5 @
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
; t% Z9 U" W9 l  X8 x* n//  ProgramCompare.java         Provided by: DRS
: l. o' U; E1 \8 C& L//
1 T5 {7 A( f* H6 q: b& x  p//  Program shell for Assignment 2! \- A$ k( p! z
//
2 @# f+ k6 j* e7 H4 I; n//  Compares two text files line by line
) S& G. l' p1 Y1 k, t: b//*********************************************************************
$ P# q( ^( k9 r
9 I8 U, N/ P( X4 k& h1 N' ?8 d" ]import java.io.*;
" ]. u8 M2 q9 O2 y2 U" j- ^
6 K9 d5 }0 Y# n; hpublic class ProgramCompare! C% p/ h( ]8 J# i& U! d8 \( c
{* p/ ~% `( Z3 O8 P
        //-----------------------------------------------------------------
3 u2 X1 S. Y# e( g9 d        // Constructor) x: u, m$ Z, W& n1 \
        //-----------------------------------------------------------------
; B- p  T4 o! O& Y1 b+ W6 S        public ProgramCompare()
0 d+ q% m: g# C* d: |7 I/ n        {
: E  y2 C3 a  m1 }. R        }
9 t4 H" C/ S. q2 y
+ x6 y9 {1 I+ F' f6 u        //-----------------------------------------------------------------2 I; D4 E8 L: |& Z, ]3 u- A6 L
        // Method for testing that class has been reached
5 Q/ H: F# |. q        //-----------------------------------------------------------------       
; n- d4 d1 U) u+ h: O/ Q
# q  c* p6 R- C        public boolean ProgramCompareReached()         ; Q! g* d& A7 W  K+ R4 m, P
        {
5 I+ ^7 X% d+ V/ R      try
5 z9 _7 q4 Q3 ?( _   {        
  {6 N4 i! X* n4 n. v. a% b                       
, ]2 C$ X. S3 A- X                //********************************************************************  J9 |$ C- Z) Z! A" {& X: a
                // Try-Catch Statement is used to handle exceptions - such as file not found 0 k6 q, J% d5 e# M
                // Reading the files will need to be placed inside a Try-Catch - just like this one!: U0 o. T- o! b
                // For more information see page 534 of the textbook
0 X  o5 @/ v9 D4 C3 W& b5 T                //********************************************************************# a7 G  |2 y/ f+ U' o' D
                    
; _# W* r$ F  Y1 G3 C        }
9 d5 w6 q3 G+ n- g" n% Z6 a             catch (Exception ex) // Exception caught here and message displayed to the screen
3 I3 C8 c/ H2 v4 Z          {+ ^2 S) h; W7 V- A- U
                    ex.printStackTrace (System.err);
& `1 J& }# F# W- x" l3 A  Q           System.out.println ("Error message goes here"); // Replace this error message with your own         
+ {1 C. L( M: S, d1 K        }
' ]) K5 T! d% ^$ y$ i9 N3 h" M                return true;
4 A- A. l. D3 ^6 ~8 z5 v        }7 a/ D0 s1 M7 f4 A4 J

) }9 d. w# w! I9 m. U, b} // end of class ProgramCompare2 B5 F* e4 D( o$ ^* t; H# {3 k1 y

2 M( `( H: s) A% i" Q4 Z//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************# X& B/ q: m5 q: I% q. [* x
//  ProgramCompareMenu.java    Provided by: DRS* j" r. |: U5 b( P1 ^7 k
//$ @5 Y" q& W# w! p/ y
//  Calls AuthorisedUsers.java and ProgramCompare.java; \5 D0 `8 F% K! g
//* E: ^, B: n. Z2 s% I# n" g
//  Driver shell for Assignment 2.
- M, o/ H- a- X7 H//********************************************************************
3 p& x1 V4 T; Q( }
; {" }. m7 l& v$ P/ s; ]class ProgramCompareMenu* _& y. T" u; Z' h4 a
{
1 L/ v' C; s& h. G7 a    public static void main (String[] args)
2 W! Y' `$ Y4 I) n" U* l3 a            {
. B  a+ T8 j" w0 B/ v$ P                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
8 k- k# M( v, Q: {9 M! ]7 s                ProgramCompare reached1 = new ProgramCompare(); . e* `' J4 p2 v+ V
                AuthorisedUsers reached2 = new AuthorisedUsers();        ( w( }  _- f" y: H# p. }1 m- [9 c# Y
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
# q5 _; s8 N' p) E$ l% D9 k                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        9 }4 Z+ r: ]5 f4 M3 A" }; j
        }
. |) ~/ F9 @2 S- X3 e0 o}// end of class ProgramCompareMenu8 {3 n0 k% C9 T" W' [7 u

5 ~% K7 o! k% s" ~2 ?3 q( F: |//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************  l  X. U3 m. B) p& h$ \$ h
//          AuthorisedUsers.java          Provided by: DRS
0 n7 n3 c: W7 J7 y0 k& p8 T4 R/ G//               
0 Y- C7 P( Q( t( p% R+ K! k//         Program shell for Assignment 2! S) m1 l* y3 c& Z' v+ c3 x
//: G+ j+ R) |3 |% M+ t
//         Represents facts about an AuthorisedUser
# [# u$ e7 ~  O+ C//********************************************************************7 O1 S' w7 ~) _. ~
! F0 J2 P) T8 m4 X% `& V
public class AuthorisedUsers' w4 x" i! T; p3 V9 v
    {0 H$ H4 z' B+ u5 Y
& u: W1 `9 c9 O( R8 i+ ?4 ~5 E
        //-----------------------------------------------------------------0 l6 P' ~& e; Q/ m& J, r# H# \
        // Constructor" v5 ~5 E. O" Z1 j0 z5 x
        //------------------------------------------------------------------ T$ t  P' x" M1 B9 W% L6 o

$ ~& ~& B, c( A" A        public AuthorisedUsers()$ b' f5 X# f6 D& n% a  }( [5 p9 d7 W
                {
5 V7 x# e  L) w* v! ~                }
+ p; V! E; W9 _3 Q6 C9 Z! d" D- {1 _
# B+ J7 M$ a1 q" r) z7 E* {4 `        //-----------------------------------------------------------------
! b+ J, z2 t( c1 |. w        // Method for testing that class has been reached' J* J+ |. Z3 P+ n6 |# Z
        //-----------------------------------------------------------------       
+ u, W% }7 R6 E/ }$ q0 A- X4 Q9 H        public boolean AuthorisedUsersReached()/ B. e9 h% {& h5 G' F
                {
$ f' t+ }/ {5 y3 h# d4 o3 F) w                        return true;                        % k( @2 E* R" }
                }
; r& f( t' [, e+ e2 t                1 P0 n. m. U; m# M( T
    } // end of class AuthorisedUsers
# Z# c" m% y, p  ]//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming+ n# @% d% s) I2 \1 k5 G
Shanghai - 20076 e2 d- g7 C& Q, y& i2 }4 z
Assignment 2, @/ _1 I; p! Z) L- A' `
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)
( d' V  |6 b# i: i1. 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.
8 A: m( q) F7 D% r" nThe staff must be able to:1 t* `7 b6 j  [
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
: e4 [* |5 `0 L* w1. 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.
% ?# L/ R+ C6 @. X8 \3 C The interface should provide a menu so that the staff can:) H  |5 o  S3 h* ^  Z
a) Enter the names of the two Java program files to be compared
3 K* Q5 u' D/ A: w2 W" V; Q0 } For this assignment, it will be assumed that the two Java program files are in the same folder as your program.4 |! [4 s3 W4 X4 y1 ^$ V
** 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).; R% c- z0 W9 U, f
BSA104 Business Programming – 2007: Assignment 2
7 y/ A7 V3 r7 S+ J% A( G/ E. XPage 2 of 5( [/ S! q* s, O/ x5 O
b) Print out to the screen all the lines of code that are the same
6 }% D+ `6 w3 V- U Include the name of the file and the line number of the code being printed for each of the two files& \+ j% a6 ~" G. P5 b/ Q" G, ^1 D6 [
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
& [) ^6 N" U4 i9 v1 p" Q the name, username and department of the user
( ?! W2 i# B6 J- n0 W) I the statistics of the comparison8 M, o1 W! T$ N' _
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
7 S: n$ E, D! }6 H+ o4 ?% K the recommendation for further checking2 g+ B$ M) @/ d) z- ^8 `
- 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( d% E' M+ N1 P3 A7 f
 the names of the two files compared0 w( F3 |# o7 W3 y: W5 x1 K2 K/ z) k
d) Leave the program (exit)
% X- n+ N( E9 Q4 T9 s6 MThe ProgramCompare class: (Total maximum 20 marks available)9 A4 o/ s$ A$ N4 n: Q- V
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)
: V) ^: O: h' I: n8 W% ]$ c0 D- U: |: ma) provide an error message if the files are not found or there is a problem opening them1 {% X2 Q2 x+ d; C. ~
b) compare each line of code
. x1 o, T5 I! R1 e, \3 h3 C' W3 {c) print out the lines that are the same2 ^' K7 \) ~# u6 o
d) count the number of lines compared / lines the same
: o* Q8 l  D/ _' }* WThe AuthorisedUsers class: (Total maximum 20 marks available)
2 ~8 q" e) h1 O+ p& g) N3. 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)
- ]1 G2 P3 a' O5 R4. Provide methods to:
9 ]  T8 R4 D" c/ L9 _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
! _0 H2 c* F( W+ y+ O9 jb) return the name of the authorised user
$ Y' t0 i2 R7 i. f7 sc) return the name of the department of the authorised user
! T/ B. k# Y$ _Individual Data (Maximum 20 marks available)* t8 E. S4 S3 `# _
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.
  x9 Q5 T0 b! l% O8 x5 d1 f) g3 T0 I4 |2 _Documentation (Maximum 10 marks available)
0 N2 i$ I4 N, C- i/ }( X/ Q6. 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.' x0 ]5 l: k" ~
BSA104 Business Programming – 2007: Assignment 2
2 \2 N8 G& Y' j7 \6 s- y( rPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
4 Q" u8 z  Y# }. k1 H  i  H1 m不过你要翻JAVA的类库说明。你有下载没有?) }/ W( _. u- b; j3 K
查询关于对比的函数。貌似关键字是contrast,还有compare
* K8 j1 W" y2 `+ Y) `, H+ P: J* P2 B- s8 s
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -! i" b: j# `+ _1 u4 t7 h- x  E
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
: Z: ?6 n$ X9 l* G( y可以下载到的 是 jdk-1_X_0-doc/ a' Q! Q. l* T4 ~# g
  g5 s4 n3 c9 f
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-5 00:27

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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