找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1793|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急+ x" g. P6 H& M) ~3 H+ ^( y 9 U8 w" ]/ N# R' l; ?
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************& [$ C5 m% c3 i1 E& ?  z7 ^
//  ProgramCompare.java         Provided by: DRS8 h: `. J% x" P9 C' [3 ^
//* b8 w/ w  I3 z. s( \% x2 l" f0 y
//  Program shell for Assignment 2
) ?8 F& p8 g' y# o9 {. n//
  |( ?* X4 s, T5 _//  Compares two text files line by line
$ M  M8 {6 @/ B+ {/ W- ?, q//*********************************************************************/ Y. T$ X& [5 ]0 g' y

6 }9 `" s2 I1 Qimport java.io.*;+ ^5 D: p9 F% G9 q) p7 I# [

% l! ~- r' ?3 Z+ @public class ProgramCompare. z, J. P- B0 O" ?" z
{
; i+ e4 ?/ C# V" l- f        //-----------------------------------------------------------------
8 u: H7 G9 K5 Z' |1 u% d1 T! a4 X. K        // Constructor
. u' i! m) I! D2 D! q        //-----------------------------------------------------------------! e' I& a6 H4 |  R
        public ProgramCompare(), h/ ~( B# P0 U! @  Y, e( n
        {8 c$ Y5 K! B" [& y. C% @
        }
( Z& N9 H/ }( E7 v5 T! `& @7 n2 g2 N
2 w8 r# }6 S$ r' W+ N( n        //-----------------------------------------------------------------
) q/ z" L; \) a        // Method for testing that class has been reached) h( x0 c3 {3 y
        //-----------------------------------------------------------------        / D( t% l# D* T$ c3 q! H& V
$ s. y0 A9 p  r! N  T% [* j1 E4 k6 r
        public boolean ProgramCompareReached()         " S% q4 C1 j- e& R
        {- F% I6 s+ s" k+ S2 Y  E: Y, Y
      try
, d2 ?3 w$ ~) O   {        
5 ]: L9 z: p& |/ I, `                        4 ?7 K7 V! K# Y2 j6 K
                //********************************************************************. Q8 I5 q# C6 }0 f5 g, B; [$ j
                // Try-Catch Statement is used to handle exceptions - such as file not found
2 t8 j& W- \& K7 u! j                // Reading the files will need to be placed inside a Try-Catch - just like this one!$ Y+ [8 u/ ~( E5 p9 z/ X
                // For more information see page 534 of the textbook* Z7 I9 V) y# h4 f& Y' h& W# @! Q/ ]
                //********************************************************************
/ N. {3 g  R; N7 k- p9 ?; x; _+ h                    
; ?, x2 a" O8 ?. P3 X        }  y( ^2 \$ C) ^, d
             catch (Exception ex) // Exception caught here and message displayed to the screen
- N6 {! N7 _& ~  k$ w          {
( c# d+ R" ?6 o1 t                    ex.printStackTrace (System.err);
8 i6 T! G8 v3 m/ }! [           System.out.println ("Error message goes here"); // Replace this error message with your own         
- u# q6 U( I% P3 j0 m        }* E( ]! a3 m8 J: G) u
                return true;
. j/ ^+ n2 R  O+ }+ }. d/ s        }
2 g( a/ W# Q# ~" K7 U: P! ]8 \1 _- ?7 W6 a: b- t
} // end of class ProgramCompare8 k* k. s  V$ k% P6 o1 u
" P# Z+ c; G! D1 N$ }
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************" w2 [" \- V7 l. ^& K: E
//  ProgramCompareMenu.java    Provided by: DRS
( h6 m. }8 Q6 P" t//
4 i% d4 U; }( d+ [* a0 t//  Calls AuthorisedUsers.java and ProgramCompare.java/ E, C$ v/ s1 j. _8 f
//0 T8 @( K8 v9 q% a' |- g8 \* \
//  Driver shell for Assignment 2.) |# |/ S+ t/ M% w
//********************************************************************
# ~" z, b1 T+ j# J5 B( o9 a% J; l* z# N7 P* y
class ProgramCompareMenu
2 _( X5 C4 d, w7 e! a  a{' t4 e8 P  J; o" X( k) j
    public static void main (String[] args)
/ _; L, S9 `7 C& U' o- @) i) o5 u            {3 I; g) f6 i! W9 Q) j: `* n$ l/ a
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
1 R, o1 v$ `; N; E                ProgramCompare reached1 = new ProgramCompare();
5 B. W6 U5 M! l0 i5 P                AuthorisedUsers reached2 = new AuthorisedUsers();        3 A7 F& m% B7 s( n. S
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());2 p- N! S" e! Z  M+ V
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        7 I7 h- V& a, @  S! t2 }
        }& f, D2 j. k) I' C5 Y  v$ }3 m. q
}// end of class ProgramCompareMenu' s' L5 k/ W* n- w8 {& p! w! b& N

! e- P6 c. O5 A' Z# [2 A//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
9 [; X9 r) r2 K/ ]+ v9 _//          AuthorisedUsers.java          Provided by: DRS+ q8 [2 E" l1 A' h5 P  t
//                $ F. ]& ^+ T0 z9 j- P
//         Program shell for Assignment 2# Z+ n: V, x" U8 u3 L1 h8 B8 f
//9 h: k1 M: k8 X& g3 ^' b
//         Represents facts about an AuthorisedUser7 g+ Z, M8 A7 o8 D& i2 D
//********************************************************************9 `* b$ B, ~$ z6 c  [; k6 J1 Y
# ^3 G4 W* \5 {/ Z" W  u" b
public class AuthorisedUsers
, @4 m/ C* c1 ~/ w2 Z    {
6 W% `( c+ V$ e1 A! H( V! j: V) N' H8 s
        //-----------------------------------------------------------------
1 @5 N" C9 @% W& L: Q        // Constructor
- T7 p& c+ i/ E3 U2 \& x4 S* V        //-----------------------------------------------------------------
: S0 o. n2 h# `6 s2 l' {) t( V
8 K$ L. l  P% m* T4 Q5 o- T  p        public AuthorisedUsers()8 k+ t8 B7 s7 {( L1 l: N$ @
                {% N. D# B' M- S
                }) L! j+ T) E$ p

( U8 e% a0 M3 X  ^        //-----------------------------------------------------------------
1 ~! B3 ]3 y/ N' N        // Method for testing that class has been reached
' q# E0 _+ f4 x/ x' g2 A        //-----------------------------------------------------------------        ! O& j: w8 W! N3 L" ~
        public boolean AuthorisedUsersReached()
! W9 o) B# z; c% O5 }9 m/ b                {  C0 ~# _1 F' i2 C' O# S# |5 f8 g
                        return true;                        ' Y9 ?9 Q7 A) t: }7 f
                }
& w& }4 Q4 {, d  b: j# H8 c7 `% w               
/ E) |8 q( b- }4 e: y1 l5 t1 c    } // end of class AuthorisedUsers$ N* o  }4 n0 r; w( o9 O7 x" v- S
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming2 ]& v- h( G& J0 d$ s
Shanghai - 2007
8 ^6 D+ V1 a9 Z+ zAssignment 2
1 [2 F2 I% x8 |9 m; y2 _# E& uDeadline 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)' j& R: j" i2 e' d. A: t) u
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.4 w& w+ @9 c5 m7 k
The staff must be able to:3 u9 @0 a, B& R
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.5 J1 K: D/ C% T* M0 Y8 [5 t
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.6 t8 \6 \8 l* [7 S" B
 The interface should provide a menu so that the staff can:+ T& k' x+ z( b% ]. X
a) Enter the names of the two Java program files to be compared
4 s' H- m! g+ ]% V For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
+ K) c3 L: `6 R* b4 y** 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).& T9 R' l' g6 y7 Z* ]
BSA104 Business Programming – 2007: Assignment 2
% r: y: C- ?" s1 }( R6 TPage 2 of 5
9 D$ ?- A+ a2 y  ?9 zb) Print out to the screen all the lines of code that are the same+ |1 E: h. U/ u8 h* s
 Include the name of the file and the line number of the code being printed for each of the two files0 Z' H# R2 ~9 o2 Y
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared  V* S" l) E3 c
 the name, username and department of the user
, r7 s9 E  R; d, M$ ~+ o the statistics of the comparison
2 R6 n9 M, c# Y9 Y. E- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different9 V' w" r! D5 \$ ~
 the recommendation for further checking
4 c* [4 r$ U9 p8 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 closely8 H$ [, O& B2 s5 g
 the names of the two files compared3 G+ e4 {' H$ z
d) Leave the program (exit)+ O# F3 H* J9 l5 a& z/ x% h
The ProgramCompare class: (Total maximum 20 marks available)
; d; c( w1 I. Y0 c# H6 a3 ~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)) R7 U" [+ W- e: j; A
a) provide an error message if the files are not found or there is a problem opening them  A4 w5 [, Z2 F. H
b) compare each line of code
  Y+ P4 H6 T" @$ ]7 ?' Oc) print out the lines that are the same& b5 b+ X1 _6 Z7 {+ H
d) count the number of lines compared / lines the same# K' j* }1 W% L& o7 Z* {' A( t5 l2 P
The AuthorisedUsers class: (Total maximum 20 marks available)
7 b" Y" s4 y* f' F4 x3. 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)" p0 ~; @: y, C
4. Provide methods to:' P3 m  T6 D* O5 w# L
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
& K" [8 S. C. F& jb) return the name of the authorised user3 v4 y! j. A* |, s' w4 C: l
c) return the name of the department of the authorised user
, V/ V# Y, f3 L( Y* jIndividual Data (Maximum 20 marks available). z/ ~6 Z  _7 ?
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, \' k8 ?, A5 Z; i+ `- f
Documentation (Maximum 10 marks available)
. Y9 y) w' N3 ?: A6. 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.  \9 Y+ N9 k0 D( o2 b; c# c  I9 ~/ k  C) ^7 d
BSA104 Business Programming – 2007: Assignment 2; I2 Z8 w2 G2 I, L" w
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了3 I- H$ U6 r8 G# u  B, m
不过你要翻JAVA的类库说明。你有下载没有?9 A* S" L) F3 \
查询关于对比的函数。貌似关键字是contrast,还有compare8 z2 o# w* H; V- G
3 h( s0 z8 x" _6 \
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
( ?( V; [# t1 y! C; J痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
% W% @% K9 f# d' U2 \, a可以下载到的 是 jdk-1_X_0-doc% f" ~4 z- u8 h% u6 {$ s- g
! Y" ?8 K! U, d' h4 ^
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-2 22:56

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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