找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1821|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 - l, b7 n9 o4 m) {3 V: [ $ M# z4 F1 ~% Y+ N9 x
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************% \& f5 _; n4 J
//  ProgramCompare.java         Provided by: DRS
+ b- m; W5 Y" F! i* f//7 @4 _, ~) n& C) M, \, v
//  Program shell for Assignment 2
  T6 y* `" H& z/ B& d0 q//
; L3 u1 C2 X3 L& R//  Compares two text files line by line
  T$ U5 v" a; j# ~* B//*********************************************************************: o( Q- G  b( l8 A2 N1 Z; m

# b' ^8 _2 ]! b; g/ X& Cimport java.io.*;7 N* o3 f' U1 j) D  u

, @! b# n/ w( G/ B, Epublic class ProgramCompare; |% S1 t4 J! e6 j% _/ [: b- q
{% a; L% k8 [5 S: \
        //-----------------------------------------------------------------: ?. M, l7 d, ^: j
        // Constructor* D0 O$ |- S9 |2 S1 X
        //-----------------------------------------------------------------
- b9 Z% l$ ?' i$ }        public ProgramCompare()9 H, S: Q# A$ S: Q
        {2 Z0 Q( W- a! t7 X
        }8 ~* g1 q  z( q4 I' y: i

& ]0 ]- r& {5 u' ~& t( J        //-----------------------------------------------------------------
2 E, }; r3 o2 C, S1 ?, [4 }8 `        // Method for testing that class has been reached
. a1 r4 U- l9 Q" \        //-----------------------------------------------------------------        $ e8 G% p: [- N: S3 y
, V  T$ p/ t; }8 E8 T# s
        public boolean ProgramCompareReached()        
. R. c6 l2 n! Z        {
3 h5 H* j0 K5 J* _! M+ K! s      try 1 Z- l0 y1 _* q/ L+ j
   {         7 q* J' w6 V/ T% m& G. W! E' Y
                       
5 E% t) Y" ~3 p* W9 g6 V                //********************************************************************
0 s+ J) |3 ?) H: }1 ?                // Try-Catch Statement is used to handle exceptions - such as file not found - e  H% f5 B; n! \3 t* n0 @0 E
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
. U0 i7 X+ R% B                // For more information see page 534 of the textbook4 r- I: g. }. I" ]8 |5 O8 ]1 U
                //********************************************************************
" l, W; `; o% B0 ]; P2 m                    
- Q4 l( x  k3 F9 N1 P. E5 G        }( \% `) Y' X7 r
             catch (Exception ex) // Exception caught here and message displayed to the screen
# ~0 ^  @2 i3 R0 T# H- N2 ~          {
7 x( o' A; D% Y  P  c' z                    ex.printStackTrace (System.err);5 e, p  Y8 z1 S8 v* j
           System.out.println ("Error message goes here"); // Replace this error message with your own         
( Q" y0 K9 g& \3 ]5 M        }- M' q' n" a3 q
                return true;
  u: d# Y5 O+ U; W; F        }$ ?8 a1 g( g* |0 s5 j# M

5 W3 i* }3 ?. c+ B+ }5 N; ~} // end of class ProgramCompare
2 @; j, b0 _; m5 S/ p4 V
& X/ B8 {; Z/ _8 m  j' m$ X3 C//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************9 ^  ?1 N% v1 C9 D: x
//  ProgramCompareMenu.java    Provided by: DRS2 F4 t3 d0 ~6 A" \
//
0 M, M; e/ M3 c/ F, o) V//  Calls AuthorisedUsers.java and ProgramCompare.java& U0 o& Y9 h2 R9 r3 s- `4 z/ M0 a
//+ D% y& n$ \: `6 ^
//  Driver shell for Assignment 2.+ C6 C4 b! i, S
//********************************************************************
) k# U# \) g# f! Y* I$ h& M9 z
( o' d* r' N: z% {* j# w' \' Oclass ProgramCompareMenu
! p* ]' |: y* y; X5 u{! q( ^" o, g+ f3 W. A
    public static void main (String[] args)
6 \/ L" X3 d$ L% S; I$ r1 H            {
) c' R7 \; \/ }4 n/ F                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable0 X, W2 W+ ?) @. ]
                ProgramCompare reached1 = new ProgramCompare(); ) f; f& O+ V3 @- _. P
                AuthorisedUsers reached2 = new AuthorisedUsers();       
+ u, d; ~4 Y- ?4 d3 F& H; X. B                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
% F# q. ^: h5 G                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        . O/ U. ?; Y; M
        }
" l( G6 ]; e" i}// end of class ProgramCompareMenu6 @( `9 a# l$ P6 W* L! P6 P5 t

; w8 h! p" Q! @) @//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
$ x# T+ c# T4 `% P, l: @//          AuthorisedUsers.java          Provided by: DRS" M  e& z8 T5 L- H4 M; o4 V; l
//               
! r+ F  c" Z6 @' U- B//         Program shell for Assignment 2
+ \3 x+ {" H& [' r* z//) d0 l5 S. p* M) W& K) ^- j
//         Represents facts about an AuthorisedUser
& F+ e; H- D% N3 g/ x/ Y7 I0 D* q* \//********************************************************************
2 H# P" f) J% r' {, ^. @( S# p0 {  C# u/ }
public class AuthorisedUsers9 m4 ?6 [* _9 u! u/ o' Z% s4 p
    {
" f& G1 L% s+ v/ a) `, ?" j/ P3 F  F) O% h3 P$ H
        //-----------------------------------------------------------------
+ @7 m( V) j- [' d) {5 Z- A        // Constructor; p* G: g+ c! T7 \% |' d
        //-----------------------------------------------------------------0 o1 t, W( _$ V. y1 d
5 c/ l  ?; I3 p" V
        public AuthorisedUsers()
8 I* I3 d5 \- I- I4 \                {
/ j8 ~4 ?; \) Q& ]( N3 O/ ?& N                }) ]7 X6 F) [/ j7 H

4 s8 R2 a) n# n3 L0 I0 S( S$ @5 O        //-----------------------------------------------------------------6 f, L% H7 g$ ^/ J
        // Method for testing that class has been reached
- `! m5 ]8 S, L( U        //-----------------------------------------------------------------       
0 V# ~3 ?3 [8 N: n# e$ ?        public boolean AuthorisedUsersReached()
) R) w! q  Q& T. m* n5 l                {
; [  H% j* T; u1 n+ ]1 H                        return true;                       
2 A# V* h4 C/ x  h* j                }7 m- a& a; i4 `2 A3 O
                ( D# d" H0 A% c" J  f
    } // end of class AuthorisedUsers
" j& C$ j! W1 i  R; }//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming8 b; V, X6 y  x) H; r# [  o
Shanghai - 2007" Y. A2 z$ l% @) D
Assignment 2
9 Z# Z& A0 f- @. RDeadline 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)% e0 w5 a8 o* C
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 u# F" {- y( J! O" @+ S1 xThe staff must be able to:1 i. R& \; m4 ~
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.! W* Y' W: B6 Q) x
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.
1 `5 o$ S7 I- \: Y$ P! w The interface should provide a menu so that the staff can:
# [& g7 {' t: [6 B- J4 v! w2 Za) Enter the names of the two Java program files to be compared& a1 q$ G8 ?  c; H/ B% k
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.( s1 K/ n* `0 B, q  I1 f/ R+ h) P
** 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).3 l+ A5 T$ I! Y- I% w7 l" I
BSA104 Business Programming – 2007: Assignment 2
# T2 K5 x. j8 ?4 T/ B- }, t; zPage 2 of 5
! m  H& ~% L3 }! Hb) Print out to the screen all the lines of code that are the same
; D' Z7 M7 G* X. q. r Include the name of the file and the line number of the code being printed for each of the two files
1 R4 ^$ y  [; j% Tc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
; h2 i9 B7 y' L" y the name, username and department of the user% y/ X' ^! ]+ i' H6 R6 G- U4 a; C
 the statistics of the comparison1 ?! g- y. G# ]/ G
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different% Q6 p/ K' ~$ W$ T& C2 v; N; N2 Q
 the recommendation for further checking
8 u  y" C3 ?+ v: \& W' J- 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
3 n2 K" `: d# w* C the names of the two files compared
# C- X! @2 x# {! ]1 J6 n: |# V9 ~d) Leave the program (exit)
& M' i3 h  \5 A$ F% T; R( aThe ProgramCompare class: (Total maximum 20 marks available)
% ]& P9 P( C% \7 v+ Y3 u& `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)  s$ k, }0 X0 j' Z+ _
a) provide an error message if the files are not found or there is a problem opening them
) V0 V8 ]2 F% l: z, E( b& \9 ]1 `b) compare each line of code
* G; t6 _; j$ Q9 z% C* Lc) print out the lines that are the same
' D  x# k" H7 p" O7 Bd) count the number of lines compared / lines the same+ W. e6 E' R0 L- r( z4 n- H; s
The AuthorisedUsers class: (Total maximum 20 marks available)
$ T& b3 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)+ o0 Y) }) @* M$ l) Z5 i
4. Provide methods to:+ h! ^8 h* R3 s3 O
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& T! m" |. V& ?5 j- H. L1 _
b) return the name of the authorised user
( G1 {2 z0 D; w; q4 [& Uc) return the name of the department of the authorised user
, p9 k& W  M# r6 e) A! zIndividual Data (Maximum 20 marks available)5 w1 i. s3 ^% o& g, E/ S. A
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.
  G  _" F9 }% O) U1 a3 D! u4 z5 WDocumentation (Maximum 10 marks available)* Z# d; s7 F# C1 j
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.
" G  X( k' S  x/ _BSA104 Business Programming – 2007: Assignment 2/ s$ x# `3 n0 t& H' ~
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
- m3 t3 x+ |. Y8 Y( d: u# u不过你要翻JAVA的类库说明。你有下载没有?, O/ y0 ~) K& o6 E
查询关于对比的函数。貌似关键字是contrast,还有compare4 W. j: _) Q7 m( Y2 H' L

4 x6 [* }; c, b5 _[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
. M- R: E( H' Q9 Q2 j* B9 @9 g. e/ u痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。/ ]- w* M) c5 V& n- F5 H; |- x
可以下载到的 是 jdk-1_X_0-doc
3 y' a+ N" R8 l) @) w0 l$ T( J" ^' t7 J  s
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-13 15:10

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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