找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1171|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 7 c4 M' C% H7 c$ \8 R+ b3 n5 S! t: 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 | 显示全部楼层
//*********************************************************************# d& H4 a5 H9 S& a7 U
//  ProgramCompare.java         Provided by: DRS
3 Q1 T' k5 q0 P6 E//
- s" c0 W. }: k//  Program shell for Assignment 2
# L5 c( F# _/ S' j7 M//) ^/ i& T! ]& c3 b3 f8 j& w
//  Compares two text files line by line
: E/ H4 y% ~2 }& ]% J//*********************************************************************
3 v% \' D7 U& i8 d( I, H4 ~  l6 g# z7 r! v3 H! f
import java.io.*;% w: j0 j7 z$ I; s

- p: ]  K& T+ Q9 g% |" Lpublic class ProgramCompare
( i# g$ f) }9 v1 h{
! K& L3 q) I( u. l        //-----------------------------------------------------------------
5 l& }8 C* j( b, r        // Constructor) z. L& @: z8 i0 F9 M- k0 o
        //-----------------------------------------------------------------5 X# h; G4 `' ^+ u/ c# b% @
        public ProgramCompare()
, \9 v" p# S2 B4 `( F( s        {9 S# Q3 @+ ]# ^2 m) b/ }
        }
% j, ^: |& o, a  f6 I) ^! X, n2 E1 _7 J" k+ Y2 n
        //-----------------------------------------------------------------
" \/ P  {* T7 b6 u$ V. H        // Method for testing that class has been reached# w( O$ y) M" c6 R; \
        //-----------------------------------------------------------------       
. m* u0 t' N- s7 O/ I' Y/ v5 f! V1 `
6 N) i7 o+ G( I1 b        public boolean ProgramCompareReached()        
# ?# E' i2 G+ j: j- x/ w% l, B        {
& _4 f2 V* l8 v% U5 N4 k# X) s      try ! P# y3 a3 p+ ~( ~; x
   {        
# G. x/ _8 ^* r  B$ l+ }0 b                       
# W" x0 [1 b- V: ?                //********************************************************************
8 N7 g% J7 W1 t4 m$ i; ?+ W3 M, T                // Try-Catch Statement is used to handle exceptions - such as file not found
& P/ h( D6 i1 D4 O) l& T                // Reading the files will need to be placed inside a Try-Catch - just like this one!
2 h  B7 Q! i0 t9 U; B                // For more information see page 534 of the textbook
: a3 x; j8 G; I) u; a6 ~                //********************************************************************
$ u, x; ?& A$ ~$ ?2 T9 S                     4 u2 m) d7 ~- S* [
        }
$ j& j0 u+ h7 Q+ K9 r& L             catch (Exception ex) // Exception caught here and message displayed to the screen
" y8 |) m* T2 d- i' w: x          {
) r) A# y% ]9 D9 O; U9 b- Z4 T+ M                    ex.printStackTrace (System.err);& d7 a* J2 m  W/ j
           System.out.println ("Error message goes here"); // Replace this error message with your own         
' M# o! d: k7 i1 Z/ x8 G0 l! }        }
- k# \) e, r' t0 S8 R* \, I                return true;
5 ^- V9 Y, S( H7 J; s$ M        }
/ w% ^* e' E' U7 T" Q% t# `6 k, C; G
} // end of class ProgramCompare4 i+ Y: {: k% p; U$ I

& b7 ?; Q* h- g' ]//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************! j% h9 Z" d1 V$ o; W3 [
//  ProgramCompareMenu.java    Provided by: DRS
0 i# r4 U6 P4 g% l4 N' m0 U//% y3 y! r! y4 a7 M" o+ {, i
//  Calls AuthorisedUsers.java and ProgramCompare.java0 O3 Z8 x( x) d% }5 e
//
% A- ?) R  i1 m8 I# ?6 C//  Driver shell for Assignment 2.
7 `, c9 P% ]; t: A( V//********************************************************************/ A3 q. ?- k; ?5 ^' I

( }7 t8 D: }9 ^3 d7 {class ProgramCompareMenu+ q' S6 l* ]" v3 H
{+ I! p! z+ J- s, U
    public static void main (String[] args)" M4 h3 [( |: g! i8 s  D" H
            {
1 u8 Y1 e- a5 v) x" T5 [                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable# o) \) _+ ]3 S8 o0 G1 d  `
                ProgramCompare reached1 = new ProgramCompare();
- Z7 }4 r9 e4 {$ \2 w; ~$ b                AuthorisedUsers reached2 = new AuthorisedUsers();       
' e; `* ~7 W0 g) q                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());1 a# v. y" H% ~; E0 A% U1 `* a
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
. `" H: ?8 l8 u6 f. y4 I9 p        }
: p8 v$ R8 \; l+ C9 A- Q}// end of class ProgramCompareMenu& H# U: @$ i2 \8 X, @* @0 {4 F0 v

1 ]! d$ ~$ d& }8 ~3 c//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************4 V: e  d1 q  j: A4 a4 v% Q; p
//          AuthorisedUsers.java          Provided by: DRS
5 y# l' V# q7 H, r8 e//                : N* O! D( t/ i3 a' Z% m
//         Program shell for Assignment 2) }/ S* d, @: y0 \4 O6 W2 T$ U# g
//
' c; L  Y0 A8 F6 G4 I/ h//         Represents facts about an AuthorisedUser' t3 Z& g7 }; ~4 x; T% i
//********************************************************************
% f8 I( f& J2 F; A9 N% \* P+ f: `5 f, Z
public class AuthorisedUsers
0 v0 p$ D4 `' ]6 h& k4 N    {+ }7 w2 N7 }4 y9 ^
& \+ l, C$ P5 q; w
        //-----------------------------------------------------------------" r! ?! i# Y  g' H1 Z3 l1 q- L1 P7 c
        // Constructor
# b! j3 }1 o" N" z        //-----------------------------------------------------------------
/ B7 ?. w5 F1 x, |- [; z3 r; O! o+ s2 I
        public AuthorisedUsers()* s7 i2 J1 h: g9 J
                {
' U0 O- m) f8 K) l* f! r1 Q                }# C" I! w7 A) L& c- z

) A; ]" o, w9 Q% x        //-----------------------------------------------------------------
- \8 N6 j$ w* V, K) Y        // Method for testing that class has been reached
' f# `  e( g9 |  s2 }' ^, G& j        //-----------------------------------------------------------------        ' f1 ~) ]3 y. d% _
        public boolean AuthorisedUsersReached()9 d1 a8 D* S$ b$ i6 [5 l
                {3 j! R2 I/ ~3 m! D
                        return true;                       
1 j% D9 c- X6 g4 y1 {# A                }, o* j' d3 t& f2 f& j% ~% x3 P
               
. h; J' e8 g$ ?8 D7 z4 J    } // end of class AuthorisedUsers  _( H; X; k% ?+ ^
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming9 A; W- j5 t: G2 o2 \/ X1 ]* s
Shanghai - 2007& x' f! z# G- f6 |4 ]
Assignment 22 u$ W( g8 }  w9 U
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)
) `  u5 L% e4 H2 N; [  {1 g$ N1. 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.
  n% _' ^, q9 |4 bThe staff must be able to:) h' |/ H: c4 _9 c, a( E. z. g0 J9 r0 T
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.  h$ A: I- W; @2 l
1. 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.$ q6 [7 l* s* i. r1 d2 Y. W8 P, U
 The interface should provide a menu so that the staff can:6 R) U: {# o" c9 S5 p2 w
a) Enter the names of the two Java program files to be compared2 S! ?' l2 J& e" Z# `
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.8 X6 n6 K1 y: r: N2 Q" w
** 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# a+ U) ~. I. E6 Z9 G# lBSA104 Business Programming – 2007: Assignment 2* J* A* z: J7 {6 U. L' ], z
Page 2 of 5# E/ N8 k2 p! b1 @  c( F' {
b) Print out to the screen all the lines of code that are the same
8 N* O- m1 M( h8 s# x5 k! N9 p/ O Include the name of the file and the line number of the code being printed for each of the two files
. n% O3 Q' ~+ N# }7 q9 `c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared5 w( }! }. z3 [- ^; s
 the name, username and department of the user) v" ]: P* W7 E4 F
 the statistics of the comparison
1 x# f3 l5 q* ?+ X3 j  y! k- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different/ `  j* n0 C' s/ e
 the recommendation for further checking
* Q5 a0 K9 u1 q; T3 r- 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- O3 p! L+ G: N# H, H# K
 the names of the two files compared
& ?' i- V- B: B" w' P! _d) Leave the program (exit)
; N4 m- M8 c) e# hThe ProgramCompare class: (Total maximum 20 marks available)2 {9 N: R  ?) N- B+ W. f
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)" G8 [: Z6 {: T0 p- k5 T9 g6 a& A
a) provide an error message if the files are not found or there is a problem opening them
& K6 L0 U, h; y9 ^7 n( j* v' u! |( wb) compare each line of code
3 H0 X* T  l) B2 G) L8 fc) print out the lines that are the same
) {0 f* [8 ]6 U, }& K: z1 nd) count the number of lines compared / lines the same
5 y* a& a( T0 ^# p# D3 \5 K1 T  ~The AuthorisedUsers class: (Total maximum 20 marks available), m3 ]% d) Q! C& C6 h
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)) A7 @7 e5 K, J9 `- j
4. Provide methods to:
- Z: I% i& t6 w, _) D+ e+ xa) 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' s7 |9 [# o" O' ]6 w, x" b% {' p
b) return the name of the authorised user
- X/ B, ~7 h, o4 L1 l& h% B3 ?c) return the name of the department of the authorised user, y' G- o8 }$ d( N+ ?0 y
Individual Data (Maximum 20 marks available)
* U* o3 Q7 A8 G. G. J3 l5. 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.+ q5 |& |. n; J' L/ ~$ C) v+ t
Documentation (Maximum 10 marks available)4 }/ c( y2 t: d" b
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.5 w- y0 e8 f7 c; }5 \" h/ h
BSA104 Business Programming – 2007: Assignment 2
+ ^3 q1 o/ ?' c& x" r) jPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
9 s. o/ ?/ \4 y& \不过你要翻JAVA的类库说明。你有下载没有?
) `! Z4 K7 ^; S4 M6 y查询关于对比的函数。貌似关键字是contrast,还有compare, S) X2 }9 h2 c- C( X# o/ v# V3 i
! j+ L  w; v# D9 G/ {' M
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
% d9 S4 u" S5 z! y; s6 g) ~痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
. w7 S5 _9 c, [+ _- G可以下载到的 是 jdk-1_X_0-doc0 L! P) G# w8 t. L! A
% x$ A  h% O4 M0 M
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-9 09:04

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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