找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1245|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急$ P1 k! t' H3 B0 a ( d$ _) s& k6 U' S4 k9 M. f7 y- ^6 ^
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************  V4 x4 L, ?$ W" q
//  ProgramCompare.java         Provided by: DRS
7 T8 w5 ]0 U: T//1 _& c' @# m5 E" q. {
//  Program shell for Assignment 2. G# N0 b% @  [0 y
//( u4 q# F; z: g) u
//  Compares two text files line by line
: F& o+ [7 d2 Z//*********************************************************************' d: z' D! V* U

8 M- c# O  U% F4 iimport java.io.*;
8 r1 W0 a! q2 J& i- T* S% L) D" q0 f
: ]5 L9 O! k( B9 v2 O6 {, K: u* [3 \$ kpublic class ProgramCompare
$ c: X9 ~8 F" p6 G! F, J# T{
& O! y' k) U1 S0 f% a% K        //-----------------------------------------------------------------
# W- t5 `, J0 d: P7 b3 s. b' t- t        // Constructor, X4 l2 t4 c( Q1 X
        //-----------------------------------------------------------------
, G3 p# ?$ J! l* S: @$ F. X0 b8 c        public ProgramCompare()
0 `% X: D" h' E0 I' @! i. D# W        {+ [0 d' I5 O' H
        }: X6 u# t( v5 t8 S" @

0 t( A7 k/ k, O2 R        //-----------------------------------------------------------------
$ i+ N6 f# M% M4 R* J9 C        // Method for testing that class has been reached# S* x, G+ g  H+ E& I* h7 Y! N6 x
        //-----------------------------------------------------------------        6 x7 g1 c0 C6 u7 h
" M# H& H  s8 d4 K; e, ^( F
        public boolean ProgramCompareReached()        
  k2 z  ?8 f) @- z        {) n2 j- Z) v. J* x" k6 v( z
      try
6 T4 |& s' o3 Y8 s   {         5 @" e' @$ Q2 z
                       
3 \+ G7 q& e' [; Y                //********************************************************************
  j" T3 A5 a2 k: l. ]                // Try-Catch Statement is used to handle exceptions - such as file not found
! e2 S# w' @4 b1 U$ g                // Reading the files will need to be placed inside a Try-Catch - just like this one!% Q& ]7 K, O8 ?6 \
                // For more information see page 534 of the textbook
6 x5 t! M7 @; W8 j% O) A                //********************************************************************
3 B3 ?4 L7 A8 p4 @: @4 G                     . B' ^( ?& f% a' s( N: e
        }
8 C! S5 i* h# s             catch (Exception ex) // Exception caught here and message displayed to the screen
  o& J% a/ N! Y. R* z! N          {& U: o, n) n, F5 e1 |( h4 ~, v
                    ex.printStackTrace (System.err);+ u# V/ K; M, s: I( O$ F" c
           System.out.println ("Error message goes here"); // Replace this error message with your own         
8 S7 w- ]& q  M8 Q& i        }9 P6 N! d  t( ?& l4 F! `
                return true;
/ ?" ]. L5 W! C3 d9 ^: N        }( i/ K* T2 d9 {: G

# {: w' R/ d! k+ Y: x7 g% f" S} // end of class ProgramCompare* m: |: C* M, j% @5 z
+ N! k3 ]. j/ r6 Z8 ~) u5 h3 B
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
* C' I$ L, q& a$ T: B8 x) y' j//  ProgramCompareMenu.java    Provided by: DRS
$ P9 C/ z9 Q2 [& ^  F  y4 r+ T//( u1 V9 w' A9 A/ s7 V& L9 G
//  Calls AuthorisedUsers.java and ProgramCompare.java+ F2 ]9 _" z- L1 X; `5 ]4 ~5 `  e
//! V8 a/ f. E; R! h+ o7 w) Y
//  Driver shell for Assignment 2.
9 K& Y8 d! ?( y//********************************************************************0 o/ p* H6 C; v" ^6 I5 U# d# E

: \. Z7 l# p8 t" @2 [5 [class ProgramCompareMenu
8 c4 @( G) D" `; H: O{
, D8 o3 l- z7 E8 ^  x. ~    public static void main (String[] args)
6 F& L9 w3 H' s0 z/ S" N            {
% a8 I5 L* g8 J- H% U5 O7 }' [0 t                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable3 P1 D" E- G" Q# o8 a1 y3 n
                ProgramCompare reached1 = new ProgramCompare(); 7 r' }; B: N/ f0 I8 R$ y: F. r
                AuthorisedUsers reached2 = new AuthorisedUsers();       
8 T+ t4 D5 e% U0 P. Y                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());( z  V$ q. Q3 S5 g
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
7 C0 _: K2 e- O. V        }
5 A. k+ a0 v' N# A4 v( G}// end of class ProgramCompareMenu% F0 [7 J* o) i- U
0 S5 t6 `; s# g' H+ R
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************( l* V9 _8 c* l$ X: h
//          AuthorisedUsers.java          Provided by: DRS
4 X! }+ G4 U. }# @# y) y6 ~( k//                - r3 d/ n+ ?! M& T
//         Program shell for Assignment 2
& [0 e+ F8 v& x3 J  W//
0 {+ t8 D# U" v+ t1 o" p1 m' ^//         Represents facts about an AuthorisedUser
6 I& v- J& o" h) `$ K//********************************************************************
, M$ l3 m" g# i5 I0 g& u$ {4 x7 S7 f) R9 J4 X  o
public class AuthorisedUsers
( ?# w' D$ k, T& I# S    {  z4 s6 ~: J4 I! T

1 D8 G/ k0 g# y9 M        //-----------------------------------------------------------------
& t4 X) m; x. k. s8 U        // Constructor
9 S4 ^' _" j* o) X        //-----------------------------------------------------------------
1 N, F6 f0 i2 D+ Z! r. k# V' Z
8 }- N9 h( v4 G9 |# e        public AuthorisedUsers()% [0 x8 E4 P. J& w9 X$ L1 _9 Y
                {4 S, T! g) N6 [
                }
; Z* k' u* T8 b1 q" p: E2 e6 \4 Y; ~% o, R. V+ z# f) {
        //-----------------------------------------------------------------
7 Q! t' m" F; c* L        // Method for testing that class has been reached
9 v0 ]6 K6 u0 [4 t" H+ K# f- w        //-----------------------------------------------------------------        7 Z- S' ~( X& t" q7 g& M. B6 q
        public boolean AuthorisedUsersReached()" `, e4 w% f# q3 p$ S" j
                {9 C& r  v" n: f- |& W; c: \! t
                        return true;                        * H: q: z6 w$ W, d) C! N
                }
0 C2 _: E1 r. o; s! Q( Y               
7 W6 ^2 f+ Z9 r! \; I5 U    } // end of class AuthorisedUsers
! M  t# g" I7 g2 t//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming# J, x9 a1 R- p! g/ }
Shanghai - 2007' o0 l3 @7 `5 ~
Assignment 2
. s4 ~" s6 [8 X1 y3 lDeadline 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% M5 o* P! X+ ^2 g+ A; H1 T
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.
9 W/ n& E* c$ n$ W. I# b0 cThe staff must be able to:
/ [! V: f$ e- [0 ?3 o$ q& F Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
, V( o6 f( f0 |2 [" m0 m! R1. 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.  |/ G" U4 p8 m3 q
 The interface should provide a menu so that the staff can:
! d+ r  b3 [  o3 [a) Enter the names of the two Java program files to be compared
, }+ a, N: z: ` For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
( H/ |2 `) G% x* w$ k8 x) s0 [" 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).: |$ C0 z- v7 t% x
BSA104 Business Programming – 2007: Assignment 2
! T7 M" R* P6 u" z2 dPage 2 of 59 z1 F3 N3 D2 o8 ^2 X
b) Print out to the screen all the lines of code that are the same& O* U$ F* }6 m: s, N
 Include the name of the file and the line number of the code being printed for each of the two files
# H5 z+ s+ ?. f' Xc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
4 {! u* s" @4 C( v6 M the name, username and department of the user9 _9 P+ h/ X4 h  o8 g0 u1 D/ N
 the statistics of the comparison; ~' u/ G/ |4 I" H( B
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
# N& s4 k/ S- O5 W the recommendation for further checking
1 ^: O* c5 ?  m( R" g- 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% ~" {( @2 Z0 h! `
 the names of the two files compared7 j- C1 W5 k( L% n9 B5 X, _
d) Leave the program (exit)' r5 V. K/ S7 P+ v
The ProgramCompare class: (Total maximum 20 marks available): k+ q* M" `) s# g
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)3 e. H% L! Y; i
a) provide an error message if the files are not found or there is a problem opening them
+ Z, K; u0 s! Z$ P' Q  O2 nb) compare each line of code7 n7 A- b* k/ ]+ L- `2 A
c) print out the lines that are the same
. v2 k$ f2 D/ }: cd) count the number of lines compared / lines the same
: o: S+ R! ?5 _- R" yThe AuthorisedUsers class: (Total maximum 20 marks available)0 D+ Y; o* c3 }$ P
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)
+ @  Y0 Q% d0 r' \+ w9 A4. Provide methods to:
% Y6 m. z8 l7 q2 ka) 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: \5 I( N+ \; U/ M
b) return the name of the authorised user5 b4 M1 u, j; j7 S
c) return the name of the department of the authorised user7 v) o; u' x% V' |, N) r
Individual Data (Maximum 20 marks available); ]; }3 V9 L, c: I- j
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.  a& j5 T( y7 B  J, }( g+ k  j# P8 Y
Documentation (Maximum 10 marks available)
3 r8 [# C7 {( j( `; P3 x6. 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.. w: z6 X: b& k1 t
BSA104 Business Programming – 2007: Assignment 2# z# C- W& ~( z& G# X0 f  G
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
% Q8 i/ f! z, V* W不过你要翻JAVA的类库说明。你有下载没有?
: a7 _: h1 `; F0 a, x  z( k查询关于对比的函数。貌似关键字是contrast,还有compare8 Z8 N% t3 S; j( \

/ q$ O6 d& Q( Q( H7 p1 o' H0 n[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -: l5 s- Q7 |' q$ \0 n* W  r
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。( M, z( P  ^4 O& @8 w1 d  D
可以下载到的 是 jdk-1_X_0-doc! p' W4 t7 C7 e* r

! H8 w! X, A6 U1 r4 N% D& w[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-2 02:00

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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