找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1494|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急2 S; ^, X! Y9 | 3 ^' w x w% O
回复

使用道具 举报

 楼主| 发表于 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 e* e( y! X  z8 l$ R
//  ProgramCompare.java         Provided by: DRS# y5 y4 L& k1 @+ _- s% a
//( g( x) G' T7 Y, S; j1 H7 b9 d) N
//  Program shell for Assignment 2
1 l1 Y- q. q/ b4 {8 [/// C+ I8 |, U8 g' F0 v5 j, ~9 W$ E
//  Compares two text files line by line' ]; T+ y1 @+ e
//*********************************************************************
/ s' p  b: c% e  K: d
) s8 b8 r5 L: Yimport java.io.*;9 f1 m7 [3 {! y* e# o& ^; b
/ E9 _7 e- z1 g/ R
public class ProgramCompare
' Y$ k7 M: M$ N{0 k; K( o9 Q2 Z) B
        //-----------------------------------------------------------------! a" M' i. k! ^4 Y: y4 z6 X" k
        // Constructor$ b" C/ @3 E% B8 {8 r. x! k, @7 U/ O
        //-----------------------------------------------------------------' c1 \- W7 W0 @% L
        public ProgramCompare()4 E0 F+ B2 G6 H
        {; h+ ^3 p. u1 b1 f0 V8 q4 `
        }* k" g0 Q$ [7 N; B9 J; G# m/ e
) ^4 q4 u' \8 d1 [
        //-----------------------------------------------------------------& T& r, G$ W, G% \) m6 S3 h$ y
        // Method for testing that class has been reached) t  U% Q. C4 h
        //-----------------------------------------------------------------       
5 J3 w$ c7 i6 L; ^6 c7 K. \, N( K, h! p# \" {* }8 H" X" n; B, S. }
        public boolean ProgramCompareReached()         9 g3 d& {  X9 _# i( ^. e
        {
& K! Z$ c& k& h, [& v      try : d9 m( b  Z; w7 O6 L
   {        
, w! h& {5 v, ~, V                       
' f' x: j, B6 T, j+ N+ A                //********************************************************************
8 M- a; y% w* e  n" {% y. O# I( x5 U8 I                // Try-Catch Statement is used to handle exceptions - such as file not found 0 R$ y" G8 D# [6 s
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
  l( M) v% }( S. l                // For more information see page 534 of the textbook; u0 V+ ~; Q7 ^! v: `# x
                //********************************************************************
, h* h4 r: t* }  t                     % p: |0 D$ x2 r6 |5 T* @
        }
* L0 P+ T- |* k. A' j( f             catch (Exception ex) // Exception caught here and message displayed to the screen 1 h7 b& |, `; S8 f9 l
          {7 Z# n: v3 ]6 D. x# Z+ S2 F  h! m. G
                    ex.printStackTrace (System.err);- [7 I7 Q3 x% W( m) A
           System.out.println ("Error message goes here"); // Replace this error message with your own          ( }2 E$ M$ N! j
        }  z' I- U% w1 \
                return true;
) n$ p1 m. Y( c6 C* o2 N        }# q& O' P. ]0 E% q1 S+ D

. ~9 U. ~% g# F} // end of class ProgramCompare
. `& i# g6 V3 e! ]; E, \( y
- Y! K! U7 i6 u, M5 s7 \) I//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************0 m9 `0 r4 X1 o. A4 p) C! |4 B
//  ProgramCompareMenu.java    Provided by: DRS; f0 M; G+ y3 L6 f' v" z
//( _6 v& P% d+ h: C) t5 ^7 w
//  Calls AuthorisedUsers.java and ProgramCompare.java" l  M" j$ x4 ]# v! o+ [& J
//3 M7 i$ d$ J6 d2 S  s8 M
//  Driver shell for Assignment 2.
! ^: `3 z5 V% @/ D+ s//********************************************************************
# _0 f0 ?6 C1 U3 Z( ]% u
8 |- E! R) Z. E8 \" Aclass ProgramCompareMenu/ C6 o! u  m( B, _6 `
{
3 t% w4 e% q( \! w. g    public static void main (String[] args)
" H$ |# e* J9 ^  w            {
+ X5 d5 o: x* H% M4 f# A# p                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable5 F4 W- H, S  `; |7 ]
                ProgramCompare reached1 = new ProgramCompare();
5 {7 R) P- J- ]# p/ X( v- T* m                AuthorisedUsers reached2 = new AuthorisedUsers();       
  L  h0 S1 e) g. R                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
- ?7 l7 I  N1 S6 W3 G' w                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
& h# C& K* Y" z+ p, ^2 Z0 y+ x        }8 b! g+ q; M( D3 ]0 v/ p
}// end of class ProgramCompareMenu2 l* N, |3 ~; L- e
$ L; o2 f/ z; G& `
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
% F7 o) W$ o+ U" k- ?& C//          AuthorisedUsers.java          Provided by: DRS5 B, p. K6 F( |3 @
//               
! y  J/ {" F2 F& h3 ^* j//         Program shell for Assignment 2& Q$ T8 P; M0 x+ [
//
' t8 m- D6 B9 z' ~: P% P' h' _//         Represents facts about an AuthorisedUser, Y7 A; A' D3 d! i# {
//********************************************************************
. o1 ~) S) x0 O' j. u6 O* x5 N9 W8 J' G% [9 Q2 w
public class AuthorisedUsers
7 K! [" A: j' \4 i. q% Y% J4 \, t    {
$ W9 i( y1 o) F2 R- f  h/ X+ L+ W' E
        //-----------------------------------------------------------------
9 o! ^* k* D1 g! r6 E; J        // Constructor( C) s2 b% Y6 }9 z
        //-----------------------------------------------------------------' Y& T0 z' I( e- \2 l3 \
& L8 S  R# l" g1 k* V* g
        public AuthorisedUsers()5 o  S9 i$ U  R1 [, h( `; e9 U7 Z
                {2 Y0 @! n: y- {
                }4 m& L4 a# i9 t) |
% B3 I) g  W$ F) r- a( C
        //-----------------------------------------------------------------) y' X. N  X- l1 l( m. Z6 l4 |, H$ x
        // Method for testing that class has been reached
+ O# S2 T+ t( d9 U0 l% j6 k        //-----------------------------------------------------------------       
8 g& f8 l9 X; _" L: Z        public boolean AuthorisedUsersReached()
# G5 y+ p& o  V& @, S) @5 d9 s7 M9 t                {
, P' Y, q( H4 f4 o" _: ~9 M                        return true;                       
1 O0 m( y; k2 V1 t/ c  y! u0 o                }
1 g5 T5 M/ j% U               
: Z8 A- w+ O5 E) t' M4 j    } // end of class AuthorisedUsers- w/ T$ o; w. [
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming* M* s5 ^) w7 S+ x' p+ t
Shanghai - 20077 G1 F1 M- b/ n8 L% j
Assignment 2
- d! Y- }/ h% Z+ I* t% ]' Q$ S  ODeadline 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)
1 Q- u+ u1 {% t, l9 L1. 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.
( v5 H* L8 ], Q% a% `* z8 sThe staff must be able to:
' U5 D& V- I) }! f" W& b' u' _. ^" K: D Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
0 D& v4 x# i: y+ E3 J/ Z$ F5 i1. 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& i4 t+ e9 _0 f. _
 The interface should provide a menu so that the staff can:: u- n/ F8 O- E! G( r
a) Enter the names of the two Java program files to be compared
$ z$ O. ]! N6 P4 ]# O+ T For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
' ], z# s. p4 |** 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).# Z0 T/ B! b- v/ z4 J" {
BSA104 Business Programming – 2007: Assignment 2
! K0 W7 L: ~6 D+ m% mPage 2 of 59 R/ E4 F) @; E3 t# G6 d0 c4 @0 n
b) Print out to the screen all the lines of code that are the same
9 m% t! ?; [$ Y/ e6 ^9 v Include the name of the file and the line number of the code being printed for each of the two files+ g/ U# E9 b& W+ I: u' N; M4 C
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared' g3 b5 K2 j6 ?" p. k1 q$ ?
 the name, username and department of the user/ V% J( N3 i, V7 n$ A7 X
 the statistics of the comparison  V& A  D# ~7 d2 d, g
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
! z9 N! z+ x) s4 G  p8 q  v the recommendation for further checking
+ w. [5 i: A& H$ z6 B( i- 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
# R  z6 q! ]) h# }2 p the names of the two files compared
6 i( T+ \5 |- x# md) Leave the program (exit)3 Y9 X8 O+ u9 r. V6 |, Q' s1 s& R
The ProgramCompare class: (Total maximum 20 marks available)7 c( ~. r3 i  S* m5 }
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)- w! G/ p! s8 b) \1 T* V; U7 b
a) provide an error message if the files are not found or there is a problem opening them* l" d. C! J# H+ [/ p- ~
b) compare each line of code# h/ L; C! ^- q* d; R# v  U8 K& Q
c) print out the lines that are the same! i6 p0 S/ q# T" k
d) count the number of lines compared / lines the same) T, E0 @4 s4 F- T
The AuthorisedUsers class: (Total maximum 20 marks available)9 `5 q* _- ]9 Q& I
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)
4 w9 g/ W2 A+ e. n. E% Z4. Provide methods to:) B! u  T) [& Q3 C
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 match6 Z: @; g1 H$ G$ h- }$ t
b) return the name of the authorised user
2 a' R: Z. N$ L5 \* h  M4 V+ Mc) return the name of the department of the authorised user
* u) t( q5 o1 h( LIndividual Data (Maximum 20 marks available), L2 ~, T! A8 Z; l0 p; S
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 ~6 t6 n7 K$ k% ]Documentation (Maximum 10 marks available)
5 B2 f5 G4 g$ ?' }7 ?$ J2 w6. 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.0 d/ J4 w! y) Q3 k4 Y
BSA104 Business Programming – 2007: Assignment 2
+ F1 t4 B# [0 ?9 YPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了) u9 u& F% X* B5 ]4 |- I- z
不过你要翻JAVA的类库说明。你有下载没有?' s" u3 y" F/ J) t
查询关于对比的函数。貌似关键字是contrast,还有compare' D+ D9 f. h9 i. w

& p: j6 e' h) U& C; g[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
$ ~" z1 c: P; r痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。& W8 g" X. }7 h' W. I$ G6 D7 W. R
可以下载到的 是 jdk-1_X_0-doc
6 Y+ ^# P# X2 s% i( M- T$ B' d$ w6 c7 x$ b
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-27 03:26

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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