找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1152|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急/ a- {; }" w( _ t% d% {2 f3 S. Y/ |& Z , ?4 e6 @4 {! N& M2 g$ `
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************, p6 m) h  H+ G! [9 `) J5 F
//  ProgramCompare.java         Provided by: DRS1 w: ^8 J0 B" M5 e. Y
//
* h: W- H0 c( F( _3 Y//  Program shell for Assignment 26 c6 O$ h. o; W( Y# \& }( @, T
//$ l2 J+ u; l8 C' v$ q4 A
//  Compares two text files line by line3 ~, h4 L3 u- [) g/ g/ v0 l# U
//*********************************************************************
. n9 a) R: d. j/ X0 V2 O0 ]) V0 T+ I
import java.io.*;$ S' B0 i8 v: J5 V1 w, A/ w

+ n/ s0 v0 n/ Z3 _public class ProgramCompare
' C& [5 t+ ^' F% i  v5 l{- L1 v2 K6 y4 i: d* L% t- q4 H
        //-----------------------------------------------------------------. S- n# f, P/ @, }  I9 C
        // Constructor2 d' _: [6 F! v' C1 k3 }
        //-----------------------------------------------------------------7 s0 Y- {7 l7 _
        public ProgramCompare()+ _; d1 k3 L/ z5 j4 L
        {' P1 l% O! L; ?8 G+ M, d( [
        }  U3 I: A1 w6 s7 @
7 Y1 V) C( @  m0 O$ W/ \0 V
        //-----------------------------------------------------------------
8 ?% Q4 ^5 w* v3 c! K& l        // Method for testing that class has been reached5 _* T2 ]# w8 \" h& l/ C2 f9 W/ m
        //-----------------------------------------------------------------        % [+ [9 }* t7 x  F6 G/ g
/ Z0 E! }( @+ n
        public boolean ProgramCompareReached()        
  f7 h7 c  m! l; o; _  Y        {) N: n( f9 ?2 H8 J, @: ~- h2 ?3 S4 ~  L
      try
6 K$ }! l2 y8 G% c# J$ h   {         . r5 N6 t/ c3 @1 l* Y% l
                       
. b; M: z; u  r5 @  I, j% X                //********************************************************************
& O" _* E: d& A# _, Y                // Try-Catch Statement is used to handle exceptions - such as file not found 9 {, G* [: B+ L) k9 [, y
                // Reading the files will need to be placed inside a Try-Catch - just like this one!, w9 Y6 L) E1 \/ Q7 E+ T6 Y: P  y
                // For more information see page 534 of the textbook
" H8 y0 ^0 T$ S/ P( ^) C2 h6 g                //********************************************************************, W) H$ H8 W, X1 @) @- i
                     ; _  U- ?! f5 q: T( B
        }+ E9 `% u6 U. Z5 l: N- ]. m
             catch (Exception ex) // Exception caught here and message displayed to the screen
+ O( B' r8 k+ b$ l, G          {
. L  r* C& n+ ]( S! F) m                    ex.printStackTrace (System.err);8 q* G" i4 ~7 O  s7 \& ~
           System.out.println ("Error message goes here"); // Replace this error message with your own          . O) S/ \4 f( M# W
        }
4 V1 U; [- E( b  \$ t9 X                return true;
7 Y% P% k' ?. `  v4 I) P        }6 t& }- X; y7 a9 B  _; I) Z3 ^: m3 n

' t1 \: c" P* e9 u5 A8 N} // end of class ProgramCompare! x1 d0 s/ D) b1 X, a; \3 M

  ?: @9 g, z, D7 D, K) }//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
. q8 f3 V" u6 o* w% a$ i//  ProgramCompareMenu.java    Provided by: DRS, h1 w5 _- c" ]( R+ h
//' m* ^( A9 I+ j5 V$ j5 j; ~5 B+ @& ^
//  Calls AuthorisedUsers.java and ProgramCompare.java! l1 z) }( S3 E" ~7 }2 M
//
4 P# |8 Y# V$ V( W" o) m' o//  Driver shell for Assignment 2.0 X3 Q% ?5 V" G$ r# Y
//********************************************************************
& Y, B2 F1 I" T
5 ^: s9 g, ~3 U1 D6 {0 c# Z, Lclass ProgramCompareMenu
+ Q/ J9 m7 G4 |# V0 }: n1 e{
& `: W6 p+ z; x9 J4 s    public static void main (String[] args)
  [5 d8 x2 R  E% a$ o; R+ B            {
0 K; m1 k" m- U3 g                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
. q% I0 _% i+ }) ~3 i) F                ProgramCompare reached1 = new ProgramCompare(); ! Z5 n$ |: k5 T8 Z( T
                AuthorisedUsers reached2 = new AuthorisedUsers();        ! f4 j( h' B8 e, J, k7 i5 z
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
& T, ^" Y  O' }5 ?" v0 z7 M8 L                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ( g! N& E" e' a
        }% U8 g5 M2 a; U, t* Z
}// end of class ProgramCompareMenu- s0 l& b% \" m: P) j* v% e

  s/ I6 o  J+ E! j//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************6 U: S# D  e6 c% z5 z! V
//          AuthorisedUsers.java          Provided by: DRS, B* ]( j3 f  x8 I: M3 {  y) l% h
//                / |; ^: H* p5 h2 L8 Q/ S
//         Program shell for Assignment 2
0 \7 m' j, _5 R* G& S//' Z9 M+ C  w+ w" S" f5 B
//         Represents facts about an AuthorisedUser
; u( ~1 x, l9 j: I//********************************************************************# d% p; e. p% q+ {1 n% [6 _3 V! O
- c' l0 n8 ?5 P0 I: R4 S
public class AuthorisedUsers
5 [- n( d& o+ v: \* x% k0 ^+ w7 x    {
8 P5 s2 |8 l! w- L. E: c5 v- F! W5 ~& X# ]: s
        //-----------------------------------------------------------------
* D' \: S. e; h6 }        // Constructor5 K/ j# H3 }, d2 ]5 @9 k
        //-----------------------------------------------------------------
7 E+ f$ w' E0 k9 }( h; I
* W% Q) I5 z+ B  [( L; T7 M# k        public AuthorisedUsers()
. O, }7 T6 E) Z% E* T0 d: G                {- U  F1 h. r3 D1 D! V' ^
                }) w9 j. e5 U" X8 O& D6 V

6 }0 _) c4 J  t; J, `        //-----------------------------------------------------------------
  a9 ]# M* s8 Z  U        // Method for testing that class has been reached
& u- }0 s+ ]% l& Z' o+ l, {) U        //-----------------------------------------------------------------       
1 `2 R( w( h! E) X5 u% L        public boolean AuthorisedUsersReached()
* m; i4 Z3 D" y% V/ t                {5 o# @+ V; T- k3 r3 i
                        return true;                       
8 h- u/ X$ E% H( J0 m/ L7 V                }! |# q6 D) S4 Q1 T
                * v9 p: g# i  W: \
    } // end of class AuthorisedUsers
( f- c$ ]# I9 \0 t) B//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
7 l& s; F$ w( w/ PShanghai - 2007
1 `. N9 K( ]% e6 b0 Y, C. xAssignment 2
; @* s( c. @4 I! H$ ~, J$ BDeadline 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)2 D  N" j9 y& j1 w6 e) Y! i0 @
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.* J% S% i. o' g% G+ b! C4 W2 `- @
The staff must be able to:
3 y; k# k8 d& Q0 n# a Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.7 @5 d& B+ K9 q/ u. K/ }
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.
1 C7 |2 n7 C+ ^& {0 A The interface should provide a menu so that the staff can:+ A) D9 L  _& N
a) Enter the names of the two Java program files to be compared) }6 @% t; R7 j+ F+ K6 j
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.8 s+ Y2 ?, c; o1 U4 M: ^: i0 V
** 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).3 }* {! D+ y6 z* D% W4 T( {
BSA104 Business Programming – 2007: Assignment 2& C% h  v" y0 Q4 x
Page 2 of 5
/ l# \" x  u: ?. V$ T1 X6 t5 g5 x; pb) Print out to the screen all the lines of code that are the same
4 l' {) @+ H1 ~$ [! V Include the name of the file and the line number of the code being printed for each of the two files
& w1 u8 e* @3 X2 x. m+ [4 o" }c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared% p) c6 I' I  ~& S2 y
 the name, username and department of the user1 A1 o, m5 p! C" j
 the statistics of the comparison6 L# [7 Q) u2 v. O; {
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
/ r8 M# |2 r6 O$ q8 L the recommendation for further checking0 d: H* a9 ~& T3 ?, B# t. G
- 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# T5 P3 j9 [, B2 f& {
 the names of the two files compared
) w# @* e9 ]3 M& u, [2 m% {d) Leave the program (exit)
! ~# d+ g8 V  `/ gThe ProgramCompare class: (Total maximum 20 marks available)
2 j, d8 K; u  H# \1 a: j- B) 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)
7 G- N: {& e7 z- ]# Ya) provide an error message if the files are not found or there is a problem opening them
9 b. [5 V9 D  P2 A' Ob) compare each line of code" v9 e; I9 J1 M1 K6 g8 {) F3 U
c) print out the lines that are the same
1 X) C( [1 ?) Z  }- Nd) count the number of lines compared / lines the same6 F5 c  d( c6 x
The AuthorisedUsers class: (Total maximum 20 marks available)
! H& w9 g* M1 ~& z, R" v3. 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)$ y, n* Z# L" I$ M+ \9 F0 o% }! }
4. Provide methods to:+ @! h& @9 l. F
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
5 Z' C4 i# z% `: t$ ob) return the name of the authorised user
9 }% `+ k' S/ c: W# t' v% pc) return the name of the department of the authorised user
% S9 m' c% U! M- GIndividual Data (Maximum 20 marks available)
' y3 e9 h) t0 X3 e5. 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.4 M( d, g) i" @2 E
Documentation (Maximum 10 marks available)
: |3 E: f. }; ]6 v; c1 G) A3 W1 F% j6. 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.! w) v0 `/ N& q. J) p' o- k5 R2 Y" p
BSA104 Business Programming – 2007: Assignment 2: [) ]  D  o- w' T$ N9 L
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了7 i- x# L$ {% y6 p: I
不过你要翻JAVA的类库说明。你有下载没有?7 m2 f4 u% ~3 A, I: h
查询关于对比的函数。貌似关键字是contrast,还有compare* l7 q# v: a0 W- I7 ~
# M/ s" H- H8 K2 b6 ]
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
1 b. i  y/ S4 P) \3 q6 h痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。& ~6 N. ]4 A0 h/ ]" n' _$ S
可以下载到的 是 jdk-1_X_0-doc
# O. a6 D$ h* R+ I, I0 b' J( U6 ?" H" v, q/ R8 [
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-1 18:51

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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