找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1229|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急6 |6 p9 ~6 W4 e$ I; _$ O6 F * C) T% c! |3 A
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************" _* X5 M) M" {% S( D
//  ProgramCompare.java         Provided by: DRS: T# H# l! x! @0 u" S  _
//; L+ x- w6 @+ C# l8 C2 i
//  Program shell for Assignment 2) F7 s  |* X0 o: _4 {, L  |
//
, o/ _' B: V8 z7 W% n/ c. Z; B. ~//  Compares two text files line by line
7 Y! x4 ?1 \2 L. |+ n) S//*********************************************************************. z' v  v& S( q' C  M% i
2 R) ?+ a& v# g
import java.io.*;0 o$ w! d0 e5 G8 x

, O* G$ f8 g/ G8 }2 ipublic class ProgramCompare2 @! g$ M* s0 g! l, a: F: B
{9 A* r1 n7 J: ~8 Z
        //-----------------------------------------------------------------* i4 j" ?& T! t  H4 x
        // Constructor
- X* [" T1 d6 e% h6 ]+ V        //-----------------------------------------------------------------
- k$ D# \$ x1 F! Q2 [+ G, R4 q0 b  C' t: ~        public ProgramCompare()
' ?% n6 c- o3 i        {2 U# k0 H* Q" u; B2 m/ x
        }
/ ^  D+ v! j# ]( R& ], Y% r
9 g* |2 `6 I; F        //-----------------------------------------------------------------' X& E8 L- p2 e" Z
        // Method for testing that class has been reached
( l3 N* m0 q' Y$ k7 g        //-----------------------------------------------------------------        0 ~4 t6 w! v& Q. e

: L9 ^; Q$ B5 C5 {4 ~+ G5 [        public boolean ProgramCompareReached()        
. a" u2 X# @) O5 ]6 h. h        {
& f6 X. e- k1 {* U2 v      try
5 J& D8 \! q# F& ~" M; _   {         8 z7 h& M2 y' O& N" w7 t
                       
; Z6 |. k+ b( h                //********************************************************************* l7 t6 h, ^: {# R9 _4 g5 T
                // Try-Catch Statement is used to handle exceptions - such as file not found
5 ^0 H4 N. {. L  z' K% d                // Reading the files will need to be placed inside a Try-Catch - just like this one!
+ f: N  t  D  P1 R9 n                // For more information see page 534 of the textbook) _' I& t8 u. h- r- G) @1 e- i7 A
                //********************************************************************1 |4 {; r' ]4 d, f
                    
: _/ h$ F( c. U        }$ y3 s/ y  d$ T3 I# ~- d
             catch (Exception ex) // Exception caught here and message displayed to the screen
6 l  o- M- h1 Q4 l8 h          {
1 E$ s# |' M/ {; V; P: U                    ex.printStackTrace (System.err);8 q% `. X; X- \3 A, I; N
           System.out.println ("Error message goes here"); // Replace this error message with your own         
/ Q$ W  n  w6 u" R* m3 R" _        }
6 G0 B3 s8 \. s; D                return true;
% E9 D# p* v* k0 u6 Y% g( x) C0 S        }
+ P( F) Q; ?8 X& B
& o% b6 X  {% q4 b9 I+ ]/ r} // end of class ProgramCompare( m9 J* v: d0 e  z0 {5 {

7 a. G8 W* q  ^& V//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
; d# k8 b' ]' E: V//  ProgramCompareMenu.java    Provided by: DRS
4 d: r& |2 O  h//  ?# V, q0 O4 D" x
//  Calls AuthorisedUsers.java and ProgramCompare.java4 i: d* U1 v/ c5 d/ @; j
//$ i& e# v/ C5 E/ G& t$ o
//  Driver shell for Assignment 2.! V/ @8 J) M: n. F1 T7 B( v
//********************************************************************
2 V2 \) i- z! M8 b* x) y- G2 j% d% Z* ~/ w& H
class ProgramCompareMenu
, m0 {' a" P; _, R4 J& j$ Y$ ~# x{
) X, ?3 R3 J. f  w    public static void main (String[] args)( J9 X( o) f& o7 ]. a
            {; N1 p  R8 ~3 c) P- m. D
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
3 n, Y* H  g) p$ X                ProgramCompare reached1 = new ProgramCompare();
& N* s0 R9 ~: E8 _+ N* F                AuthorisedUsers reached2 = new AuthorisedUsers();       
8 {4 y8 |8 u+ z( l7 ~. K2 J1 g                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());, P3 m6 z; V+ t! V$ I; j
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
6 u/ l) V$ v0 O0 _2 `! e        }
5 H. ^5 E! H. d$ ]1 t4 T}// end of class ProgramCompareMenu' I$ ~( Y" A1 Q; D4 P% i5 u' x

; U- `4 M9 Z. w) B5 o//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************9 m3 N: S# o8 r; u7 a6 ^- H& T
//          AuthorisedUsers.java          Provided by: DRS) }$ d- L4 Q% V0 f' k) k' Z% A, V
//                , I6 L) d6 B4 a
//         Program shell for Assignment 2
" a' A6 V8 A; K//
0 F, h- M  T7 |/ K& C- ], r//         Represents facts about an AuthorisedUser* Z, f0 S) \7 P/ b; s+ c
//********************************************************************8 {/ K/ J9 x4 S+ H) F& e) @! ]( j

; }! ?; Y: d8 Z, Epublic class AuthorisedUsers- b: _8 m1 E" W* j3 C
    {
/ ~, J5 ~/ Q/ j5 R7 q
1 x- m  Q$ ]# |, c5 C* x# ]        //-----------------------------------------------------------------
0 {. L; }2 x& p7 p1 a5 O/ q9 y        // Constructor2 m- W  D, d! q5 \6 n/ E
        //-----------------------------------------------------------------
# Q! l+ s5 u7 B9 Q$ L: n4 b0 G- r# ^- q5 V6 n
        public AuthorisedUsers()% O7 s. F( M2 G: x0 X4 I- @
                {) i/ u' `" p; x& k- C) Z0 ?
                }8 ^: S& V& d  k6 z

1 V) f7 _) ?/ u3 o        //-----------------------------------------------------------------
7 T" r8 \& @3 I# A% _0 b1 Y7 s6 p        // Method for testing that class has been reached( E  ~; h1 q+ Y9 A" n! g: A
        //-----------------------------------------------------------------       
, W; w. p; q/ R, O$ N# k        public boolean AuthorisedUsersReached()6 o" A$ R" s% L# y
                {& t3 K1 e# G8 j2 n" Q/ [1 y
                        return true;                       
( {+ B/ h4 W: J$ D                }1 {+ a. R7 _3 R! l& q0 R  J7 p
               
- H, k' K. a9 v. c$ |    } // end of class AuthorisedUsers
3 d5 H* o4 H* A7 W/ N//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
  y2 @/ a, d  c9 K$ \Shanghai - 20077 {" a/ N4 e, A0 f1 g( {
Assignment 2
1 |5 O9 r# F' R! V: yDeadline 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)3 E* Q! u# ]" f
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.
) U( n+ L/ f" E; Z; wThe staff must be able to:
# k2 D/ ~/ S/ U0 i Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.$ ?, ^( l/ L. D! C( J3 L) P
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.: @8 I3 J: L) R! U& Q6 @
 The interface should provide a menu so that the staff can:  i: L: `1 i/ S1 O- ?  l' H: O) W5 o
a) Enter the names of the two Java program files to be compared1 |! j! G7 O1 g3 u" z+ F
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.  y5 F. H1 [" Z  \
** 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).0 {# H4 m+ `% F) \( S) ^) y
BSA104 Business Programming – 2007: Assignment 2
6 B! ?0 J8 E9 k4 e9 M$ F3 sPage 2 of 55 Z  }/ @0 S/ t! n/ \
b) Print out to the screen all the lines of code that are the same
9 f2 k& `) f- G9 Q$ J" b1 M* K Include the name of the file and the line number of the code being printed for each of the two files" [- r8 x8 |2 ]9 S$ h4 ^5 w! e
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared  M. j+ I/ y& {) Y8 s# [) i
 the name, username and department of the user' Z! @4 X; r1 @- n+ C' k' z7 N& w
 the statistics of the comparison4 c4 C4 o; `& ]% [* I: _
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different4 S7 q7 Y. G; g1 B& U6 p
 the recommendation for further checking' X4 G/ @  {) ^) w
- 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
1 I# V9 ~; [- I# j the names of the two files compared( f) ?4 J$ c- Y% r
d) Leave the program (exit)! s, X) W$ s$ E+ T& E
The ProgramCompare class: (Total maximum 20 marks available)! z( H- T" T( |3 U( Q: A- n
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)+ Q7 ~$ e, b, P0 U  D
a) provide an error message if the files are not found or there is a problem opening them
5 W& B( q& {" v! g4 c& Eb) compare each line of code0 I1 Z5 D8 C) r: I( D% i" E
c) print out the lines that are the same
1 i$ @" C2 s+ U: k6 g9 c. xd) count the number of lines compared / lines the same; A! B5 D4 v- W$ F: {! k: g
The AuthorisedUsers class: (Total maximum 20 marks available)
9 B+ l7 X5 ?2 Q; Y3 r4 e- k7 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)! f6 D. S9 t$ x% `( Q
4. Provide methods to:
6 t( q: H* @) ]* a/ R! [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  o% ]5 f) j& g: ?0 I
b) return the name of the authorised user
' ]6 M3 K. B' \, Yc) return the name of the department of the authorised user! u1 ]9 P6 M% n) L' L* s
Individual Data (Maximum 20 marks available)8 i/ R% |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.. A4 M& h, o" G( O0 ]/ i
Documentation (Maximum 10 marks available)
* [7 ?. p2 H+ `6 X" |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.
! ]0 N- f. A  f1 C. S/ C# h# z- T; M1 ], MBSA104 Business Programming – 2007: Assignment 2, x6 [1 I$ H; I' F, ~
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
5 o( U0 h( U) k不过你要翻JAVA的类库说明。你有下载没有?
* p! j4 f8 l  L3 `6 b7 _4 h( Y5 Q  j. C查询关于对比的函数。貌似关键字是contrast,还有compare/ K2 A, a# p1 n. o; i
( m9 M! |. d8 V
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
( m; \% ~7 Y! z) G; U痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。) K( j/ s7 q7 Y2 v/ y
可以下载到的 是 jdk-1_X_0-doc
# y3 ^% G7 ~$ g, y4 x8 f% m- r. M) n% a9 b& r! L
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-22 22:40

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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