找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1548|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 $ Q6 d5 T% f/ g- _- I1 E6 ^) q, k& `) c3 o' F5 p
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************! o$ Q' N$ Q1 \; _9 b
//  ProgramCompare.java         Provided by: DRS
+ _8 I6 d% g& X: w& K//
4 t4 l1 r5 y4 s, {//  Program shell for Assignment 2
; i7 V5 @4 ~2 b; Z: b//
% i! b* S% x5 e//  Compares two text files line by line
) r- l$ z2 Z* H' _2 }$ o//*********************************************************************
/ I- n  y: C: n6 W, g3 w: h  o2 w" O! T7 l. m' b1 m* K
import java.io.*;
0 {1 E& Y8 x7 @0 U- [) h9 `
/ [% t. J1 X- X3 ~public class ProgramCompare
, M0 f/ o/ G/ B& y4 l$ D& {. l{" E/ ?; L2 [( L
        //-----------------------------------------------------------------
& E2 y8 q7 x! @        // Constructor
; q# T1 d- j9 p" ~5 R+ U        //-----------------------------------------------------------------6 G- j' p4 S, a* e+ r6 @3 l9 G
        public ProgramCompare()6 _' t) w8 N* W, c
        {
- j  d3 {' _) Q# P- w4 n9 F        }
7 N+ V; b4 m6 `7 g2 i5 {9 M! K3 t+ F7 w; X$ N( \" p% s1 P7 [
        //-----------------------------------------------------------------
2 q( k; }$ a. n% t        // Method for testing that class has been reached
" D) c6 t  h; g) p5 G- o5 s        //-----------------------------------------------------------------        - v2 e( c; s( D* K# a; I* P* T
2 M! r/ r' W1 f" Y  D4 H
        public boolean ProgramCompareReached()         ! m% |! j) c' a3 i+ {
        {
2 A& I' C5 c: @: n0 W5 S- L      try
1 [% w  A2 |# v7 A) J   {        
! u* e, O0 P5 y                        3 j" ~  M' Y( f
                //********************************************************************
" R/ S3 O% ?1 H0 \3 u" p$ [                // Try-Catch Statement is used to handle exceptions - such as file not found
. w9 Q" j& {, o3 y+ _6 l* A* ?0 L                // Reading the files will need to be placed inside a Try-Catch - just like this one!1 }! }7 \. ~0 S( x6 f' D( f( e
                // For more information see page 534 of the textbook
& k0 B/ G, [5 o& Z/ h                //********************************************************************
1 R6 y. F/ z6 ?5 @) T2 Q                     . q3 m8 T& k- q
        }; h5 R7 R' e% h% h
             catch (Exception ex) // Exception caught here and message displayed to the screen
7 j, i( r: z! V. B6 v. k6 o% Q4 t          {
) L% O9 P  Y* \" W8 j8 `                    ex.printStackTrace (System.err);
  u* J1 I: b+ v# g6 l9 Z           System.out.println ("Error message goes here"); // Replace this error message with your own          % k' C( ~: j1 p8 A' K( J
        }
* s. U- n% X6 q3 P                return true;) {4 T8 E* g* j4 Z, K
        }- v5 a4 l' K6 s8 L) P, i0 Y
) k1 [) f! @4 _$ \- F
} // end of class ProgramCompare/ y# y! o7 Z. d* S: A9 H# G% b5 f  o
7 j+ _1 _+ Y+ r( m
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
# ~, h' h; t6 Y: n//  ProgramCompareMenu.java    Provided by: DRS  x) U, T/ p! p; T. G, j/ Z, H
//
0 s& L6 B1 y" j//  Calls AuthorisedUsers.java and ProgramCompare.java
3 k1 f$ P/ V+ j2 Y+ ?2 p//
2 i( w9 ~: r  R//  Driver shell for Assignment 2.
3 W' l0 E( w& E2 x7 \8 w( ]//********************************************************************
0 k, \' c5 ^5 f1 Q2 H, S
2 H3 l+ H' y, k% }* s+ Xclass ProgramCompareMenu
! l$ v& Z% h7 E* D4 G{
. z  m4 ]: t6 D; y( H    public static void main (String[] args); W# C8 H) t; V* s, o. M3 s. M1 l( E
            {2 J  \/ C5 a+ o3 @: t* ^9 q6 a
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
7 I" {, L3 _$ @6 L( B! {1 D8 z                ProgramCompare reached1 = new ProgramCompare();
/ _3 ^9 {9 O0 V  D8 D* m$ J                AuthorisedUsers reached2 = new AuthorisedUsers();        * y9 m9 s- c: d5 f
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());6 H3 ?/ x( M+ j+ S4 |6 C! X. j
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
9 S. D8 \8 t8 Q3 h! {- L: n( D        }
+ _/ X+ q4 p8 D6 S% @}// end of class ProgramCompareMenu. N& U7 z9 l4 f1 ?6 u5 r1 b, y
' Q: u: A+ d* v+ u- O# P
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
0 I+ m2 z& z$ [. [# B8 r/ b//          AuthorisedUsers.java          Provided by: DRS
7 n- f) i, q+ `; U! j//                + T9 c% L1 M+ d0 u5 l. \- E0 j1 p
//         Program shell for Assignment 2! X/ ^, w  a0 `) C  X
//
1 a1 ]7 q0 [2 j. k! c/ j0 U2 g//         Represents facts about an AuthorisedUser) v+ T& i2 t; [5 i5 u- w2 e
//********************************************************************: o: m5 @8 i$ }4 {- ?- _% Q
$ d3 D6 x* N3 P$ n
public class AuthorisedUsers. i" A9 e4 Z4 f( J- ^
    {2 V  ~9 f- v; y0 Q% L
+ Q& ?0 H/ X  t& V( Q0 X0 N6 l5 ~/ ^
        //-----------------------------------------------------------------
8 M6 H/ f! w( K        // Constructor
" l) E: K1 l/ P3 r3 s        //-----------------------------------------------------------------7 |* k$ Z5 A6 [" {9 {9 L( z1 l
" `/ O; b+ }; q4 b9 j
        public AuthorisedUsers()
, a. g5 @( O. e% y                {
' k$ Z! l( C; ?# N; Q                }2 k, N2 O, y) [4 r: Z4 S
, T5 W6 y: C! K, C- J0 V
        //-----------------------------------------------------------------/ s5 k+ l  c$ j$ U5 d
        // Method for testing that class has been reached* w& W' n  C+ ^. U6 ~- a7 ^8 t
        //-----------------------------------------------------------------        3 M: b% o9 z4 P) G# F) X
        public boolean AuthorisedUsersReached(), Y& I( `+ w" O) a! A
                {
" l& R8 @9 v# V4 u! F                        return true;                       
/ g) z' k. D* r; p- e. E6 b! B                }
. N, ^9 |6 z2 j# w               
; E! m" I9 J2 k( P& N2 n7 E4 @1 ^    } // end of class AuthorisedUsers8 A! B# S( L6 p* f4 f
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming- G0 S5 {0 i  v& Z5 [: L# M
Shanghai - 2007
3 O0 ^2 n8 F3 g. S  H+ r' |" pAssignment 2: y- l: u  B0 C$ T
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)1 C' ?( d: }# U/ s9 [' l3 v7 Y
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.
9 w$ S) v1 I) Z$ w$ L% k1 e9 H* iThe staff must be able to:" T4 G% o. f* f3 y4 z& K3 C
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **." T- L. _9 O$ o6 n
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.# t- |0 K* C6 S7 q: Y  h9 p
 The interface should provide a menu so that the staff can:
% a8 X1 C2 }( ]6 ra) Enter the names of the two Java program files to be compared6 B' M2 Q  }6 }; E: M) ]( E% d
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.$ A+ t% M, ^- c! ]; y' ]6 c- 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).
1 E1 m+ N  E4 T. \5 E, F6 v& B9 QBSA104 Business Programming – 2007: Assignment 29 h  ~% M, c0 b5 S' t/ m1 A" j
Page 2 of 56 z2 `, F- A& g/ K# P) |
b) Print out to the screen all the lines of code that are the same
$ `! @0 j4 ~5 i4 e& a Include the name of the file and the line number of the code being printed for each of the two files
* U; f, t) x9 X9 ?0 ?, c; c# ic) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared( f# I! E9 k  S/ _( w: }& T
 the name, username and department of the user) j5 V0 q  w; E9 `$ g9 v( O
 the statistics of the comparison3 ?# a: f! R! d  E# i
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different2 M' Z7 g) s& ^
 the recommendation for further checking
& F) e; x( |* c# |' q- 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
  N2 ~4 L; X0 Y7 e+ X7 I the names of the two files compared
/ `% f6 W! c' }" n, ~6 {% D" Q0 E7 pd) Leave the program (exit)9 u4 q( {8 R, }- z+ V
The ProgramCompare class: (Total maximum 20 marks available)! o3 L( R; l* d) h6 d0 w! Y6 u
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)
5 O: K* E& {' d3 N4 c$ _" _- ua) provide an error message if the files are not found or there is a problem opening them
% V) B3 n: K$ x# D/ D) r( M! n6 ^9 |b) compare each line of code
2 X6 Q. u% v; y8 y: K% C, Ac) print out the lines that are the same  ]1 M) k& C8 g" S. p4 i
d) count the number of lines compared / lines the same1 d* I8 e' @0 m; k. t
The AuthorisedUsers class: (Total maximum 20 marks available)+ u9 I7 G: [6 t  D$ I3 C
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)
# l9 a% g9 A9 i8 D4. Provide methods to:; [6 e0 L6 r. R$ C+ f8 k# s
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% E+ ]9 |  H2 P5 N  C
b) return the name of the authorised user
6 X3 @; E& `* Qc) return the name of the department of the authorised user
/ L! f) o9 @: ]2 N. E; N6 oIndividual Data (Maximum 20 marks available)
- Q: L9 P1 [0 S+ A2 [  A% I# z. L0 Z5. 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.
' P) j* j/ _& Y% k: w, [; k) \0 P% ]Documentation (Maximum 10 marks available)
! L1 {" P' g2 f! T  H+ g6. 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.
/ g' k/ O( B4 x7 t& wBSA104 Business Programming – 2007: Assignment 2
6 q6 F1 n( H" x8 sPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
( Q' ]8 r4 ^: k+ A7 z2 {  g不过你要翻JAVA的类库说明。你有下载没有?$ _7 m# I9 F+ L
查询关于对比的函数。貌似关键字是contrast,还有compare: O1 W* Q6 L  G1 Z# M- Z# J; s! x; {
  b( ]# y3 y; y% I; J: ]1 k0 I4 Z6 D
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
9 s2 S8 Q% C- f# C# V; |痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
' g" @# a$ x$ W! d/ L5 x, o6 T可以下载到的 是 jdk-1_X_0-doc. Z. q0 K1 o, @2 j4 N& p

7 u: c4 R- m$ f[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-18 05:24

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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