找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1285|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 , w" X: H0 l3 A# T2 X/ ~$ I A+ ?: o- W" h( T& v7 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 | 显示全部楼层
//*********************************************************************( s; A4 r. U8 X' T' f( r. F1 `1 c
//  ProgramCompare.java         Provided by: DRS
% D. o9 G- ]% @' B//
: v4 i8 b$ |; `6 W//  Program shell for Assignment 2
$ b. ^# \) }  ]//
  O; L+ U2 T! i//  Compares two text files line by line) {& j4 Y. P  M1 y2 ]' M
//*********************************************************************- C. f$ {$ q0 ]- C+ _4 L3 z) l
5 Z* i5 `! q# s6 c1 }7 M- ?, Z
import java.io.*;
: k- S: E- K3 {) i) B, M, t0 o* U8 `, m9 ]/ c
public class ProgramCompare- Y) ~- d% g8 b  M7 s) r& q2 |) n
{3 f+ s( K* M+ U- [3 W: i' E* \
        //-----------------------------------------------------------------. q4 k' {4 z3 o" z
        // Constructor( o- Q, e( ^1 P$ [6 H+ j- A. [4 D
        //-----------------------------------------------------------------
0 Y2 y$ X% q# C        public ProgramCompare()
0 W- T+ a0 j$ E. ^- m$ V        {* @3 N: a$ k& {3 j4 Q! U
        }
8 r- W. v3 H; T5 |# p1 ]7 c- w% S2 m4 d
        //-----------------------------------------------------------------
. ^% E6 g% O2 P: f        // Method for testing that class has been reached
  r2 q. E. j( E. N/ h4 b( E        //-----------------------------------------------------------------       
; i5 S, D: e* P; ^
: I, S  l* O5 z& G# {        public boolean ProgramCompareReached()        
! S5 @# A! `* h  R" b- r        {
( H  x. A6 {% v6 @; O      try
- n5 s+ s% b; q9 I) H6 a   {        
+ Y& f7 z6 v2 U( _' r                       
3 s, v4 ^6 n4 y3 M3 W& L, M* \                //********************************************************************
7 E' x0 R9 i! ?                // Try-Catch Statement is used to handle exceptions - such as file not found & z3 i2 b9 p  j7 w
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
9 v! W( C0 D0 q7 E                // For more information see page 534 of the textbook  @% G* P; p% m1 ]) {
                //********************************************************************
& C1 p( _! i& n  ]2 l" k                     & ?* j: t, l( f+ Y* A7 f
        }
- V) A) U, s; ^, k- _             catch (Exception ex) // Exception caught here and message displayed to the screen
% W& g+ k! {6 `( X          {
* ~5 s  Y/ [8 A$ n                    ex.printStackTrace (System.err);  ^. n" S$ e9 y+ M
           System.out.println ("Error message goes here"); // Replace this error message with your own          / K6 n6 ]2 l: [
        }$ f: Q' `( B' |* Z2 u5 p; C" b
                return true;, ?. F6 I" I: q! @
        }
1 I; ~8 G+ J8 Q* j7 o: q2 q- x+ H2 F4 B- `2 g
} // end of class ProgramCompare2 G& q% h- r' c

/ g; n7 l/ T4 O, n/ D! f# o//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
* w( x! a  Y5 L: q$ u; y//  ProgramCompareMenu.java    Provided by: DRS! S: P4 m. `' d5 D% l+ h
//
8 G  f* s+ w; [+ a+ \, ]//  Calls AuthorisedUsers.java and ProgramCompare.java
3 O1 ], T1 L1 L# w$ X4 K, P/ _//  i7 e% E% _7 G
//  Driver shell for Assignment 2.; @3 x4 K, D) |5 f$ H. [+ V
//********************************************************************
9 f+ f% d  p7 Q2 B" e& [* L9 m' \  h3 g" Y8 W# w& h6 k
class ProgramCompareMenu
1 i: k) v. A: t, w5 ]9 c) C{' a% i& |+ @# q3 _  R" r/ t
    public static void main (String[] args)
  R5 j& p1 o0 Z6 ~. ~( \6 m2 e            {
! r- L" h& c+ I0 A, W% x2 T* z                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
, ~! M8 n4 q/ q0 X. E; c                ProgramCompare reached1 = new ProgramCompare(); & ^& C: U6 E3 w! F, n- `! `" _
                AuthorisedUsers reached2 = new AuthorisedUsers();        - x( E$ c5 w0 }
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());( H( e; a* ?2 |! v) c3 h% C" c! ^
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        2 Q  m3 X$ p9 K7 y7 e  V9 ^2 I
        }4 M5 j4 e; v2 X: ^" j$ h- m# Z
}// end of class ProgramCompareMenu
) _5 S( _, U% v- ]  ^0 h( \4 [/ J' p
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
9 q5 t! {4 t  r5 K5 I( m//          AuthorisedUsers.java          Provided by: DRS9 w/ S  F1 A, ~' l
//               
: m& D. g" T/ m8 t! Q% x1 M//         Program shell for Assignment 2
' g5 Z* ]. E& E3 @' z; k! N$ o' A# Q8 V% ~//  B6 H% Z- s9 t
//         Represents facts about an AuthorisedUser1 K/ G4 L) {$ |( \, c6 |
//********************************************************************8 t8 M  d3 U8 }/ ~

! i( w) O6 S$ Y7 J: xpublic class AuthorisedUsers+ a1 k1 t" ?7 }7 ~7 y
    {
; b# c8 r: }  J6 {9 |7 G3 M# f2 L. }+ I
        //-----------------------------------------------------------------2 W4 v3 h* K! u! Q( i
        // Constructor
; b& U' ^+ N% e6 M; E& \) y        //-----------------------------------------------------------------
! Q* O# {  q2 `
5 w5 V1 X2 z( [  @8 `        public AuthorisedUsers()8 M( ~6 O1 W; e% z9 i8 h
                {& m9 d# L6 d# q3 w
                }
/ v, J' S3 L6 g* j1 A% e+ I; ^4 C+ D% @( A2 G6 H
        //-----------------------------------------------------------------
4 [& W2 {9 \4 D; A        // Method for testing that class has been reached
% h; ^" o7 l1 S8 X' Y& l        //-----------------------------------------------------------------       
  l4 R% T7 k4 s/ f2 B. u  v        public boolean AuthorisedUsersReached()1 h5 U! w' B# @8 r
                {
/ o5 U0 v/ E6 t. u                        return true;                       
! I" n2 i: }) k3 N: C* B( g, g                }
# d6 ?2 c8 x, \, V  l               
4 U" N* J+ n- r1 _2 C. P6 ]    } // end of class AuthorisedUsers6 P' B0 Q1 @5 S, W9 p  j( ]
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
; X/ a/ k1 B% uShanghai - 2007  q+ `7 C! T# i3 R2 y2 }
Assignment 2; S+ h- s3 V) u. r4 m0 y" g& r
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)
4 c) j, Q  D' ^. F' g1. 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.
% ?  D4 h- k* j' W- C6 J: f, UThe staff must be able to:
8 J  E  G& J6 {% J0 F! P; | Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
8 T: ?$ S3 O* k0 V# B% N( J1. 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.
1 h0 d9 U! o5 E+ n2 V2 n. y' | The interface should provide a menu so that the staff can:
: n1 Q8 E( g) x( z( q$ \5 Q% f8 k! fa) Enter the names of the two Java program files to be compared
$ }+ _) P* e: l: F* b7 D For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
9 E- C1 K9 [# R; I** 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).
' h. N# A( Y4 y+ E" pBSA104 Business Programming – 2007: Assignment 2
' Y  w$ e0 o5 F5 \0 M  A4 cPage 2 of 5# u( _" B* a9 j: x9 @; G0 o
b) Print out to the screen all the lines of code that are the same7 [' I3 P7 U. [) P+ b# y7 K/ T
 Include the name of the file and the line number of the code being printed for each of the two files
: ]/ v; ~9 _. q8 n; v; w4 l2 nc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
3 O" R1 r% |$ p the name, username and department of the user
. M1 G3 P2 ~3 X( E1 F9 M, C the statistics of the comparison+ J; N5 D& J/ f3 }% A
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different& [& q0 f+ g- c7 j3 K& b) z/ r
 the recommendation for further checking
+ K; P+ l2 G- p& P  z% }- 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% S, u& w' z( O# |+ k: w7 f
 the names of the two files compared
1 C3 S# C8 q) rd) Leave the program (exit)
* Q8 U" v" |7 V4 A* n% [1 q* EThe ProgramCompare class: (Total maximum 20 marks available)
! m# w2 N5 G6 H1 V$ p) 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 P5 ^; }7 z6 I1 X. |* T) Y, `a) provide an error message if the files are not found or there is a problem opening them
: Q: X9 w. X. @" ]( I" ]; l0 [b) compare each line of code
) E7 _1 C2 R7 z" e& M/ r8 ac) print out the lines that are the same
% a* m8 }, h4 t. r' Gd) count the number of lines compared / lines the same. ?6 \* O5 l: C& i* D/ z, H0 P
The AuthorisedUsers class: (Total maximum 20 marks available)
! O. s3 b& e4 N  ~2 {2 t3. 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); `# I8 g/ d: d: @6 ]$ c
4. Provide methods to:* n! n( g  R& i* u1 ^6 A
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
! S8 A& x! J( A1 Z" jb) return the name of the authorised user2 M& Y/ S; M2 C, j5 q, ^
c) return the name of the department of the authorised user
% M. I& L7 v7 EIndividual Data (Maximum 20 marks available)' ?+ f5 l2 n3 V' R7 J. Y
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.
( o( @, P5 C# W- Z+ v# uDocumentation (Maximum 10 marks available)% I; e$ h" n# f, {: O/ g/ `
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.
  a3 D/ R3 T0 DBSA104 Business Programming – 2007: Assignment 2
2 f* ~$ M7 [$ ~$ NPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了; s7 g' G/ v5 ]
不过你要翻JAVA的类库说明。你有下载没有?7 l# H# }4 T9 V8 w9 b5 ~/ j/ H
查询关于对比的函数。貌似关键字是contrast,还有compare+ r1 h7 U3 d, Z  Y' P
. H) R3 z  D; y* b! a$ L
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
/ M0 y2 [# D' d+ ~. @# _2 _痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。. R3 e, u  V8 P# ?! [' t8 Y
可以下载到的 是 jdk-1_X_0-doc
( s- w" a$ Z3 U; k9 z# [
1 e' v( {, w# N8 r' n4 o$ L[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-15 08:38

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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