找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1236|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急7 R: e4 Y7 j+ m7 F% w9 \ / a* M! w: b( @% s {2 z: @' Y
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************% N; ^* k% z5 x& l
//  ProgramCompare.java         Provided by: DRS
) `# V7 y9 K& `, H: M//
% e# i* v2 h7 R//  Program shell for Assignment 2
$ L/ ~2 s2 n2 y# b8 ^; C: Z2 y//
$ |; a2 K3 J% q* T# I4 _  g2 `//  Compares two text files line by line2 Z0 y- c2 y4 C2 E  b; X' W' s
//*********************************************************************6 t3 a+ |$ i: K# G0 V. {
  s5 N3 [. Q* }7 ~/ u" k
import java.io.*;& R1 _+ k5 B. s

. G" J" l- J& Y1 E' N, hpublic class ProgramCompare
6 B2 \7 y. \% E9 y" Q{
& \7 a. V* V9 R8 I+ D        //-----------------------------------------------------------------! G/ _( D/ b5 d
        // Constructor
! ^8 l! R* q7 d) [( B9 D7 K        //-----------------------------------------------------------------) q& ], W& I% r2 O$ [7 l3 G) V
        public ProgramCompare()
- m9 {; e( J0 x! Y2 n- W( H5 `" k        {' g: Q( l7 I: e- k0 h/ _
        }
: f2 l3 G# i3 V/ r$ m$ H0 t
7 b- _; A4 |; U        //-----------------------------------------------------------------
2 ~- O* ^  }, v: ^8 X        // Method for testing that class has been reached
! m& ^) E! E( T, H; s# x+ i5 d        //-----------------------------------------------------------------        " L4 M/ u/ Q# A$ G  f8 u2 H% g5 B
1 r! i. d# g# d/ w5 x) b" _0 i4 P% H
        public boolean ProgramCompareReached()        
& q) l. `4 d# d& T0 v8 l+ L5 M        {/ Z  @4 Y1 G' a) a* J3 k
      try 7 Q. @0 M% z3 c. W5 H
   {         # V  @5 b! m& u: T7 x4 m  t/ t
                       
' f! U3 E: I4 x( |$ x- R                //********************************************************************) d. Z' l* @- g/ n$ C7 z5 l% w
                // Try-Catch Statement is used to handle exceptions - such as file not found
# H# Y  I) \: H6 ]- ]                // Reading the files will need to be placed inside a Try-Catch - just like this one!
4 e5 V% s  L- u- v2 g) J5 u                // For more information see page 534 of the textbook+ D0 R, G$ v  V8 D) \
                //********************************************************************: y8 T, i1 M/ x$ O: D$ n  t
                     0 A0 w" W/ X! o2 n, N! ~
        }
4 |5 ^( d3 W! i% s" q! y* O( ^. ]1 h             catch (Exception ex) // Exception caught here and message displayed to the screen ! p6 E+ [# L9 \/ ~" x
          {
+ t# S2 v2 O3 d' I' ?                    ex.printStackTrace (System.err);
+ ?4 j1 ?4 J5 D9 G+ q' _           System.out.println ("Error message goes here"); // Replace this error message with your own         
% g) |, L, ~7 Z2 P; L1 o        }3 P6 e; b- n; F8 M# }
                return true;
  x0 R/ Z+ G/ _* ?1 m- |+ c9 _        }
; Y7 F: d( K+ H0 B) |8 F
2 A% v1 I) t6 I5 A} // end of class ProgramCompare
& L& {8 [2 C  Q2 Q/ E7 L; v% Y! K7 ]& A, e8 p+ X) u0 `* i
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************# i3 ]7 V. E; @: U* r" r! @* y
//  ProgramCompareMenu.java    Provided by: DRS
+ v2 B# F" u6 O+ X: H! e//
" V0 O% P% w) q' J) n//  Calls AuthorisedUsers.java and ProgramCompare.java
8 b  \+ `0 X% C3 D8 o' n//: {6 P9 @. }* p5 e* J* A& s
//  Driver shell for Assignment 2.
: f3 O4 x: i. Z4 V$ }  D8 f//********************************************************************
( q8 E4 C. `) u
* ~" P5 h* n( h% K- K) Oclass ProgramCompareMenu( ~, m8 e! ^1 ?5 b3 t
{
4 p6 `" U$ m. j. I    public static void main (String[] args)) P$ ?5 X# ]$ L( p! n6 t  J
            {
- A) e1 G1 y* ?4 p                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable- E( g" i! ~" i$ Z( V& Y
                ProgramCompare reached1 = new ProgramCompare(); 5 H$ ^# T5 \+ d9 H
                AuthorisedUsers reached2 = new AuthorisedUsers();        4 h( g! Q! h, j
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
$ [, G% v0 S) F. q# L                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ) p! k4 _4 {2 V7 }9 r0 j
        }
+ c/ U2 ~) g: f6 O# O; b}// end of class ProgramCompareMenu
5 |9 }. I  U2 f4 N+ Z; f- R% A: i) @$ E
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
; L7 d( P! R- X2 |. u//          AuthorisedUsers.java          Provided by: DRS7 Z2 g9 U( t1 D2 ?: G$ S0 q/ p8 E& x. r
//               
4 N0 |3 a' {9 |' m; L5 c  }//         Program shell for Assignment 2
  r( o+ a/ O1 {  |$ {$ A//. j5 M+ C* B# m3 s
//         Represents facts about an AuthorisedUser; p9 p% P* a1 }. e7 e$ R1 i  P
//********************************************************************
4 y* S* b. B+ O% P2 x% n& \0 E8 x8 Y$ Y
public class AuthorisedUsers
& g: g* J6 b1 Q0 j    {' t; E$ h$ D  N
" n* }/ u- c7 x) A! s4 h2 L
        //-----------------------------------------------------------------
4 P' I$ B6 m3 E% X  S2 n# X4 q/ o        // Constructor3 M6 `# K" o5 |5 F' W6 o
        //-----------------------------------------------------------------
+ |6 ~1 F& p4 w
  W) P. w9 D9 m! e$ P* h        public AuthorisedUsers()
# n, [4 M1 j; j4 V" Q2 J) O; A                {
  e. A* M6 ]8 ?* ~, t" |7 {+ B                }
/ G9 |/ G* b8 ]/ [1 o& v+ E6 ]: E# v( t- ?' u1 S' x6 V/ ]
        //-----------------------------------------------------------------
) |1 M& w7 l+ w5 k0 O, t        // Method for testing that class has been reached
: Y6 U9 H1 [( A2 |% C+ U$ I" c        //-----------------------------------------------------------------        7 j; y. p+ L, Z8 ~; c
        public boolean AuthorisedUsersReached()
7 m/ Z& O$ n4 q1 a' J                {
) I$ p% R& d9 v. T8 ^' d3 k. v                        return true;                       
, Y2 ~- n; r$ B* g  u# Z                }9 H: k: t0 n* }, q
                8 X0 B! w# R, M9 R8 S- H/ ?  z
    } // end of class AuthorisedUsers/ {/ n( O* O6 K$ i; g# Y, F# y
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
/ O; B' J! I  V& u8 q/ kShanghai - 2007$ \9 N. \6 C& a% v  [% c1 N
Assignment 2: A7 F. d/ Y8 y: ^; d2 \& 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)
3 e$ U3 q+ B8 i7 ]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.$ d* M) q% g- @
The staff must be able to:& o/ m- ~; ]) h
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.7 {( i% F; k6 d. B
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.
3 Y9 {3 K6 T7 f% P7 n5 ^ The interface should provide a menu so that the staff can:* ?, l1 V# e% w3 ?" D7 ^1 ~
a) Enter the names of the two Java program files to be compared
* v# w, a; _5 V% x. _# Z+ ^ For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
- U  s+ u0 P8 l* U** 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).
& [( O1 G% A+ qBSA104 Business Programming – 2007: Assignment 2
/ ~- n3 Z  G* m0 ?+ `Page 2 of 52 u5 `+ _. O* E9 I) `+ x
b) Print out to the screen all the lines of code that are the same
  l6 B& j& R  b9 ?  {2 o" L Include the name of the file and the line number of the code being printed for each of the two files  ]( Z2 A+ k/ R- F3 S* p8 h
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared  O' E! i4 E( e, X1 `
 the name, username and department of the user
6 n" w$ `. O8 [% \ the statistics of the comparison9 \3 b7 |) C: w2 l8 V: E; L
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
/ F$ a* E" {! i, G the recommendation for further checking, U/ @& P5 w4 [+ n9 W+ Y' ^% C
- 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
) H8 N' j3 }2 l4 m. V the names of the two files compared) X- }& }2 c, L- d) e
d) Leave the program (exit)
: V. `. V( d5 @The ProgramCompare class: (Total maximum 20 marks available)
5 O9 j, E: ^; h2. 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)9 E1 p# T0 |7 x4 O2 C
a) provide an error message if the files are not found or there is a problem opening them5 ]  Q' ~5 M7 y4 e# m8 e
b) compare each line of code2 s$ o. Z# c7 p+ N, Z$ I0 H7 x
c) print out the lines that are the same- Q( A. i# I$ V
d) count the number of lines compared / lines the same  E! J  Z/ ?5 x; G) a
The AuthorisedUsers class: (Total maximum 20 marks available)* z7 T9 r( `0 \: X6 l
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)
. P, a+ g- l0 v, c2 ]+ e4. Provide methods to:5 s0 M/ P) N% J: R
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( A' n4 _! Q& `# I
b) return the name of the authorised user. a$ [% |/ a$ L+ L' `/ [
c) return the name of the department of the authorised user3 T+ i" B" P) _( I4 {. K' h
Individual Data (Maximum 20 marks available)+ I- D, N' S$ T: ?2 U) H
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.
6 x: P' T( R* z0 r0 d0 LDocumentation (Maximum 10 marks available)7 X3 {& l$ k- R+ R; v; J
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.
. z' Y0 j2 A) u9 @$ u; ?( ?BSA104 Business Programming – 2007: Assignment 28 g3 u! M. C5 c8 ]( \6 P1 X
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
7 l; r9 N0 S( ~3 X; f: A; O  M不过你要翻JAVA的类库说明。你有下载没有?$ _0 v6 v4 s/ O8 P0 R4 Q% x0 z
查询关于对比的函数。貌似关键字是contrast,还有compare$ f1 f, L) X3 M+ r( F

; D4 ~/ c: \: k[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -4 F3 p7 \0 o, z8 F# \: q
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
; l& V5 x  A: [5 z9 k5 q1 z0 k可以下载到的 是 jdk-1_X_0-doc# r6 p) s, h) m3 |  c
: u0 e+ B. d" e' C; l% p
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-27 21:56

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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