找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1575|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ( f9 m' Z0 t+ f. t ) ^! X/ J+ I0 K6 h8 A1 r
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
% [/ r( M/ M% ~% _1 w//  ProgramCompare.java         Provided by: DRS
+ }* y% p1 s8 B- ~2 L2 }. i//
/ T# T3 v, }2 p$ \# x9 {  K& n//  Program shell for Assignment 2+ J/ U1 n% y/ i% f% N( B
//
# W$ t# D5 `" b2 N" w4 ]7 S//  Compares two text files line by line
3 S, F8 f( }/ T3 o# @* l//*********************************************************************7 S% }! r+ X/ @' d$ K1 ]2 S5 j5 F

) a9 S7 b$ X4 C7 W4 I; i$ |+ \import java.io.*;2 d( e- o2 g& L, H1 ~% Z  z& T
4 ]  L% r. g' |; S5 ?9 ^% F
public class ProgramCompare
6 G/ R$ N: R7 K{5 U7 F  ]& C2 k. y& \
        //-----------------------------------------------------------------
0 Q" y6 q. c' e* v* h/ I0 B8 _        // Constructor; K' v) g$ Z( u. Q5 r* O, i7 w; F
        //-----------------------------------------------------------------; D, u  ~+ A4 S$ N  T: D" ^' I) z- s
        public ProgramCompare()( B$ N5 K1 R7 z; R+ A0 O
        {7 H, J/ N) }5 h8 L0 P# k6 z
        }
. O9 j( U3 F3 O8 {0 e0 |; g
- ]* O7 t* I/ K+ O        //-----------------------------------------------------------------
3 F/ ?! D% A) d% v% K        // Method for testing that class has been reached
; E' l. ]% n$ j        //-----------------------------------------------------------------       
; h3 L2 L+ n7 ], V
4 J' ~" k, t+ c+ T        public boolean ProgramCompareReached()         ' c" K; I8 |  g1 S' q' m0 X! I
        {
9 q6 H, F% A, {! o      try
' }' `9 i5 s* x8 S- |0 c" q; q7 Z6 f   {         9 \' n6 T: I4 G) ]0 e% I: |
                       
/ c# \0 p; V% `; R4 O# h                //********************************************************************
8 I) ^  ^9 S; M1 i# m! G                // Try-Catch Statement is used to handle exceptions - such as file not found
1 I( {& m* S5 o) E5 f% q                // Reading the files will need to be placed inside a Try-Catch - just like this one!
% ^, |6 b9 i9 }5 Z' d8 p8 R                // For more information see page 534 of the textbook
. `: ?1 L! ]' Y8 j& \' u6 T                //********************************************************************
" z' P/ P* F; N                    
% P% w2 n. A4 l: w2 T        }9 C; z* {) v) q, `; l5 e: Q/ O
             catch (Exception ex) // Exception caught here and message displayed to the screen * Y+ h4 M, S* @8 v* I2 D4 F7 f$ I/ A
          {: P3 B. s$ ?2 m1 P. T. @
                    ex.printStackTrace (System.err);6 g" S0 ]. v3 \& d0 n
           System.out.println ("Error message goes here"); // Replace this error message with your own         
( H( [8 A  r! g7 M/ N        }) y/ e6 B2 m$ B6 {% ~6 H! K
                return true;
! Y1 _" c9 z8 o5 x) B" v" |        }% k. {, a( w' R  u; }* C2 T, r
6 _9 A4 s5 b0 B
} // end of class ProgramCompare& k0 @; }; M7 t+ Q1 _/ Y, m5 D9 r* }

) R( A$ P1 D, ~; W$ V" w5 D: ^//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************6 y- {6 o! t! s5 q
//  ProgramCompareMenu.java    Provided by: DRS
5 v; u  y$ J7 @) }//
9 H( b& Q2 p3 f  u# K- Z' e: t//  Calls AuthorisedUsers.java and ProgramCompare.java# z- m; q! c# z2 b( R  h# S
//1 S- I2 X. C1 ]) _
//  Driver shell for Assignment 2.' _# v6 j, h& \  o% X5 `3 A
//********************************************************************2 \# P+ x9 ^9 N: {4 L/ t

3 j7 N4 Q( _* A& F9 ^8 [5 v6 U$ qclass ProgramCompareMenu
/ Z1 }3 a( R( Y# V{# c7 \% w0 H" s7 m( r1 q* l' x
    public static void main (String[] args)5 H8 D; J& ]: L, [$ W
            {- j6 R# C8 _" G/ c* ^4 |
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable4 J0 Q/ z' N1 |( |, E
                ProgramCompare reached1 = new ProgramCompare();
3 m  U- q1 ]9 K, _5 {7 K                AuthorisedUsers reached2 = new AuthorisedUsers();        * U/ x9 M- \% R9 P. }: a
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());' o; V. A6 C3 F$ v
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        1 f: z8 q: {" T
        }
' Z- P3 A5 j3 e  [}// end of class ProgramCompareMenu
$ D% F; Z9 u$ }7 o4 g
- [  c8 o& |5 h; H) w' N* R//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************. X* x/ @; L* r0 j3 W
//          AuthorisedUsers.java          Provided by: DRS2 M. Z% F' L+ C) l' n& X9 z
//                4 n1 D% P; a0 D- n) A) f
//         Program shell for Assignment 2
- w7 U( Q) m8 l. l, l0 {//
4 Z) y, V4 @; a9 S3 q$ J//         Represents facts about an AuthorisedUser" l' \7 S6 b1 z4 Q9 i1 S
//********************************************************************
2 Y  @0 a5 V& S  F  T
: Z6 q9 H: ]' y& vpublic class AuthorisedUsers. R- U8 d0 B3 h, T0 b$ u
    {
  l5 f- a: F1 [& i, c1 Q7 |3 r% ^% C# p; t" g# u# S
        //-----------------------------------------------------------------
3 `( x9 X+ A) U$ L  ^        // Constructor
8 ]5 `( C$ ?9 w, x2 }        //-----------------------------------------------------------------6 f7 T6 n, B# Z' q' b7 V
( ]8 R/ f6 z( }2 V% S
        public AuthorisedUsers()
7 t6 M  }& C7 |                {: U( n! h6 o  ]  r8 n5 J' K
                }( ?3 b" @' p, @( u

. ]- T; h9 b) t$ G& a2 ~# K2 D        //-----------------------------------------------------------------
, e/ n- h9 Q7 x9 X" Y" `        // Method for testing that class has been reached
) X' T- p0 N7 Z# l1 n. B        //-----------------------------------------------------------------       
3 \8 c0 K) y; v! Z* S, ~/ b        public boolean AuthorisedUsersReached()
% O% z* g' j, w& e                {+ G0 m/ j! q5 c8 S
                        return true;                        - L: T  }3 k# L6 b
                }+ e7 ?) m" O  A% D3 Z' s- H
                , Z' J- U. V+ k8 ^
    } // end of class AuthorisedUsers
8 R( C& x' z- D/ r6 X# l//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming% V! L  S6 w  g9 u. s
Shanghai - 2007$ Q  r" J7 |) f* A9 g$ h8 h6 [
Assignment 2
4 k& p$ z% N! [9 E4 B. d7 jDeadline 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)
; x0 p  a! i, q% E9 T1. 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., `( e3 H7 T$ c% t* ?
The staff must be able to:
) v+ c8 F* i+ A& Q1 G* Q Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
( `% [; P& U1 E4 q* 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.4 W, U: r5 d0 Q' S
 The interface should provide a menu so that the staff can:( Q4 O1 O/ y8 R% e& Q& X
a) Enter the names of the two Java program files to be compared
2 s5 R( {$ }, e0 B For this assignment, it will be assumed that the two Java program files are in the same folder as your program.+ ]8 l  j1 q$ S
** 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).
. [% [7 T9 A# ?) h2 v1 h  H/ L. qBSA104 Business Programming – 2007: Assignment 20 R5 ?% o, i: u
Page 2 of 53 F: S+ j* @, ^8 a4 f3 k2 N* ^/ t
b) Print out to the screen all the lines of code that are the same
) K/ [: g, i' d9 o5 Q3 G, V Include the name of the file and the line number of the code being printed for each of the two files
% p4 Z' C8 U* Y/ _3 a- |c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared& d) B* L/ _; \  R5 L- A& I5 |
 the name, username and department of the user* W3 o$ C8 {7 S0 R  P: O8 A0 u
 the statistics of the comparison3 C/ ]0 P0 E, ~, R) ]1 `9 P4 G) A/ q
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different0 w$ Y# w& k8 \( h4 f# P
 the recommendation for further checking% |, g# c; G3 }  e" w: R* Y
- 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
% l" q1 N: G* v' [ the names of the two files compared
! l2 I7 t; b; }* G4 md) Leave the program (exit)
4 U! W4 Y; {. q' Q9 u2 F. WThe ProgramCompare class: (Total maximum 20 marks available)# U/ x- Z. Y4 \% [; b
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)/ _/ x' e: M3 q  }1 ~
a) provide an error message if the files are not found or there is a problem opening them
$ u0 _! L+ i7 E6 \b) compare each line of code7 B' w2 Q1 @2 r/ i( n/ }9 }
c) print out the lines that are the same) H! j8 `7 j6 p; m5 @, j3 |! u
d) count the number of lines compared / lines the same! e9 Z' i7 K7 ]5 d6 d; [
The AuthorisedUsers class: (Total maximum 20 marks available)
7 ~2 ~4 B* \6 B! i; Y7 r8 E3. 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)
; s/ C* q% Z/ z* c4. Provide methods to:3 C5 A& F6 ~7 m0 J4 ]
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
/ L$ B# `3 C( Eb) return the name of the authorised user
$ [* N8 A! O; n! h  `1 Uc) return the name of the department of the authorised user
  e- i! x" w6 H7 @( wIndividual Data (Maximum 20 marks available)
. d. |0 m4 c& Z  y1 j5 ?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.
) `( e+ l, g# e/ D4 a+ QDocumentation (Maximum 10 marks available)1 o6 @' `9 X' j6 n- V5 P% C
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.0 X& ~5 H) {* T9 c$ x' q
BSA104 Business Programming – 2007: Assignment 2
1 C7 F: b! r7 i- ?: ?, W+ OPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
& b) t  L" k5 V不过你要翻JAVA的类库说明。你有下载没有?
, B1 {% X7 b# s& B0 i" n% ]查询关于对比的函数。貌似关键字是contrast,还有compare
. q  h6 P9 F) c3 A. J3 ^' ]5 C3 P+ H
3 N% |6 U3 m" j  E$ e[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
( M, o3 x1 n; p; D& k$ [" C. x8 S痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
! T8 }0 J8 m! d+ T& }2 R可以下载到的 是 jdk-1_X_0-doc( I8 S* u, v6 P! J# P

, w. L. _6 L1 ][ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-25 00:37

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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