找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1189|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急6 m& ^9 |0 [5 B+ S& N5 X; N ) P; R9 D: G9 D: F
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
, t5 O3 f. }/ C, N0 ~//  ProgramCompare.java         Provided by: DRS
' K/ g! W2 \1 {% \3 u* [' b//
1 u5 ]; t+ B; z4 k: e//  Program shell for Assignment 2+ Z9 _& `2 f0 _/ [8 Y0 w
//
" ]0 S0 f+ U5 Z( |: X4 B, H! L//  Compares two text files line by line
, i9 c: O+ k+ P1 K4 o, W+ H//*********************************************************************6 I+ r" t9 _( N$ R/ N
6 v# Y9 ~% n4 U5 s* `) C7 _
import java.io.*;
" ~  o7 R3 m' C. B/ H+ u1 H! Z. g1 E$ b7 p" J
public class ProgramCompare( Y8 }& a8 H+ ~& g
{7 Q0 M! z7 ?. [( t; b7 G* z) w
        //-----------------------------------------------------------------
! W; {/ ?, z  C4 A$ q        // Constructor& R5 _% U. S6 Q9 p5 B
        //-----------------------------------------------------------------
: l2 o" F# Z$ E$ F/ _# t6 B$ K        public ProgramCompare()5 v: h* M( K: v; k3 A, l
        {
# [) z( e3 J) d1 i% P        }
6 L  E* c6 N2 v! W# K9 k! ^
: A0 q! @# K' D4 F        //-----------------------------------------------------------------! C) k% Q. G; @  Q
        // Method for testing that class has been reached
# n; a9 c; t: C# }: e- l/ [        //-----------------------------------------------------------------        1 ~& ^" [( j! V' e: A. c( a
6 q( t5 @4 p( z7 B& v+ E* K
        public boolean ProgramCompareReached()        
& U5 s; P$ }8 D( j0 I( g/ Y' O        {; ?. ]/ J, a2 k( w4 a/ S. K8 ]/ E
      try . k( n0 U3 Q0 X# M
   {        
! I& R1 _9 o8 s! g+ F                       
$ @' Q  A( e* B. l/ X# z4 ~. _! A                //********************************************************************
: J! }3 b* ]# Q. t$ y) X                // Try-Catch Statement is used to handle exceptions - such as file not found 0 V$ C% V2 t4 c1 y
                // Reading the files will need to be placed inside a Try-Catch - just like this one!* g# v6 I) Z1 l. V6 G' t
                // For more information see page 534 of the textbook# {" M% H, T& `
                //********************************************************************/ Y# j5 s8 g7 D7 Q2 \; O5 j
                     8 w2 a$ ^' x8 R6 S
        }
0 U2 o6 k  w/ u  V  [: @- e0 O             catch (Exception ex) // Exception caught here and message displayed to the screen ( ^+ o7 F* G8 B$ T4 M- c- i  A
          {3 B$ \8 o  g5 H4 b- P$ L
                    ex.printStackTrace (System.err);
9 d5 {( i! b' L) z1 V4 E! Q           System.out.println ("Error message goes here"); // Replace this error message with your own          $ Q# V- S0 _, {' [
        }
$ V% m( k) t; w, ]                return true;
/ C" B3 J$ V' o7 J7 ?        }4 Y0 F# Z3 n, l8 [9 i6 a- L- k

2 K& I5 v6 _* Z- a" a- Z} // end of class ProgramCompare
. G! }) S, C5 @8 B2 i& N& d/ e1 z# |7 C0 o/ A* g
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
) Q3 Q0 Y! k( y$ X* o' M//  ProgramCompareMenu.java    Provided by: DRS
) h/ J' S6 E8 Z( h* f, p3 ~% |1 {//
, Y0 ^" d+ N9 A0 c; v//  Calls AuthorisedUsers.java and ProgramCompare.java# j. E( p# n& V( O% C- T
//2 f+ r8 c9 O: z) z
//  Driver shell for Assignment 2.
- B4 Q& d$ I8 ?5 a, C; l( L7 y//********************************************************************& r* B7 I( R9 C+ E

) e+ @, @$ c) B/ c/ Jclass ProgramCompareMenu! z% J* ~# n% }8 m; L+ B
{
. F& n0 r5 c9 `( b    public static void main (String[] args)
& O' U' r% J; |1 m: B            {
' s/ @0 t6 j1 c  R' i  v2 D                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
. L1 u0 H- b8 D3 A$ E                ProgramCompare reached1 = new ProgramCompare();
6 {; h- l+ J! _. u1 H                AuthorisedUsers reached2 = new AuthorisedUsers();        0 l' H' K" b" _. q* a4 d
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
+ J7 U, X- O8 v) p                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ; u8 C, `  H, g
        }
; U$ i1 _5 H5 x7 D$ C}// end of class ProgramCompareMenu2 z4 Q: p  J' t
" R6 `) m) N; _  }2 S4 |
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
1 l: p$ H- s. N+ P& p4 o: H//          AuthorisedUsers.java          Provided by: DRS8 u' [# I" {* m
//                # K7 d* ~8 o; y1 T8 a
//         Program shell for Assignment 2$ v7 Q" B: N9 b/ g; `/ Z( c. p
//4 v9 s8 \+ \5 n2 {/ j5 _
//         Represents facts about an AuthorisedUser& F) C: U1 I1 e7 z3 c! a7 I
//********************************************************************
( [# U: {; }) {9 P; S3 [3 u  R/ X8 ^
public class AuthorisedUsers
# U) P6 I0 P, G7 l    {! q7 }6 ?- h/ L; v

' o* ?$ g6 D1 H- q/ H' L/ v1 y        //-----------------------------------------------------------------
3 H; G$ W& V7 w& V3 ~) z% W! F        // Constructor
5 t' Q+ |9 E0 X$ a  K        //-----------------------------------------------------------------% H* b7 e0 h4 Q0 _) K

. l+ M2 d: J) [% O        public AuthorisedUsers()  ~4 b" {) _- e; h
                {
; p; Z# J1 F7 [                }
, t8 h  Q* }! ~0 r6 ^5 R) L. ?; R! l; T
        //-----------------------------------------------------------------, ]+ T' i5 i1 e! y0 G4 q# `
        // Method for testing that class has been reached
; N+ o4 ?* [9 K* }9 E. S3 f" ~+ ^% {        //-----------------------------------------------------------------        $ ?9 x) ^+ {% \6 y; Y
        public boolean AuthorisedUsersReached()
3 [- t1 o+ c8 x2 }4 q                {( h( m/ s  v4 M* f" }( l# a
                        return true;                       
; ]# \$ g, ^8 ^                }5 `9 W/ e8 Y4 {- }' q* R  H9 N
               
) A% e) x) f- h( u' V/ n    } // end of class AuthorisedUsers
5 Z) q1 O. B, {0 n2 \$ A7 H//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming8 b7 _4 K- `1 H  z4 Q& Z, S( V* Y# J
Shanghai - 2007
) b; Q/ N$ n6 M; S& h% uAssignment 2
$ a+ [2 j- {0 q% S6 f1 h# HDeadline 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)* V; W5 e" t, V5 b
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.
) V8 E5 G% X5 F# F* y$ ]The staff must be able to:
9 a8 s9 }$ h3 K Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
$ T  s0 q% N4 z* K& f1. 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.! O, k: b/ J$ Q2 b; u+ k# ~3 O
 The interface should provide a menu so that the staff can:8 E' E+ Z' N2 Q+ V! c
a) Enter the names of the two Java program files to be compared
' y: m" t  c; n% N- R5 B For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
9 j% D7 U1 o- D$ 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)., q: E" W) V  h
BSA104 Business Programming – 2007: Assignment 2. w8 T# }! u# J* }6 R2 l9 B
Page 2 of 5
! s, n/ A! \* bb) Print out to the screen all the lines of code that are the same
# T* I4 T' R4 c0 ~% y5 R2 u Include the name of the file and the line number of the code being printed for each of the two files& Z2 T3 i! @3 O7 o4 `
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared3 i! m" T" g8 Q' j; e
 the name, username and department of the user
9 H0 x& u) H5 i6 k% r the statistics of the comparison
2 V, C- i! z, C5 l2 @- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different* v# _0 v  `- g0 \1 k
 the recommendation for further checking$ ?& H# ^6 b! n- R, t
- 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; k! F6 [. Y7 b) {9 V# e
 the names of the two files compared
; k7 {2 v" i0 F1 n6 ^- Cd) Leave the program (exit)
7 m3 [- _1 }5 A2 V9 Y/ X3 k/ KThe ProgramCompare class: (Total maximum 20 marks available)* d9 V% G1 B9 Z
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). ]. e4 ~) t1 h0 I+ `' W, }
a) provide an error message if the files are not found or there is a problem opening them2 M, _7 I$ i$ k& F) g
b) compare each line of code
$ S( M! p' B4 K) v9 R. T" S9 Wc) print out the lines that are the same
  }, T9 H& o4 r  _d) count the number of lines compared / lines the same1 D; D/ f$ X3 t' f: @$ Y9 Z
The AuthorisedUsers class: (Total maximum 20 marks available)
1 f+ V) A: \& t8 Y( w2 H3. 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)8 ]1 A' i2 _# W
4. Provide methods to:& ?5 Y: n# x3 _* C
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) }6 y% a0 L/ k5 J/ R  Q: S
b) return the name of the authorised user' A! i) `" `. a* H% J9 x
c) return the name of the department of the authorised user6 K- J0 y! C  @. q% x/ b  L
Individual Data (Maximum 20 marks available)0 u5 S; ]' Y2 _- b) z
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./ ~$ u: |; n; \: {/ g: I. ?/ K
Documentation (Maximum 10 marks available)0 ~3 X; E& `! y0 j- Q) E0 L
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.( m" F" v1 \* j9 t
BSA104 Business Programming – 2007: Assignment 20 o7 _$ g# q0 V  I! K9 l
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了5 h3 i( M! |# U1 T7 J
不过你要翻JAVA的类库说明。你有下载没有?
4 [" X4 Z% M, Y2 X( y  |2 P查询关于对比的函数。貌似关键字是contrast,还有compare
: P: {  p  x9 ?7 ]3 x7 b) x0 d+ K+ U2 X8 B: {
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
$ j5 Z$ Z! x/ S, z4 a痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。* y8 }+ c* w/ q; g$ O
可以下载到的 是 jdk-1_X_0-doc4 P9 |; \$ N: l5 g3 t* I
9 U8 q/ D; P( X5 I
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-12 07:56

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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