找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1364|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急% F& x7 k6 Z. r" ~ . X! k$ U. { X* }
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
4 F: Z( V' S5 Z1 U7 \" J3 s8 W//  ProgramCompare.java         Provided by: DRS
  z/ x: A: F. P//3 R7 l& r, A5 @' C% ]8 F! J. U
//  Program shell for Assignment 2
: u# R+ {; K$ ^1 Y. n//
4 o% u0 m* U; [+ D//  Compares two text files line by line/ k8 c  `5 z4 @  @. m5 c
//*********************************************************************' H6 u! y; _5 Y/ f

/ {4 E; v! F2 t+ P) Z! N& Gimport java.io.*;' U6 F/ ~$ \3 H& E/ u& u

9 V: R0 B1 K7 T; z* Rpublic class ProgramCompare4 i" I# V' T# ^
{% Y: I% C1 Q) l0 c/ S: p! ~& x
        //-----------------------------------------------------------------6 y4 T# f2 m( A, x, E2 c
        // Constructor
+ F8 s6 R: n$ ?$ D3 ~        //-----------------------------------------------------------------
1 D# F0 r9 A! g5 }) r3 u        public ProgramCompare()* G, M9 p* o3 s/ ^7 `8 W5 O2 q$ K
        {$ u$ t6 j- Q6 [) I
        }! K9 w( s( u2 j0 f5 Y" D
! ?( k) v! g% Y; h4 x# X
        //-----------------------------------------------------------------
; |) ^4 L, m6 [7 t" l+ |        // Method for testing that class has been reached
$ ~4 [8 |) ~$ [; \* F/ l        //-----------------------------------------------------------------       
- D  ^7 S4 k: T6 ~8 O6 j! {' a% O
8 Z- Z! ?* l+ V  N  Q- R' ?, a0 \) j- F        public boolean ProgramCompareReached()        
) j& ?. `- G" h        {, M& W9 G; n  t8 @# F
      try " T+ @# |! g& J' }  t
   {         , s3 \& U' y8 c) c
                        . B7 U! U8 L5 K" R- @9 O  S1 R
                //********************************************************************) N4 \; o. D: q! x$ x
                // Try-Catch Statement is used to handle exceptions - such as file not found
; P8 _7 ?9 ]6 `9 P                // Reading the files will need to be placed inside a Try-Catch - just like this one!
# v2 \) ?0 c* u  [/ m" i4 C. ^4 q                // For more information see page 534 of the textbook3 E5 @& [. B1 j
                //********************************************************************6 F5 H3 r" W& y- r" X
                     + W! ]6 g) J5 }" `" S6 h
        }: X. I5 {! C' x! \! Y1 h  [$ Y
             catch (Exception ex) // Exception caught here and message displayed to the screen % y, |+ N6 f) c' @( I
          {
/ |0 g& i; o. x# Y5 l# `/ S" f                    ex.printStackTrace (System.err);! q- }  t- p, E2 v# x# ^9 s
           System.out.println ("Error message goes here"); // Replace this error message with your own         
: [# |! c3 S( u5 j5 w2 n& A- _        }) d9 V$ P; H* |; I* ]+ b
                return true;$ C4 p5 C) y; ?
        }
; b3 h& W) k( [# h* J7 u: q8 w3 w8 S4 u' G) k3 e
} // end of class ProgramCompare
# _- G$ Z, o! f3 Y
% c7 Z' |7 U" U9 N8 ?% a" X//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************; J4 U% L/ {& d0 C# z& P
//  ProgramCompareMenu.java    Provided by: DRS
" z, w% A' e- F& {//  K0 f( R- s) Q7 S; o' o+ I
//  Calls AuthorisedUsers.java and ProgramCompare.java) m; s8 c6 b2 D) v* @
//
: Y9 z' N2 U4 k//  Driver shell for Assignment 2.* W$ }! D& |, ~$ U
//********************************************************************' \; @! t7 N7 G/ |+ X2 g
; ?6 e( `3 ?- Q) u+ M
class ProgramCompareMenu
/ L) }! I/ t2 X4 G' t+ ~{  X7 a3 n1 p7 Q8 U: }
    public static void main (String[] args)
7 Y% Q4 g! t7 B. `9 C4 q& U            {
7 H7 d' p1 M* M                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable* ?7 H" \, X# l5 l
                ProgramCompare reached1 = new ProgramCompare(); & ~7 Y( C# t7 n( {9 B6 A
                AuthorisedUsers reached2 = new AuthorisedUsers();       
9 S$ l* \! g+ G8 U" R5 }9 V                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());; k# o% g/ Y7 b  O" U) B
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        6 h' w8 d2 f! \1 A& g$ }, t
        }
" C2 h0 n, P) G0 v}// end of class ProgramCompareMenu7 Q) l$ }! B  K" ~( `& E  u) C

1 y. `4 D, @* ^! Z8 _//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
: [# |2 v0 a" F$ T; O9 T8 s//          AuthorisedUsers.java          Provided by: DRS' M2 t7 {5 i2 c8 `
//                6 S3 y& H3 v1 U: G4 k2 k
//         Program shell for Assignment 2
, J; h1 ]6 Q3 d//. c7 m3 w1 y' E0 @8 m
//         Represents facts about an AuthorisedUser. t! \. O# a8 [9 O3 P% m! K
//********************************************************************3 ~  c/ b9 ]: M# ]
! T6 @) A1 v1 C% _+ X
public class AuthorisedUsers! o! O  f! f$ }2 x- g- O/ k
    {6 }( g$ I$ \; `: t
- N" ~! V- N$ T' V0 o
        //-----------------------------------------------------------------
- {3 ?7 w) O* R& U) u- H1 F        // Constructor5 v: c$ |4 V! O% t6 ]$ j* c6 i
        //-----------------------------------------------------------------
' Q3 c, t' U6 u1 z9 j0 j/ ~% O: U% z4 k! P5 I0 D
        public AuthorisedUsers()
: Q  p* M1 n# n) v                {
& z: z9 ~4 W+ o# U/ q: b                }/ A# m& L: T# M1 F
0 V8 w  M/ u. [5 X1 \2 Q
        //-----------------------------------------------------------------
" c1 _6 V* b" T! h6 m" d        // Method for testing that class has been reached
- q. d* l6 x+ W" m8 U        //-----------------------------------------------------------------        , G6 L8 V! G+ j9 ~# S! n+ w
        public boolean AuthorisedUsersReached()6 K( g! z( w3 e* g$ Y2 q# f
                {
0 [& s3 J$ C4 G                        return true;                       
# G) D, V3 U9 J' A! a& v  O                }" [, F  I! D( ?0 z( h) a
               
7 d% J9 M4 t0 d1 A. b    } // end of class AuthorisedUsers  g' s7 R& d* Y
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
( }4 _5 `; I2 c! c& E* Z( {+ }! iShanghai - 20072 F% D% G$ f; z/ E5 K- C- q5 c
Assignment 2
5 ^) c! [% N( Q; f1 R( d( ^4 y  f) oDeadline 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)
. p6 H7 l( l: S" K1. 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.
5 d' q# l. m( X; lThe staff must be able to:
+ v, q* b" b7 J, a3 W" @ Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
/ H& Z0 m- ?2 `! p1. 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.
" F1 \, W) L- R* d The interface should provide a menu so that the staff can:
( j0 O& b  r% b1 F& a0 L' aa) Enter the names of the two Java program files to be compared4 y' U* a  n/ c! S
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
: v! ]& I/ f& q2 \* [7 X0 r6 v! ^) e** 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).
" |+ d8 S( r: |& r0 Y' v) L) pBSA104 Business Programming – 2007: Assignment 2! A, M+ M5 M$ j, [8 ^5 Q
Page 2 of 5& p" z/ |# F; B" s+ ]+ N3 Z
b) Print out to the screen all the lines of code that are the same. @1 f: F8 ^; y) u+ @
 Include the name of the file and the line number of the code being printed for each of the two files+ U( N+ `6 [4 y+ E6 f) u  w2 M7 n
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
9 J1 ?# h" j8 d) c3 n the name, username and department of the user8 o8 [, X+ k6 |  t
 the statistics of the comparison
! R+ v7 ]; D! ?' ^: @& T4 _3 W- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
0 Q/ y4 r% |! U2 @  H the recommendation for further checking4 r" Y0 M+ }& 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" p, R) Z7 G: }* S& X: B
 the names of the two files compared
1 Q# Y) ?" I$ z0 A7 xd) Leave the program (exit)
( R  D/ a4 M5 A+ A9 V2 JThe ProgramCompare class: (Total maximum 20 marks available)
+ V1 q3 @$ D' \+ H. g0 ~8 @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)
2 s3 i7 d' P1 C$ p/ U; \a) provide an error message if the files are not found or there is a problem opening them% Q- ~& O3 j% ]
b) compare each line of code
$ ^1 Q0 {9 e+ p9 mc) print out the lines that are the same0 g2 ^; Z/ J& y8 ]- F
d) count the number of lines compared / lines the same  i3 y% g' ~* [* L8 P; }5 k
The AuthorisedUsers class: (Total maximum 20 marks available)* B; s. l5 d# r9 _
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)1 J# m" B+ W1 v) M) I
4. Provide methods to:
' B4 }& o9 E- g- H; ]9 a: ga) 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& @' ]6 s; M: m3 Sb) return the name of the authorised user
- E  g1 C& k4 `c) return the name of the department of the authorised user
) h2 e: C% `) Y& Y/ HIndividual Data (Maximum 20 marks available)
! z7 Z, q3 L4 p7 j5. 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.9 W7 |+ s* Q; g- e  w
Documentation (Maximum 10 marks available)! |/ T! r" F+ K% H5 o5 C# P- s
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.
3 I# \3 e* |) lBSA104 Business Programming – 2007: Assignment 2" E% F9 Q$ ^! O$ @* j/ t
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
6 D* Q6 M0 @- r: X- d不过你要翻JAVA的类库说明。你有下载没有?- @: K) u, T5 E' i# U
查询关于对比的函数。貌似关键字是contrast,还有compare
  H+ h- K0 G3 p2 n. l+ c1 k) o4 |; M
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -$ r2 m* t0 D0 P5 E( A6 ~
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
8 |! c7 R# A! F( I3 x2 O可以下载到的 是 jdk-1_X_0-doc- W1 Z4 V9 P- f' Y6 T
' l. d. H: V; v
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-8 00:42

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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