找回密码
 注册

QQ登录

只需一步,快速开始

查看: 947|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急- c7 z9 W4 m1 \ j% X) h" |+ k 4 @* O( Y* x$ E( U1 d0 x
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************: j4 R/ o; E: |3 N
//  ProgramCompare.java         Provided by: DRS5 X/ ?( a. M2 G7 ]& J( o' l* i
//9 [5 |3 S* |) Z+ o9 F, e6 o; `
//  Program shell for Assignment 2
, k+ j5 L& {" u% s: T% U4 K//
" j6 I) u; v2 v9 X//  Compares two text files line by line- z( \5 N0 L  A0 E! f( U
//*********************************************************************: z& z! L' u& D% K: e

2 ~$ p0 @& X4 W1 C$ qimport java.io.*;
; p. c3 E' E8 D/ _/ t7 F; h* ]7 ]9 V3 m
public class ProgramCompare
- [; x1 u9 }5 L: e( F{
# g; a) f0 p" N  Z9 i        //-----------------------------------------------------------------
  k7 u$ z0 P$ @5 _/ @1 _        // Constructor! p0 L9 J# D% h4 N% J" B
        //-----------------------------------------------------------------
' n0 v' A5 c* b, p# f9 }* e        public ProgramCompare()3 {4 K. n; N- \+ H
        {1 Z+ Z; g. @( J
        }
: t& r0 V6 N; b# U. V4 J  x# G/ H: L5 i
        //-----------------------------------------------------------------
+ `5 E) h4 `2 ]8 ^4 v( B        // Method for testing that class has been reached
# [  H, s4 [$ g% B) {/ E: p, ?        //-----------------------------------------------------------------       
) b  [" Z: L& H3 h- {+ N
7 y1 t% p+ }1 a/ P        public boolean ProgramCompareReached()         ' p. z; `) s+ y8 I: n$ n3 j( [0 H
        {1 t7 m  h+ R1 c( d' }
      try
* P- c& y! t8 g3 t0 L   {        
  i7 E1 n! D7 Y                       
8 @+ M& W8 r7 o+ `# U3 n                //********************************************************************
5 @5 o$ w' Z2 w1 e/ R                // Try-Catch Statement is used to handle exceptions - such as file not found
, o3 y5 P: l% E                // Reading the files will need to be placed inside a Try-Catch - just like this one!
/ V& Z; Z  M4 n: l                // For more information see page 534 of the textbook& F% z: A- ?1 w9 s
                //********************************************************************0 s& K; u, `) @
                     0 ?6 i9 K0 c& b; {, L& b4 A1 R7 K
        }
! G. x( ^+ o  v" p/ y1 G             catch (Exception ex) // Exception caught here and message displayed to the screen & Z+ g5 ~( }8 \& c* F
          {
$ u6 D, Q6 G4 w9 O                    ex.printStackTrace (System.err);
- W) o7 b& j0 \8 |1 ~           System.out.println ("Error message goes here"); // Replace this error message with your own          ; |* R4 E. m6 R( h. }
        }
8 h, j0 X8 B8 C                return true;
7 z# g( y" f) B7 _% @: i        }
0 k- Z) V* _/ F. J; C; r; K0 N& F4 B' q$ v' `4 {5 s
} // end of class ProgramCompare
! h9 r* s. N6 O4 d* v& X% v- {& D4 X/ F4 n+ g
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************4 Z- y! o6 L4 @  ?+ Q
//  ProgramCompareMenu.java    Provided by: DRS' a" k- C  J" b, K  w! U
//
' j: u: L- Q* J* ~( l//  Calls AuthorisedUsers.java and ProgramCompare.java
+ z# d, y& @* J//+ Y) V& I* ]7 ^% H3 a9 J
//  Driver shell for Assignment 2.
2 J5 X5 c' V) {! I$ ~% x//********************************************************************; c& ^+ R; p, A- L3 C' X) H4 c  W. }
( ^4 Z8 }; I9 e6 S
class ProgramCompareMenu
# A$ o1 r7 @$ ~7 V% j{
4 @' ^$ F, L8 w* c+ `" G    public static void main (String[] args): P) h. u% S! \- ]8 a9 b9 K/ ]
            {$ K- p3 a2 o% `! \& o
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable  k) x1 h' r, n/ A+ `
                ProgramCompare reached1 = new ProgramCompare(); * \! @( I, ?! N9 h0 D  {4 b
                AuthorisedUsers reached2 = new AuthorisedUsers();       
1 ~& z/ x9 s6 A; n. D$ T$ {* v# r6 c                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());0 W# m6 U2 Z: X, u5 r: C
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        7 }/ W% U- K# ^0 L( |
        }) Y7 @- ?* n2 f
}// end of class ProgramCompareMenu9 }1 W5 o$ o% Z+ z

9 m" ^& u6 e7 R- Q+ r" {+ o4 ~* A//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************8 c, }% @7 n) h7 k2 v" L* ]
//          AuthorisedUsers.java          Provided by: DRS4 d: `5 h) N7 ]0 \9 I
//               
% T% B; G! W# p6 g' c( b//         Program shell for Assignment 27 J6 x. z! D) j3 z
//
" i% Y. R) z' L3 K! a8 i//         Represents facts about an AuthorisedUser3 E" |$ J9 C) Y  P5 o& `2 U% K' @
//********************************************************************
- X" o% _+ X8 |8 j; c" I- m, `. v  F2 L! e% i" T! e
public class AuthorisedUsers* R! I- V( X& x9 H8 b7 W" |
    {
$ `" N8 b7 V/ ^% J0 I! q' r$ H; U' e2 c) G3 `
        //-----------------------------------------------------------------0 f( t" \3 l3 o  q2 `3 f
        // Constructor) b( `8 b& u/ V, b' w: B9 O
        //-----------------------------------------------------------------
5 a6 y' |& f  N2 X& o: d* z6 E2 w+ s/ h3 A* D1 ?" r! z1 P
        public AuthorisedUsers()) X& h3 [; v  S. G+ {' |8 `) `
                {
+ v' S: ^! C' |; Q/ }- @$ B                }
! {: H4 E. Z2 W" O, \# f
5 A5 n1 r) l3 r9 D: f& [, ?: T% k4 D        //-----------------------------------------------------------------
7 }" [  }* a( S) w        // Method for testing that class has been reached
# o- F5 `2 r) Q+ ^! Y        //-----------------------------------------------------------------       
7 {& y6 x8 m# }0 Q. W( q4 o6 J2 i        public boolean AuthorisedUsersReached()
5 ^8 E6 X) I; E( Q4 E2 p# M# x$ w                {  `: k6 W3 G4 p
                        return true;                       
9 ^  x" b% Y$ R/ x! S* O* d                }5 U" i) X# q+ |/ v& r; j
                + P8 v& {$ W! `  L
    } // end of class AuthorisedUsers
6 v: I2 J' U. U* P' X. v//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming+ @1 ~# N: D# D/ y1 c+ F/ f
Shanghai - 2007
5 z. S( v: ]* B* `! ~Assignment 2. z  F- V* C0 t* N& I! S
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)$ y: x, w; }2 x
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.
/ K( Y! B+ U  Y, A4 X7 g9 r1 j2 gThe staff must be able to:
5 P  O* A  g# X& e- T3 @& e2 C9 P. Z Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
% m% E* d/ D! J1. 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.
% A, w  n. `' e7 { The interface should provide a menu so that the staff can:2 D( V5 c" R% B% z( p2 O& l1 g* u
a) Enter the names of the two Java program files to be compared3 B& x: J4 h% {# Z
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.1 H" k/ q( S, x$ |: [
** 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).7 L% @1 A. S; l. r0 ^0 f
BSA104 Business Programming – 2007: Assignment 2
( Z6 D0 s3 M% h; |Page 2 of 5
0 Q: n  ?* B$ g9 b8 g2 ]- H7 N( Rb) Print out to the screen all the lines of code that are the same
  s' R0 T/ }1 c/ a. J1 V4 S' z Include the name of the file and the line number of the code being printed for each of the two files
2 y. q* V* `  ?0 o+ p6 ]0 Sc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared( O7 H8 H; |& ~6 C2 m, B& \; n7 W4 n
 the name, username and department of the user
  n0 W. m+ K% j( [" o the statistics of the comparison
. e2 ?* _( }3 z6 _( U; q  Q8 M5 E- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different# \% V. \. g' n2 h
 the recommendation for further checking
- F6 Y- Q9 o. h) s8 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% j) ]# c3 f+ O8 [5 J2 T  _. A
 the names of the two files compared
' g1 I: [0 e/ h7 Jd) Leave the program (exit)" E* Y3 h1 ]( X5 H3 Z
The ProgramCompare class: (Total maximum 20 marks available)4 q- a# L4 n& x7 L2 {$ Y+ j! Q
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)
. x) }( ]2 q  G0 ~2 S7 s8 Sa) provide an error message if the files are not found or there is a problem opening them' O% @; ^& i9 H4 _2 W  a+ ^
b) compare each line of code; ~& A/ h/ m* ^) v, C- n
c) print out the lines that are the same
6 C( c) T7 l+ L* Td) count the number of lines compared / lines the same
; C/ x8 l7 o& J3 ]The AuthorisedUsers class: (Total maximum 20 marks available). x8 _1 q0 J0 X; k$ c2 F7 Y, E
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)! Q  o# F/ u9 F- |; o
4. Provide methods to:
* A4 e+ y3 ~, r" n) |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
9 z+ R) E, L  O$ `. C6 eb) return the name of the authorised user
) X4 g2 O9 V0 i8 kc) return the name of the department of the authorised user/ H: M; ^2 w  |  J1 d* G1 L6 P3 q
Individual Data (Maximum 20 marks available)) m9 b8 p+ N8 x7 k" u7 d$ N% V. R
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.) }: y3 k+ q2 v$ H3 }8 x
Documentation (Maximum 10 marks available). O3 s3 h" f0 S" P: z2 [9 F
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.
8 m* f8 N- \+ r) g9 o6 H6 WBSA104 Business Programming – 2007: Assignment 2
, E/ k3 B1 g% ^8 QPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
1 C" _3 a6 R4 U6 t$ U9 Y! t# X4 A! W不过你要翻JAVA的类库说明。你有下载没有?6 x  X7 G' c; M4 W: y9 H7 p: x
查询关于对比的函数。貌似关键字是contrast,还有compare  o+ b4 ?& _9 N

6 i/ K5 N2 v" o; X# g[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -; C0 ]6 g, [* z
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。/ l, O2 a6 n0 t, A  @. k" G
可以下载到的 是 jdk-1_X_0-doc
5 R* c! I- ]% P# m' R8 R2 F- t$ L$ \5 `9 |4 G+ \2 T8 j8 x# ^6 E
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-16 15:41

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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