找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1785|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 9 w; h) [2 w/ M2 b, X 6 p; E6 H% T2 k1 _) e5 c
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************  @9 Q/ {* Z- h" M5 a8 _9 ?2 j
//  ProgramCompare.java         Provided by: DRS- j  v+ x" B- d: Q
//+ N7 ^3 V- W6 M
//  Program shell for Assignment 2; c( l# ^) ~; U7 j' U( C- Q7 j
//
% z, o. r" W' A9 w, I. m//  Compares two text files line by line
% t1 _7 _& s7 H& H3 o, U//*********************************************************************+ K( C$ a4 ?+ f  k0 b+ V) O

( V; p) e( ?, B+ q- n2 eimport java.io.*;0 j/ t7 n+ |2 G: x* T% f: p; V+ a

! m5 y0 a+ W% p7 h% {" rpublic class ProgramCompare
# D' M) g- ~8 O% a* m{. N6 ^2 P4 O* i/ y1 [
        //-----------------------------------------------------------------
& z7 x+ `: y. W; b9 e# X        // Constructor
4 F# L/ z1 G3 x3 T8 i1 w        //-----------------------------------------------------------------; a3 P& U" a( o$ z4 _7 y
        public ProgramCompare()8 y  ?0 J9 e/ l- T' p' t
        {2 i: Y9 b! G; g% Y8 ?! m% R
        }2 |  P, z, C. U% c* B( I4 o; T

- p: A! C. f% V0 y1 ?( j: z+ l        //-----------------------------------------------------------------
! P+ ~5 ?/ ~5 Y        // Method for testing that class has been reached
& `1 r  Q4 {5 x* ^# s. W        //-----------------------------------------------------------------       
- T, Z7 B$ p7 s& X9 Z1 e3 T6 I; l0 I8 Y6 G9 A& B, f1 w3 q
        public boolean ProgramCompareReached()        
. s. u  p% u* [7 `  N+ [        {
8 D- G! B. S7 a; j) ?  O      try + C" }# k6 |; z* F) g; `, @% l: I
   {         9 T6 M! K3 x/ U2 o" }6 _" g
                       
5 q& L; T( ^- ~6 u                //********************************************************************' K- a" P- j) [7 k; D) V
                // Try-Catch Statement is used to handle exceptions - such as file not found
/ ^* B7 O5 d( m) |) S8 O                // Reading the files will need to be placed inside a Try-Catch - just like this one!+ K5 V8 V$ }- l( Q- x0 }
                // For more information see page 534 of the textbook, B% C/ @! P% y  J' [3 C7 ]6 R
                //********************************************************************9 c; c3 S, q2 q1 }/ ~
                    
% F' c$ {& R/ D; K5 s) j        }
! \; x3 p# a4 k  u* w' E# L3 B             catch (Exception ex) // Exception caught here and message displayed to the screen + p1 A$ M' b3 W+ L2 d
          {- C0 R& o* ?0 s8 ~
                    ex.printStackTrace (System.err);
; T/ w% M' E) b% F7 w+ I7 e, g9 j  i           System.out.println ("Error message goes here"); // Replace this error message with your own          9 O( I5 |2 a5 D5 K1 }; g" X
        }
3 {3 }% H" `$ |* ?' ~                return true;
) {1 M1 M. M3 A. Z/ U8 x  Q        }6 z% |$ n# B) f+ X1 k" r4 y  A- r
+ k- \9 u1 y2 k- P& q, C$ x
} // end of class ProgramCompare
5 Y$ _, V% N( q- y7 c) O/ @5 l& f+ S0 H' T' y0 @# o" K
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************# ]' d' @$ X# Q2 V/ D. O( ~
//  ProgramCompareMenu.java    Provided by: DRS
- Y) D, `/ F- y2 R0 l2 d/ R1 L//
9 ?% {) @" M- Q9 s5 _  R- b' B3 `//  Calls AuthorisedUsers.java and ProgramCompare.java) p- {* D: X+ {
//1 c  V7 z! M, f+ p1 X' ^9 B
//  Driver shell for Assignment 2.) E: t" J( s* Y0 A) m
//********************************************************************) d6 i4 M) M, w/ g
+ h, p4 ^9 c# O7 ~0 _
class ProgramCompareMenu
3 K; _8 J: u% A" e9 ^+ ]" @$ V, F{. |+ {5 B7 ]! N+ v6 ^
    public static void main (String[] args)
6 i' f8 W! O( ~5 S4 w            {) c6 p8 M6 a$ n8 B, L3 T( m
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
' g3 [3 j" A" |3 A$ k4 f: q                ProgramCompare reached1 = new ProgramCompare(); 7 p3 F0 t, `8 s1 i& |% c. i" ?  ]* ^0 F
                AuthorisedUsers reached2 = new AuthorisedUsers();       
* m) U5 r6 R, D5 u. A5 C& M9 Z                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());0 X+ m. b; N5 r( ^
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
& _# |; o: \1 I, [0 t; _        }
/ @- G0 O! @- j' _}// end of class ProgramCompareMenu
7 v; s6 Y" P0 M! m  s; r$ F
" T; L" |; T7 F4 j) H//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************0 c5 j2 w* I/ p' M
//          AuthorisedUsers.java          Provided by: DRS
+ o- Q' K' X8 N' S5 x//                5 a; z. r8 g" u5 k6 Q; |; Q  N8 J
//         Program shell for Assignment 2
+ _' z9 @6 j8 N8 E7 x/ f//& S' y. U- s1 D2 _4 v) r- L( N
//         Represents facts about an AuthorisedUser2 I$ s! c! J6 s: v: o
//********************************************************************, N2 D3 }, V6 x9 Y' K
8 O! ]9 N- d3 R' @! A" {  x/ F4 `1 i
public class AuthorisedUsers
9 q' \$ q* z  _. Y    {: k) X+ Q4 X5 X- S

+ V' N( y. M% M- M) u        //-----------------------------------------------------------------
; g2 x4 a  Q' s5 w6 g( C0 R        // Constructor
8 k7 g* x6 l4 l$ w        //-----------------------------------------------------------------' L, O& A, g  L
( u/ S" P& Q% b1 {4 g% y
        public AuthorisedUsers()  C- G) W9 F/ @$ e: x1 Z" O4 N' O6 b
                {9 T( \0 F" b0 P, ^) k
                }, I) w( z4 \7 V  T
  X+ S! d  ?7 S8 Z) u0 U3 R
        //-----------------------------------------------------------------
' o$ G0 A$ s. }/ C+ O0 Q. ^        // Method for testing that class has been reached
0 p6 A9 i- p& e& u+ b7 Y  \, E        //-----------------------------------------------------------------        . t; p# x* Y' o, i, N
        public boolean AuthorisedUsersReached()
# h3 y# D- \# ?" a3 s                {
0 Y2 n3 w3 y* v7 D0 {; O                        return true;                        4 T4 P9 r! Z7 n
                }/ m0 p, `  J! V$ l; I: a
                * i# E/ {6 {2 U$ R# K+ g
    } // end of class AuthorisedUsers8 V; M- i* h- K( b6 |7 y% [( `6 x
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming) c, w# S; W  Y- ~# Q
Shanghai - 2007& ]+ S4 E" b, Y3 c: N3 J' @
Assignment 2% a) C$ t0 T9 c' E
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)& U8 O0 S  g% {$ c7 u8 t
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.
" R) F- ~: b+ ~! GThe staff must be able to:% L5 v9 a3 R9 f
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
% G% N  c, l/ q$ i2 u" d1. 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.1 A' K. x3 I0 K! _
 The interface should provide a menu so that the staff can:1 k3 K$ J) B  q
a) Enter the names of the two Java program files to be compared% r# R4 L+ F1 o
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.6 [$ {. U  p+ J
** 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).
( p4 w+ D* B% v* s6 \% h# t- a- P: E* HBSA104 Business Programming – 2007: Assignment 2
' U. i- ?2 n5 B' BPage 2 of 5% |* Z( J5 X5 t: d9 c" _( P- q
b) Print out to the screen all the lines of code that are the same
0 M# p1 W% c7 T- q5 o' @! b Include the name of the file and the line number of the code being printed for each of the two files
9 Q0 [% Z$ e2 r6 {. Kc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
) Z7 K6 V  r  G* J% W) [* j. \ the name, username and department of the user
" P7 E4 F7 B+ G. C: z1 o the statistics of the comparison( I5 w% ]( [7 ~* W, ~) W
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different% L' y* L6 [" P9 m+ S. v  m
 the recommendation for further checking
8 u% ?* Y: `& E! x; g9 a& S- 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 `+ U8 X4 |# T# q, G% ? the names of the two files compared) ]$ w6 L( J. d+ V/ J5 o
d) Leave the program (exit)
' t; n: v- w; e+ p" |The ProgramCompare class: (Total maximum 20 marks available)9 M9 P2 Y  K6 T7 S8 ^  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)* u* g* K+ r7 k) q3 ^
a) provide an error message if the files are not found or there is a problem opening them( @% ]6 K8 O4 C
b) compare each line of code9 ]& K9 ]- Q" b4 n/ i0 M& T4 [
c) print out the lines that are the same+ F2 Q! {6 _& b2 I
d) count the number of lines compared / lines the same! w4 W7 l' o) \& V$ \
The AuthorisedUsers class: (Total maximum 20 marks available)
! b& t- m6 }- _2 J. Y3. 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)) K  o  ?% v. Q6 y" Y% b
4. Provide methods to:
0 N4 F/ N: ?- u3 g  Ia) 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
) z( t' y- t9 lb) return the name of the authorised user. ^7 `1 _* B7 a- p3 K7 f% V
c) return the name of the department of the authorised user, s+ K: {' Z9 X+ R
Individual Data (Maximum 20 marks available)- @5 z2 l+ E4 C- B: ^
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.
  ?0 w* H6 W/ e0 `+ J, @/ ODocumentation (Maximum 10 marks available)9 }4 i- g! ?8 H5 V
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." C. l6 C0 W0 X; X8 i
BSA104 Business Programming – 2007: Assignment 2! {" n( O, U" f6 E8 }; P8 n
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了4 }( a, P* ]/ l! J$ A" w2 C0 ~% g
不过你要翻JAVA的类库说明。你有下载没有?2 g  e( u! o/ C" n( |7 ?0 t% M
查询关于对比的函数。貌似关键字是contrast,还有compare
5 M2 t8 X3 ?6 W: C! b0 t) E% l# y* T
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
! u- Q( L8 X, \, }+ O7 p% [痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。- ~' U9 R2 d0 u+ d
可以下载到的 是 jdk-1_X_0-doc
; y# W) s) X% m$ E  K0 x+ ~3 T4 h% @# y9 x( G) D
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-30 01:54

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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