找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1477|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急4 f* e' O9 [' F , A3 ~( D# Q3 R8 [
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************; C( a5 \: \/ O9 w3 @% y
//  ProgramCompare.java         Provided by: DRS8 r( Q) {; S8 f- [7 L; z
//8 @7 C% I) b! U& j  L' e8 e8 ?
//  Program shell for Assignment 2
! g& g& A7 R! B% g9 W; T2 H//3 K& W/ ^4 a9 F' P
//  Compares two text files line by line
0 Q, ]1 G' U0 Y3 T//*********************************************************************
4 c8 ^. t# |& H2 r6 _  ]& c
' ?9 c9 Q$ ^4 @, ~( E0 G# Z# Limport java.io.*;7 j! L) L0 l; f5 o- |* t. G# V
9 }+ k" f5 D4 L
public class ProgramCompare
9 D* N. |, S7 }, D$ c{
) D5 M" q/ L& X5 B7 R4 A        //-----------------------------------------------------------------
- W8 h5 L% i3 u. U        // Constructor, b2 v8 s" C) ?/ c
        //-----------------------------------------------------------------: H. Y# M( C! l, a% g5 B( t
        public ProgramCompare()
; y' ^& r4 ^/ A9 F7 Y        {
8 M: }) z1 C% w& P5 b/ W' v- s7 R        }4 c9 `" d$ c: z

" x* N; m2 @' L5 |6 y' n        //-----------------------------------------------------------------
1 Y: L* I* v# z1 n4 `7 q0 N        // Method for testing that class has been reached
2 {& O# h- ?% `9 k) N        //-----------------------------------------------------------------       
( I$ W5 U, U* H" s* |# p% g! {* ?' f7 e) b- P% J
        public boolean ProgramCompareReached()         % t! l1 a8 n: Z# Q, k5 u0 \- F
        {
% z' x' z+ r$ M) t: ~      try # J2 H7 T0 _" u# `
   {        
5 N& k9 Q: x( n& g) c  G                        4 J# G; p* w6 v0 T7 j$ g& _
                //********************************************************************
$ l2 c, R9 [3 ~                // Try-Catch Statement is used to handle exceptions - such as file not found ( W4 T6 _/ U0 P3 g7 ~
                // Reading the files will need to be placed inside a Try-Catch - just like this one!; [$ V1 Q& z5 M% a" W$ a
                // For more information see page 534 of the textbook% h. }- I: h/ y% N4 I2 ^3 t
                //********************************************************************+ s2 D  X& i( ?( L
                    
& ?6 b- Z( \6 n0 _: g        }
& H% j' j2 H) w! l: P) H             catch (Exception ex) // Exception caught here and message displayed to the screen 9 M8 n% k6 x. B
          {! }5 ~& j, ]' A9 S! U4 _
                    ex.printStackTrace (System.err);  J4 `' g8 P* p& g/ D; ~+ b8 ~) j! x
           System.out.println ("Error message goes here"); // Replace this error message with your own          6 B! t3 I2 l' n+ _" p3 O* D- ?
        }
# G6 O3 j: E5 M" E! G                return true;6 U8 Q; ]  c( f7 X0 G; N* u
        }* \1 u1 y& _* ^; M( z( @7 I3 j% o
$ j' w6 j0 r  k0 t
} // end of class ProgramCompare3 |' s/ p! _" ^  w  y: a! w

+ d9 y2 J- e4 P7 j//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************0 W4 b5 f, t  x) M6 G
//  ProgramCompareMenu.java    Provided by: DRS# g7 |, V: k# S( X6 P" Z+ }( }
//
) \$ n1 ]# B- X+ o/ s//  Calls AuthorisedUsers.java and ProgramCompare.java
0 `2 k: I/ N& r' }3 `. I- Y  V//) Z, i8 O! i( I' @& G& |- m
//  Driver shell for Assignment 2." M5 v3 |0 m8 `) R$ E+ v
//********************************************************************! _8 H& p6 o5 M% ]

3 b4 B- H& S# oclass ProgramCompareMenu8 S2 _: z9 {# T! T
{  h# ?4 K9 W' M4 y
    public static void main (String[] args)8 [' |  i4 {* O' v
            {
8 A( Q1 v! p! G* T- h' i                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable8 X$ S# O% c; j7 b  @9 s4 e( f) V
                ProgramCompare reached1 = new ProgramCompare();
$ K! _% i4 |' F  W                AuthorisedUsers reached2 = new AuthorisedUsers();        # }/ {( }- J/ y$ M. X. Q! n
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());# s# f2 m7 S2 O6 {
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        # Y- W6 Q. f6 l! ?+ a8 U( v
        }
8 d8 X# p$ \6 n; X0 `}// end of class ProgramCompareMenu
- N: ^  E+ z. {3 \( |$ G
/ @/ V7 k* m, h1 N( k//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
' i9 X+ d7 U7 ^- l//          AuthorisedUsers.java          Provided by: DRS
, c* {+ u3 c" d% Z" y1 m1 F7 v# W//               
: W! ?& I& C! V0 o: R6 Y9 e//         Program shell for Assignment 2
: s/ d- `7 t+ m6 e: U//
. \1 V+ P2 W5 a//         Represents facts about an AuthorisedUser
  G8 }6 W' `, N7 _5 [4 G; W$ h//********************************************************************
5 Y8 W9 J% W& S% O# e' r$ u$ [6 k; R0 m5 _2 [- f
public class AuthorisedUsers
  t6 @- @& \: h/ z0 n1 z, R    {
8 `- ^; E& }% d6 ]9 c) m, {
2 ^& A' L% o1 P+ A. l        //-----------------------------------------------------------------
  T4 U$ B, s" p) N$ Z! u2 |        // Constructor
. H9 k+ h- v  |5 u, m        //-----------------------------------------------------------------
' w6 D3 E7 W! X. ]6 H( Q' `* k* y. |* e8 g, C
        public AuthorisedUsers()/ T. X5 O# O+ ~6 ^6 y
                {
7 b( e+ u, _4 q) h                }
; _8 j' P; X1 p. O8 X2 Y( `
% v  i" B. A; Z- G1 l; `        //-----------------------------------------------------------------
/ M# n0 B1 k2 B0 m. t3 I        // Method for testing that class has been reached/ p+ i  D' R  U% w5 A1 G
        //-----------------------------------------------------------------        * u4 H9 q4 u: x6 x5 A# ^* M
        public boolean AuthorisedUsersReached()( W4 r( X" n, q- G3 [( i
                {) W, d( C4 W$ O0 y# }0 ?# \
                        return true;                       
1 y2 h' o4 L# U" x! o                }+ k, k; |  j+ M0 p" k# h
               
  r; J3 k! W% F" P. N- W    } // end of class AuthorisedUsers
9 v/ \' q' y' V3 r' H2 N4 `//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming1 J" ?2 V$ `$ W  o( F* K: ~  p9 o0 ~% s6 `
Shanghai - 20075 G( B4 M3 I/ v
Assignment 2
* E) I* Y) {+ I) j# HDeadline 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): W% Z7 ~( A; t3 `, N
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.* `7 G7 g& |3 E, |$ f. Q. D  \
The staff must be able to:: l5 t+ W# r! P, a: {6 F
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
9 G: u% s" L- C, H2 j4 Y1. 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.
  i- M4 v6 ^! J& R, b/ C5 ]/ f. M7 i The interface should provide a menu so that the staff can:) E6 {1 p& H) \) l
a) Enter the names of the two Java program files to be compared, a( u. t) g$ q- Y4 c
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.' m$ z' E" n1 W, ^+ m4 L% @: n
** 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).$ Z: d, s% z1 w1 k( z: _8 Y4 w% l
BSA104 Business Programming – 2007: Assignment 27 S+ |9 |6 j5 _/ t: Q8 o# r
Page 2 of 5
) I2 v. J& P! A3 Ib) Print out to the screen all the lines of code that are the same
6 E/ l; I/ Z% E, H Include the name of the file and the line number of the code being printed for each of the two files/ Z/ C! b& ~7 u! l
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared8 g$ K1 w  B% ]; D) ~
 the name, username and department of the user
4 y% Y+ @+ o6 {" o8 X the statistics of the comparison
* W9 S- ]2 ?$ H, j" s8 [- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
4 w) P- C8 i% I; I& U4 B5 F$ I the recommendation for further checking
4 `$ z2 E) j9 q2 A- 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 closely2 q. I8 b- j0 S
 the names of the two files compared5 t) ~% ^; }, `8 y
d) Leave the program (exit)0 Q" a1 y$ w4 c' k1 m
The ProgramCompare class: (Total maximum 20 marks available)
! |: }6 I4 l4 k% m) b4 i, W2. 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)& q  b  g( Q: J  g
a) provide an error message if the files are not found or there is a problem opening them$ e. V1 t6 b6 W7 Y$ o1 |
b) compare each line of code! ~* `( u% ]! c' j" g
c) print out the lines that are the same# `! S3 x" B8 P; G7 a" V* T* Q2 l
d) count the number of lines compared / lines the same
) d6 z2 _4 b+ y- U# m# J2 wThe AuthorisedUsers class: (Total maximum 20 marks available)
; a2 M  Y; O' n9 q" ]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)
+ s1 E; m4 G5 t! s2 v( Y$ e; ~8 r! ]1 C4 a4. Provide methods to:0 y5 y# r' \$ E* e
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
3 a. p" b7 s/ T& L1 `$ ^9 Pb) return the name of the authorised user
: D& q) v- M( ]c) return the name of the department of the authorised user) g! t# r! X4 [, A& s! _
Individual Data (Maximum 20 marks available)( Y4 y9 N$ x5 d
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.
6 t4 V  S) j4 q0 SDocumentation (Maximum 10 marks available)
6 Y. `) |! [' P# a6. 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.5 A+ V5 s, d' c5 a/ W0 f
BSA104 Business Programming – 2007: Assignment 2
7 A; m( X2 b4 @6 C3 pPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
+ F) T: n+ F/ m' g% |" i8 l* Z不过你要翻JAVA的类库说明。你有下载没有?
4 w% g' e) H6 \' G- e6 H+ E查询关于对比的函数。貌似关键字是contrast,还有compare& x) x) }; P, F
$ N, V+ E' i( H2 A) A- E0 s1 N
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
2 a  y. s+ [9 w# i6 L痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
* B- z  u/ W% W可以下载到的 是 jdk-1_X_0-doc+ Q( F2 C- m4 a" u$ N! H! D
0 r! z& G- m; f5 p8 J
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-23 01:41

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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