找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1676|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ' l# U3 T( {4 D# w" I8 {- s7 ]; L8 Q
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
. Q/ q. c& g0 X( G/ @6 I//  ProgramCompare.java         Provided by: DRS
, p! y( v. u* E! e/ j! }//, \+ j7 K" E" u! S
//  Program shell for Assignment 2
6 f# l- l0 O4 ~8 i  F+ h7 C//& Z" a5 J2 R0 H9 K# a) L! j* \
//  Compares two text files line by line# x+ K) ~) m7 c; ?1 }
//*********************************************************************4 i  o/ N; p' F1 _2 n$ |" s* ^

) _3 s/ G0 K' L0 x5 U' limport java.io.*;
" o) v) T8 v' a# J3 {3 k8 ?
: U, K8 c( Y- ?: f7 y# h: Zpublic class ProgramCompare
- D9 [. \, {1 D3 R9 b/ Q/ ]{/ Z& x, G( |, D7 `' T. C' z( z; A
        //-----------------------------------------------------------------4 A+ g( U# R3 N7 U6 [* V
        // Constructor
# w4 z7 e1 `6 k        //-----------------------------------------------------------------
% @7 D2 L1 v$ ^" ~: t) Z2 Y        public ProgramCompare()
4 K  r+ s- A9 q: w3 @9 c, n5 H        {$ |+ {* i$ w* v( Z1 T
        }
4 [/ V, d; K( `: d- ^' r0 g+ n# s. H. z; A' t0 |* m- X
        //-----------------------------------------------------------------1 s! V1 |5 j$ Y
        // Method for testing that class has been reached8 ~& {9 T; ^: U2 Z0 c5 i/ l
        //-----------------------------------------------------------------       
- s- Q5 U1 W9 y2 v8 K" }+ C+ z+ m& t3 Z+ m; P; O6 A, v
        public boolean ProgramCompareReached()         8 s6 F9 y+ @, `
        {' c* R5 g4 w  g' [; t: ?; S
      try $ k8 i: P; l/ Y1 v
   {         5 s( t% R3 ?+ J+ p0 L7 }( C
                        # e( g! n8 v% ]8 g
                //********************************************************************0 P% g7 y+ O( e' q$ Q! X, O$ }2 K
                // Try-Catch Statement is used to handle exceptions - such as file not found 6 n" k2 z, t3 T0 l8 B0 {
                // Reading the files will need to be placed inside a Try-Catch - just like this one!' d  x: d% ?% O3 g( O
                // For more information see page 534 of the textbook
" q- g% ]( M3 {0 u2 ~& u                //********************************************************************
! D: I" ~' O! v, A                     5 z; D# o1 T% |% i6 T6 F, `
        }  _& \  @) z4 `# C9 @
             catch (Exception ex) // Exception caught here and message displayed to the screen
- D1 ?3 R$ d/ u8 E0 M% W, A+ Q          {
" g- Z3 z  q) `  k) ^, B                    ex.printStackTrace (System.err);
! z" c' h7 B; ~2 S' s8 x+ d           System.out.println ("Error message goes here"); // Replace this error message with your own         
: [) z: F" U3 `( ]0 g, C/ }4 d        }
, V) C) I# l7 ^$ ?$ s                return true;5 @& X2 }) p0 O( ^( b
        }& u( D! @0 w3 w3 Z

/ z% E' }3 }; I6 E3 r+ J} // end of class ProgramCompare
4 ~1 ?: e* H" ~# R
. E3 n0 o' S3 W3 k6 e6 U3 G2 Y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************% l8 U  ^" ]* [3 m6 A, [2 \- V
//  ProgramCompareMenu.java    Provided by: DRS, w5 w$ w2 |2 Q
//
3 A$ q8 q$ |0 f" h+ T: I! x//  Calls AuthorisedUsers.java and ProgramCompare.java. A" ], Z; l2 z% b  z
//
$ X- n: W5 ^8 H7 Y: E7 X6 C' D0 t//  Driver shell for Assignment 2.
- N! s' o( T- s$ Y' m; x3 e//********************************************************************9 s3 H& _* C+ L4 {+ s

4 ~# }- W+ l# V! vclass ProgramCompareMenu
3 ]7 m; \2 O, `{
4 y$ g' \- K* H* M$ D    public static void main (String[] args). `( n5 |& s. z0 Y, P( P
            {7 |1 E( v  d0 S7 M# I+ B5 y8 c
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
5 _7 Z% [8 p% W# U                ProgramCompare reached1 = new ProgramCompare();
; M* y' k) t+ \1 F# [                AuthorisedUsers reached2 = new AuthorisedUsers();       
3 P. [9 x5 t; f& _0 d, f& U                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());7 v5 Z. l  D8 {% P' S
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
7 `2 ~" C6 c! O7 h  X# B) x5 X! k        }: r; h7 N+ p' n
}// end of class ProgramCompareMenu
- M8 p4 v0 Y! R8 T1 E
' }, n" x1 D1 e" j//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
. q1 ~# j' X- p7 |0 D//          AuthorisedUsers.java          Provided by: DRS! f" z7 r& f4 x+ e8 D% z
//               
% k) F3 c5 e# `) P% U: s- D//         Program shell for Assignment 26 G' k4 ~3 m2 I6 g4 P
//; F. {; S0 o( A* o" Z
//         Represents facts about an AuthorisedUser
* y( F& @" b% L( x6 _4 a//********************************************************************
3 c% }9 G. ?, E( x5 l' p; F: N9 I) K7 x2 H. `
public class AuthorisedUsers
. N0 p2 {2 D4 `, L( ?8 l/ P    {6 e9 L7 W- l+ y# _  l! |- A! \

7 e0 e7 R& Q( E: E/ Z        //-----------------------------------------------------------------+ r; K  Y' @8 X" X  k+ H! T
        // Constructor
# M9 C1 S% |: l* B  {, F$ V4 b        //-----------------------------------------------------------------
' N2 J( K+ H6 v: j
2 A3 a' m% U! L        public AuthorisedUsers()
# z& Q$ K* U$ w. ^: N# C: G                {
. u- V& y/ u5 Y! P# q% |+ l( `2 ^                }
7 P: |- b5 R- O8 @& H' e1 B
2 F. u% x5 Q: T        //-----------------------------------------------------------------/ [& H$ L0 i% @" g! q6 a# l
        // Method for testing that class has been reached
; |" y" C3 {5 x* _" S        //-----------------------------------------------------------------        $ p) @% {) z2 z: A0 P
        public boolean AuthorisedUsersReached()
4 I+ k6 u6 [, p2 ?( ~                {& b& M' x# O# Z# Q. F
                        return true;                        / T# p7 R' V$ L7 C' s- m
                }* o1 t  R5 q- h: c1 u8 t
               
5 i% y. b$ h! Q' X    } // end of class AuthorisedUsers
# }, `; g" `/ g//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming3 _: v* z; Q# Y3 t7 F& T5 h" S
Shanghai - 20076 C; J/ P2 C! d+ q9 H
Assignment 2- ^. m, B1 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)
* [, V8 |8 ?! p1 k( ?" O1. 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.
. K6 k% b' d. G- u1 sThe staff must be able to:
$ C% U: W$ W7 [) e4 n! v* e Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
8 c9 o+ |2 M6 ]2 m, _7 o  o' t1. 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.7 k2 @5 b4 x% B$ {% u- u8 y8 B
 The interface should provide a menu so that the staff can:
0 F  \! W* N: M/ S) c. Wa) Enter the names of the two Java program files to be compared
- C: m# S, \+ G- k$ a& L% ? For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
# V) Q# Z9 T9 @# {6 X3 [6 ~4 r** 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).& D3 M8 l9 f. {* f; z
BSA104 Business Programming – 2007: Assignment 2
: c( o# b' J' G1 e6 uPage 2 of 5
3 V9 E, H" ~, K8 v$ {5 mb) Print out to the screen all the lines of code that are the same2 b- ?/ \* h! z! n5 }
 Include the name of the file and the line number of the code being printed for each of the two files
+ f, R; h! }3 s# i7 Z; Oc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared; w& g! A5 \1 J% Q# x0 D1 s1 [3 c1 X
 the name, username and department of the user
) T/ c3 r$ `" G4 x8 x/ e the statistics of the comparison
6 i) B  x* {5 L: L* t; F- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
, g* Z. p1 C4 Z4 S the recommendation for further checking$ O- s2 C' ~2 Q7 S$ X, R- e9 o8 _
- 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# {2 D3 e6 [* s1 ?3 k( {
 the names of the two files compared
8 z* G& ~& `) y7 S, J1 I# {d) Leave the program (exit)
# ^6 r# s; b# U% ?5 A9 lThe ProgramCompare class: (Total maximum 20 marks available)
* ~- z- e* ~/ Q/ u2. 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)$ H* j8 K9 d) }
a) provide an error message if the files are not found or there is a problem opening them
( k. p1 Q6 |# M) I5 Q  G9 a3 Z, ub) compare each line of code
8 S9 c( r# i: |, c& dc) print out the lines that are the same8 |' z; i  D7 w. X! q4 k' m( o
d) count the number of lines compared / lines the same
8 D5 v3 |+ ~/ e" {3 yThe AuthorisedUsers class: (Total maximum 20 marks available)  p- X7 l  m2 l% j
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 P8 I) p- G' Z$ u0 s2 H
4. Provide methods to:4 O8 G3 N4 p# L- E, z
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
6 Q! E% d& c3 [9 V4 L, Fb) return the name of the authorised user
7 f( N; g5 v9 w. V+ Kc) return the name of the department of the authorised user- F1 g* }! q/ o% v
Individual Data (Maximum 20 marks available)
3 L& s0 F/ _- f- }' p5. 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.
  _1 V  u  G6 y* V4 C" U2 c) UDocumentation (Maximum 10 marks available)# D  K. E, A! F, {9 G( y% P1 R
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.
' X4 ?# y/ q7 x2 @* mBSA104 Business Programming – 2007: Assignment 2
5 I' }: j6 M0 x7 y, ]) mPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了) B" n+ M" m; ]# N$ N; _+ B. w
不过你要翻JAVA的类库说明。你有下载没有?
) e! ?& J8 r0 {' h- x& E查询关于对比的函数。貌似关键字是contrast,还有compare
8 Y1 i& u# @, d3 Y. O. G: e5 |( B- I* i. |2 U  H# j/ b' G4 D/ w" w
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
: A7 H/ x! |1 Q  z; \4 n痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。9 q+ o1 K  {' ?. u. s  X. Q" E
可以下载到的 是 jdk-1_X_0-doc
4 t+ @' Q# e, B6 k9 \9 O8 s. w6 @5 s7 J# ^! V: E) j! W, l
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-27 06:41

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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