找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1703|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急. Z- \4 M9 D; V& ~8 D 4 m! G& z% m1 f4 |; R$ `
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
" z" Z) ~! Q  ~4 Y//  ProgramCompare.java         Provided by: DRS
" E4 l: ~7 m" O$ _. b//
6 O" ]) v: s# i3 n  i$ B//  Program shell for Assignment 2
+ V! i  q) a$ @6 S//( X8 q5 `, b6 S* b  l: O/ @5 B
//  Compares two text files line by line( e- l2 Z2 y1 Y  l, ^, f3 H- `
//*********************************************************************  f0 C  C3 M. z# Y% {  |7 m
' S& h% L, l1 \5 E0 M. V. x# Z
import java.io.*;
; S+ v; r) D- e  k) x) M1 [& h7 U1 K% \5 d, f
public class ProgramCompare+ p+ j* p6 l+ S  h
{. p  A. G, s; ?  [
        //-----------------------------------------------------------------; e$ R8 t+ B  C- M9 c. f4 u9 G
        // Constructor
9 F5 N: k4 G( ~        //-----------------------------------------------------------------8 G( ~7 V8 G, o5 f8 B* U0 a
        public ProgramCompare()
3 K* ^% W, f: U6 \% M        {' p9 f. ^2 q' b. A% D. s
        }
8 G3 p3 Z# b8 _
( B; j" t; X: B# ?" B/ I        //-----------------------------------------------------------------
: O8 F% _+ a( h( c        // Method for testing that class has been reached
7 m" V7 ?( K5 \- m# D  v* v- c        //-----------------------------------------------------------------        / Z* g+ u- z. H$ X0 U

& y7 g" `; i/ V: T8 Q        public boolean ProgramCompareReached()         * v# v9 `" T/ m1 g5 D3 @$ R! v
        {& B9 H' }, Z. F7 p3 x# X* L3 ]0 W
      try
6 @8 B+ T9 c' W   {        
, e7 B" P. C! n8 C- j* |/ K                       
2 V2 t0 b: I- D/ h                //********************************************************************
& l9 C$ j7 x& ~; ]4 @                // Try-Catch Statement is used to handle exceptions - such as file not found * ?  h- @: N# [9 w4 y& I& \
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
8 Q* c! `+ \  T' G5 ?                // For more information see page 534 of the textbook. @+ t/ H( I8 y2 B. B3 X
                //********************************************************************" k3 y6 }4 C- p, h. K
                    
  m& O$ G2 `8 j9 m5 F# f        }& T/ ~' }- z6 r6 o6 h
             catch (Exception ex) // Exception caught here and message displayed to the screen ) i, g; a2 K  i# @1 I
          {3 y4 s$ q* Y. F) U2 X
                    ex.printStackTrace (System.err);2 o* @8 O. Z: U1 Q& O
           System.out.println ("Error message goes here"); // Replace this error message with your own          * U/ K; b. f- e; d
        }; t3 k, Z" Z+ h9 k9 M( t
                return true;
' o7 g6 B# `4 s" w+ L  ^6 T        }
  W$ S5 U' g, D$ w& S3 p) i# t; t) q8 X
} // end of class ProgramCompare
: Y8 }, ?* a0 u
8 _5 H0 m2 X, I2 I# M//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************% b) \- y' A+ n" ~3 i) Z
//  ProgramCompareMenu.java    Provided by: DRS
2 I/ q* c6 b# Y8 x, P2 @//$ h+ h! W% T9 ]8 H0 f7 A! }$ Y
//  Calls AuthorisedUsers.java and ProgramCompare.java& k+ o% ^3 f+ n' O, b
//7 w! i5 |" J8 a: W. D
//  Driver shell for Assignment 2.
, o% u! L1 {; `- \1 r+ U//********************************************************************
. Y# k# C% T; [4 m$ F3 G( B) r$ I7 B) k0 ~, W4 I
class ProgramCompareMenu
7 _  k( u  b# _% c+ x9 L4 r2 x{' `5 h+ I4 b  m3 |( V8 a
    public static void main (String[] args)
9 c/ P' V- e0 m& F2 R/ h$ D            {
( ]: x( |& R) U+ e. @- \9 ~  Y                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable: L1 @- m' S" l; L% q
                ProgramCompare reached1 = new ProgramCompare(); 0 w1 T" @; t, O; Y
                AuthorisedUsers reached2 = new AuthorisedUsers();       
% A1 I+ Y# h6 x* f( N9 x# |3 K                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
; R6 g" V3 V7 F; r) w4 P                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        1 ?  s8 L* I! d, @, J+ q9 Q2 ]9 c
        }& ^; D! z! y, H! ~) ?
}// end of class ProgramCompareMenu
8 f1 Y, t2 V5 F% _5 o' q$ O6 ^% ?" y/ R6 z) _4 l3 s) Y
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************5 d! S2 h1 G8 x' m8 `
//          AuthorisedUsers.java          Provided by: DRS
4 }3 U/ A! L, F$ f) P2 x//               
) o3 B! G- Y/ z+ u% G//         Program shell for Assignment 2
# y) O; m. w- {. o8 S8 j" f//( a# W3 _8 M% G1 ~5 z, D
//         Represents facts about an AuthorisedUser& X6 _! }0 j9 Q+ n
//********************************************************************
6 U) n2 y+ N; d! B' s! [2 m: z9 L" T& L* e: B# `
public class AuthorisedUsers
4 f6 j$ |- \8 _2 }5 i3 I4 [    {
- X% Y2 H; u( d  M4 ?& H
/ E% z: J* `  G7 E5 k3 Y/ G        //-----------------------------------------------------------------
0 J/ V' s3 F" b! E3 Y) O9 W        // Constructor* _$ j+ R$ `' v% ~( u- {$ r
        //-----------------------------------------------------------------
6 a2 k# m! W$ y0 x5 G5 G5 v* C- I1 M# _- L' A; \* F4 u7 S, \
        public AuthorisedUsers()9 e/ f1 P/ c) b  t! v
                {
' P; Y5 G- S: {% T; R1 b' g& k  u                }
$ G# R3 }2 Y% b. x/ x9 t4 o- V2 y& E% Q- T
        //-----------------------------------------------------------------$ U! z) w3 a3 I# @
        // Method for testing that class has been reached
6 w3 l1 A3 k4 h6 g) R' |1 L        //-----------------------------------------------------------------        ; }2 l) {0 b! ?& c0 X1 \
        public boolean AuthorisedUsersReached()2 O& {$ o+ l( |- V/ r: x
                {' N9 }1 c: g0 Q2 e- {! Y9 K
                        return true;                       
8 \- q* H) E6 |: t$ {) T8 S& Q) N                }
: N/ g. \. A6 I$ F                . I: l( x; X1 E! @& x
    } // end of class AuthorisedUsers
7 T" `/ L/ k$ {$ K//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
# P' ]7 M: @5 u! H* fShanghai - 2007
$ [8 i. k: c' ^( v! eAssignment 2: L' a1 A, M$ \( l# f* k
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)
5 V" V' D. Z* a8 ]! W+ L1. 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.
4 @! y, T1 ^* {4 a. M8 `  AThe staff must be able to:
8 m+ h1 B8 p. p( p Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.7 _& x6 z, d; @
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./ n! P3 L! G, m1 H) h) n
 The interface should provide a menu so that the staff can:
% t% I: W& M$ u/ M8 ia) Enter the names of the two Java program files to be compared4 n. ~( _1 @% C% o  I5 W( i
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program., b& o$ O1 y. D: T
** 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).# ^# C1 V1 P& K+ K
BSA104 Business Programming – 2007: Assignment 2% r$ ~  h. l; g2 P
Page 2 of 5
2 O. `4 W0 ~+ F2 p) Xb) Print out to the screen all the lines of code that are the same
/ g7 R% P4 L1 T! T9 ? Include the name of the file and the line number of the code being printed for each of the two files4 y3 w1 j# L: \' \# O" X, A  v
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared7 D1 h% E& }  ?1 E6 k) q
 the name, username and department of the user
+ z% `' x9 W* K the statistics of the comparison
, \$ F& e" j8 K& c$ e- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different* y3 C! P) m) B5 U8 [
 the recommendation for further checking
1 x* k8 k7 ^4 w3 D- 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$ H3 I5 f9 e3 l
 the names of the two files compared
4 l9 i! ?" s( S2 m2 O5 q! zd) Leave the program (exit)- u4 B; U* u( z. }/ Y, ^) X# H7 ^
The ProgramCompare class: (Total maximum 20 marks available)
. m$ l2 n6 |+ ]% M6 I2. 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)* x5 |% z& S* V" {  X! @! r/ M' ~* m
a) provide an error message if the files are not found or there is a problem opening them
$ Y3 P! ~: ?8 n9 jb) compare each line of code
( {- }+ ~, d5 Bc) print out the lines that are the same1 b' x4 T" F6 |9 x  d& G: D9 @
d) count the number of lines compared / lines the same5 ?$ z7 G6 u8 J; n5 q" l( t
The AuthorisedUsers class: (Total maximum 20 marks available)
$ G- M2 L9 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)
! H( a+ o3 P1 b  @4. Provide methods to:7 J0 R. {& [; n/ n/ @# P
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 match0 e0 ~4 P7 h  ~- ]1 ?1 I
b) return the name of the authorised user8 [7 [( x3 M; @; Z3 |4 n. z! M
c) return the name of the department of the authorised user6 k6 j0 g1 h. T$ y* v: F+ k/ m2 |
Individual Data (Maximum 20 marks available)
  N6 g, M" z2 h$ B- f5. 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.
/ S# i3 a; I& Q( F0 o+ L0 ^Documentation (Maximum 10 marks available)
; f+ ]8 X- ~' @6 b( p" A/ h6. 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.
. D" d1 c2 K! ]$ ~BSA104 Business Programming – 2007: Assignment 2
: Q5 [# {: [4 p+ ?6 d5 s- I: j( q' _Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
! W+ Y% x! B0 q, q1 K) H/ Y# p/ m* E不过你要翻JAVA的类库说明。你有下载没有?
6 H) B& c/ _2 o/ l1 d6 U查询关于对比的函数。貌似关键字是contrast,还有compare3 |: a, E; }) R* Z' k7 o6 z9 n

# k: C: y1 x: t8 u0 k[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
: N$ N3 X% J" i: ~痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。9 D, t5 M: z6 v$ G, D( U5 W6 k
可以下载到的 是 jdk-1_X_0-doc& _: p' U) D7 w' U# |  M* V0 L* q
7 j3 K  w) ?2 F" r3 r
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-6 00:21

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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