找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1748|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 L$ f: s2 }$ n! I. i4 L. m5 b8 s; H/ g: P- `6 Z; I$ Z. [
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
  k5 H! S+ R5 F4 e2 I//  ProgramCompare.java         Provided by: DRS
% }( x) W1 O9 D) g& g3 I$ S& Z//- T; u% k/ U) D% ~7 a8 W
//  Program shell for Assignment 2( x& j" U6 r/ j8 d
//
) x9 V6 F& p  a' b0 A//  Compares two text files line by line
; \% E2 ]. N* P//*********************************************************************
4 m6 @* g6 r3 K5 J2 i5 E/ H' |; b' H4 M/ p7 N( _3 _
import java.io.*;
4 C2 q+ `$ _( _6 o8 {' p  j; W* M$ z" p
. Y( c; K( W3 Bpublic class ProgramCompare' m- ]6 x+ p) J
{8 ~/ r4 J4 a& S" U" S
        //-----------------------------------------------------------------
6 G0 g. w- a4 ?/ c4 f5 h. k: \/ l        // Constructor) _9 e4 w# V( i) l/ P/ `
        //-----------------------------------------------------------------
) B# C1 X3 K! F, y# o' v0 ?        public ProgramCompare()
9 ^3 G, \* ?3 w        {; r8 h; s4 _- \+ I
        }
, ]+ r; p2 j- _: e0 d+ G
& ~# s/ V+ Z7 e. C; o* |        //-----------------------------------------------------------------! \  N( |* J" Z  I1 u2 u
        // Method for testing that class has been reached7 X" {( g* p; R* e- g1 a
        //-----------------------------------------------------------------       
/ N9 Z! `  Y: A& A; o5 A; T8 `  b$ R
( p" o* H& X$ N8 u5 z        public boolean ProgramCompareReached()         . g. E, W1 y# V/ w8 d
        {# `8 z( z% u( a8 \( v
      try
6 h7 B6 P6 y/ a5 \   {         ! ?- `6 J! n1 V' L' V  o
                       
1 j$ ~/ S# k2 E# U                //********************************************************************
0 @  w2 z, p+ @( M                // Try-Catch Statement is used to handle exceptions - such as file not found 9 V/ v2 g. X9 `
                // Reading the files will need to be placed inside a Try-Catch - just like this one!/ D5 K$ P( S" C
                // For more information see page 534 of the textbook
: Y! ?8 U: Y1 V0 N                //********************************************************************
6 P# }: p9 d9 w/ c4 B  f7 s9 U/ ^                    
7 r( L' _; `, J' E% h' C% _* a        }
/ M$ p. ~0 x, b/ [1 r7 D! Q3 |             catch (Exception ex) // Exception caught here and message displayed to the screen " j* Z' ^$ D, t3 l$ o; W' H
          {8 a& M; g! w3 }0 n8 @7 e
                    ex.printStackTrace (System.err);/ ], `. a4 M0 ^2 E: [
           System.out.println ("Error message goes here"); // Replace this error message with your own         
+ j% e' B% L* A* Y        }1 |1 z$ O+ D$ D8 K
                return true;+ j  X& f& V3 z. T9 S
        }
  s5 c8 Y' ?$ P8 j5 r
9 h0 _+ Y* s0 P} // end of class ProgramCompare
. n( I( n0 Q; |5 |2 W8 q8 Q* {5 k. Y( }: s9 ~( ]" H
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************2 V- H0 T) z( x
//  ProgramCompareMenu.java    Provided by: DRS
/ k7 G8 Y$ W7 |7 U4 U//+ l& l& n6 \% C2 a" Q$ \. Y: u
//  Calls AuthorisedUsers.java and ProgramCompare.java
' E: d4 Q: l0 ~, F//
9 y/ H0 I9 D3 t//  Driver shell for Assignment 2.% N! N% R! \( v( z; z/ r
//********************************************************************
7 v) h2 I% |. x! `4 P
; K9 F6 V. H" xclass ProgramCompareMenu
# g0 [6 R6 j6 S% W{
5 M; K# ?4 k: l* @& N8 w    public static void main (String[] args)8 `+ r: W3 x2 G: [# k
            {
: G+ \" E  q# u2 D4 x# B0 G4 G4 h                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable$ i( N# ~% n3 W6 s/ e5 `/ |
                ProgramCompare reached1 = new ProgramCompare();
+ o; h6 W* I) a0 l( V" V                AuthorisedUsers reached2 = new AuthorisedUsers();       
' x$ Z; O! }( P  O1 ?                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());7 L* L! i& R& E, _6 C; z
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
8 G  m: z8 [2 |+ A        }
- ]5 l: t. p2 T  w}// end of class ProgramCompareMenu
( s0 A6 O2 M5 h# Q$ `/ p1 k
4 B" B7 r$ j3 _/ V! w' a9 Q( L//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************: q/ s6 K* _- }  c
//          AuthorisedUsers.java          Provided by: DRS
' @. L: q! O' ]: e//               
& f4 D# \( r6 |: X  h- I//         Program shell for Assignment 2
9 D# {2 _. _$ J5 m( u3 W! r//9 l( N# ?% h1 ~: @2 B0 r
//         Represents facts about an AuthorisedUser) {' [3 _  n. L
//********************************************************************
& `0 @. ?8 W7 ^0 h9 [
! `! I3 m3 t, ^. _- m/ Y( }/ Ipublic class AuthorisedUsers' _( s4 F# h, D& N9 P
    {4 P& Q4 _+ ]; |, k
, D+ }( ~+ G4 f# x9 o6 f# D" T
        //-----------------------------------------------------------------
7 a1 y. M3 i0 l+ Y, v        // Constructor
- R/ q7 M6 g# m( T: Q; x        //-----------------------------------------------------------------
" ?0 t: V$ C- Y8 P! }: f0 K0 G7 Y) }8 W
        public AuthorisedUsers()
* }. o& A8 {5 E) W3 C1 m7 [& [                {1 i3 c5 z) e- ~6 j+ }
                }
; C' W- `8 X9 D# [$ e
6 \6 s4 K1 q: D% M% p) W        //-----------------------------------------------------------------
: a1 [) E$ f8 _9 U- d! Z        // Method for testing that class has been reached8 N+ S/ S( J( D! U2 J' m
        //-----------------------------------------------------------------       
1 j1 N+ b: P0 v: k, j9 S  P6 [! Z        public boolean AuthorisedUsersReached()' _) |5 @" x) e2 ?& t( h& B" e
                {: Y' |3 e. Y" P2 L2 [. a
                        return true;                        " \5 q/ P) Y5 l7 Q1 b6 V' g
                }5 T: p0 K8 y' Y2 ]) a& j7 [8 i; ~
               
& q( g: h4 j( [/ r4 v* `) X4 u    } // end of class AuthorisedUsers
- Z* R9 }6 m* t' |* j//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
! i# B! Y% H0 R. p: |5 q' WShanghai - 20077 ]; X3 M& V* i  F& C! X2 i
Assignment 2
1 ^( A. c9 {+ e" u- R' @+ DDeadline 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)( u0 R3 D9 r9 J4 w% E
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./ \  E9 l, D& \5 H4 J6 `, k
The staff must be able to:
$ t6 n9 p# W& ^+ w5 K Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
- v0 h& d/ P( B  C) D5 @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.
9 o  ]+ N* f0 }9 j( j9 @8 _ The interface should provide a menu so that the staff can:
* \7 ^( o7 K: U* z6 Ca) Enter the names of the two Java program files to be compared
; X9 M! E8 A; _; T$ Y: K- j9 V For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
4 m2 }. t6 i; \% B; a8 O0 B2 K** 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).
  D& W# ?9 A4 t& D( qBSA104 Business Programming – 2007: Assignment 2
9 q& O, i: m& d& @2 XPage 2 of 5* ?& e' h8 ]" o) T
b) Print out to the screen all the lines of code that are the same4 y* M5 E& o) x' r
 Include the name of the file and the line number of the code being printed for each of the two files1 G1 y& o& Y& i6 E7 k) ^( N8 I) J
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared& Q1 m  C9 D. B$ t
 the name, username and department of the user
* ]3 V, E+ C! \4 w the statistics of the comparison
7 {2 e2 ]! _- p1 |; D9 V- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
/ I6 [4 Z5 A$ K7 Y the recommendation for further checking
" r- b8 M. a- V+ c1 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
1 f7 d$ o9 N( T the names of the two files compared
! ^7 @' l3 I5 d, E/ w! Fd) Leave the program (exit)3 j4 m) P. i' C
The ProgramCompare class: (Total maximum 20 marks available)
8 h5 z: v) L+ y0 v$ T7 x2. 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): Y! h- r: q1 P9 [1 Z/ F( o! a
a) provide an error message if the files are not found or there is a problem opening them7 {6 b* @* N1 F3 `
b) compare each line of code
# |9 @+ L1 |  S8 t- N  _! i+ \1 Tc) print out the lines that are the same, F8 W6 r7 ?- f, Z4 r  E
d) count the number of lines compared / lines the same: p% U- z0 }* g7 ]! W# S& Q
The AuthorisedUsers class: (Total maximum 20 marks available)
; `8 q4 d# K* T5 f2 v, x3. 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)
. k: L. z( R/ z* ]. U! L4. Provide methods to:
0 F1 a/ t8 }* B7 aa) 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
. {: ?* g! m1 m1 ~9 C4 M0 [b) return the name of the authorised user
/ t% S0 U$ n0 w0 o8 `' }1 \c) return the name of the department of the authorised user6 e) g1 p4 j5 X6 n+ x" k9 ]
Individual Data (Maximum 20 marks available)6 i8 y" y' W) X; x4 S
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.
5 B2 A( \1 u: ?* R! W8 E5 fDocumentation (Maximum 10 marks available)
! G' k* L; m, F. W# ]- y6. 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.+ F* T+ ]. N3 y2 O, z
BSA104 Business Programming – 2007: Assignment 2
2 C6 A* X% h, `# |8 H! pPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了2 D$ g: [* C5 Y, f
不过你要翻JAVA的类库说明。你有下载没有?
0 u* k$ H- h& ^+ |( C查询关于对比的函数。貌似关键字是contrast,还有compare
& w9 v+ s. X, r8 Z5 \& ]# E
  v1 c. e" \0 R9 Z6 H- t  }2 Q[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -+ ~8 b" h+ x6 \0 B' i8 z7 e
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
3 e0 p/ t( O0 L  V9 W6 w可以下载到的 是 jdk-1_X_0-doc+ L' F5 Y7 u% [. ?" t
/ N" B2 G9 X3 f; }5 [# P7 r& i9 b
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-23 05:51

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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