找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1733|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急6 I1 Z" q Z4 t! u 3 R! h" Q1 B( v. |% u, p `& w0 M
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************6 ]& \9 k% V( B/ B
//  ProgramCompare.java         Provided by: DRS
: }) p% D" _4 C: u" K//1 [' y. \, a6 z9 H2 I
//  Program shell for Assignment 2# Z' e5 ^- ]$ S2 w# p
//6 S4 G: n+ t# S/ g; Q! B
//  Compares two text files line by line2 K8 Q: V2 r( J3 l7 [6 w6 @
//*********************************************************************
3 l1 w6 w- g. k$ a, a9 ^' N$ t7 R1 l% g: _
import java.io.*;
3 C: _2 S; v2 X0 _
- ~: {# ~& C! k) V  A) W  Y8 G% R$ ypublic class ProgramCompare' r/ \8 s# p4 b- b
{: b$ T' r0 ]4 s7 p9 M, j
        //-----------------------------------------------------------------/ P% i5 q* r7 @8 w1 \
        // Constructor% v+ u+ J7 ^( H2 E; r
        //-----------------------------------------------------------------$ E  `; Q% H4 t$ W
        public ProgramCompare()
# o2 ~* y' {/ ]/ k1 t        {$ k* w  W# B& E5 _; t
        }
# F3 W8 S8 a, ]8 D. G
% i5 S% i  r% O( t. K& y+ ?, g        //-----------------------------------------------------------------. q/ R4 R# B3 d! f3 L2 N  o
        // Method for testing that class has been reached
. {/ y& Q+ O) J4 b% q        //-----------------------------------------------------------------       
! A" x  w& F# a- q9 C% |
* \9 I3 D$ c* F0 L& P0 O        public boolean ProgramCompareReached()         ; H( h" i' t+ l* m! u
        {% h$ Y+ ^* H( D8 C$ g$ z% G& O
      try : l) }- y1 g/ o5 w6 O" }
   {         # N* P# r" h, y* m2 H2 k/ s* r9 L3 i! H
                        # ^( p: U( ?* u# G9 l; d
                //********************************************************************* p% M/ X' m0 s! [
                // Try-Catch Statement is used to handle exceptions - such as file not found : z, q4 j) a4 [. s( k& z
                // Reading the files will need to be placed inside a Try-Catch - just like this one!; M+ f5 C( ~2 u8 G
                // For more information see page 534 of the textbook
( u9 d  w7 i9 s7 T/ h5 \6 N- Z$ L                //********************************************************************
# c9 N7 L* o9 k$ i: }2 L                    
  `1 {5 ^( q# F; Y; n        }
7 K3 c0 N% `  `3 L. z             catch (Exception ex) // Exception caught here and message displayed to the screen : w  @* Y  t  ~% V
          {* x7 ?( g$ c# N0 Q
                    ex.printStackTrace (System.err);7 U6 P0 M0 F9 G* I% Q; ?. Z
           System.out.println ("Error message goes here"); // Replace this error message with your own          0 _8 g) L# l. p5 \' X0 a
        }
/ g6 {0 {" z% \4 a5 o8 z) ]! a                return true;
5 N0 i4 ]$ \6 n; i        }/ P4 b8 T$ v- ?5 J

9 x# `, h- p& B3 F( ?} // end of class ProgramCompare0 y/ t* i7 t* d

. r) {% H% L: L' U& a7 [$ W//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
" k$ K% c! n1 a; t: ^( b$ }# v- D//  ProgramCompareMenu.java    Provided by: DRS
: a: F, Y" r; O//' g3 K. m( \; ]0 U5 h6 V/ V  h
//  Calls AuthorisedUsers.java and ProgramCompare.java
- V. S/ f- U! O//
6 W* s$ W# l" G2 R& i//  Driver shell for Assignment 2.
6 C, Z. E. ~/ }- t- ?//********************************************************************% B" @7 p  o( @3 r
/ A/ E1 b5 W3 y/ d: c( v
class ProgramCompareMenu
9 q* T+ k2 p: ?) B) |{
: C" X# i: |8 r  {" C    public static void main (String[] args)
7 G+ Q- s0 ]' z7 M8 `* V# ]- P: V2 p            {( }! m( l4 e! u
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable; K% v. ~$ \  k: D0 ]
                ProgramCompare reached1 = new ProgramCompare();
+ v4 z( w* O1 y9 K- u0 b                AuthorisedUsers reached2 = new AuthorisedUsers();        * y6 Z0 j4 }6 K: _
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
7 ~" a/ F  O7 J: @2 F8 z0 D$ X                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        5 s6 Y, }* `% G$ Y% A* Z; ]
        }
) ^6 g5 _7 \! S! n, P}// end of class ProgramCompareMenu; _# P$ k0 B& B, m# ?; @6 t, I" v% _

! v7 Y1 F* t2 m//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
4 P& s' c2 d- V. W# Z//          AuthorisedUsers.java          Provided by: DRS
0 \' ^! E9 r2 d//               
+ N% m! V2 ~( Y* Q& b' C//         Program shell for Assignment 2
& @6 |* D: E, d: R//
% c+ q* v3 d/ j3 [7 t2 ^3 z//         Represents facts about an AuthorisedUser1 p9 m" t0 T1 R8 r  p) ~- J0 E0 @6 c
//********************************************************************
2 Y0 j5 y: {6 u- n8 h) z
4 T& e4 h( x) H/ S1 x: k, bpublic class AuthorisedUsers* I; A" V* X4 J% u1 Z2 E9 a1 f# b
    {7 X, b; Y3 F7 A- q8 f- i4 ?( {

/ i  J" H6 d! t" O( j) H! I        //-----------------------------------------------------------------
) M5 o3 U& ^3 R# W/ Q/ [9 ]        // Constructor
# g% A% G- o0 k9 e        //-----------------------------------------------------------------4 i8 y: g7 A' U7 h- V" r

: s8 m/ \: L' H' G" q        public AuthorisedUsers()
) i; c* d2 n) {2 K0 C1 L                {
3 U/ m$ Q) D/ Q+ v0 q                }9 i2 u5 C8 I$ E6 i

  C, }3 v7 b* x- [        //-----------------------------------------------------------------! U7 H9 t) H: N+ a: t! v* }+ i
        // Method for testing that class has been reached
9 w, P% O/ I* S- Y9 E: A* g1 h        //-----------------------------------------------------------------       
& n* n, q, ]$ e1 Z% @* c. i5 V        public boolean AuthorisedUsersReached()
( B; Z; B0 _- X, b9 M* h                {
# h0 c8 y1 H% a                        return true;                       
- p. M# x7 M! f5 P: K) n% h                }/ v2 W# n, {& ?/ t
               
( U" `, D; q6 ^$ u' ^    } // end of class AuthorisedUsers# G  Y) C8 e9 y- v1 T. V
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
2 g" k; u1 S. u; w6 @Shanghai - 2007
: G4 L( A' a' X" E; n% z3 qAssignment 2
8 F5 Z, L- q0 i! v: v3 oDeadline 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)0 y( [& r( A; E% J! G; b# w
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.
; D  l! ]5 \% ]# V1 IThe staff must be able to:5 ~$ W2 D* t( n$ z
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.7 [1 @- ]  i+ Z
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.( b. Q9 b0 w- Q) W7 F$ g
 The interface should provide a menu so that the staff can:6 h' Z; r! P& h! k% g' V2 y4 Z  l4 b
a) Enter the names of the two Java program files to be compared
8 |# K" i9 M# @- D2 M9 U! U3 t For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
+ |: t# l5 h: B$ d$ `** 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).* M( a( ?9 |$ m/ [* `1 i- i& W2 R
BSA104 Business Programming – 2007: Assignment 2* i* O" q* r+ x
Page 2 of 52 U$ u3 D- Y6 B  l; y( b! P7 t
b) Print out to the screen all the lines of code that are the same
0 l5 k7 E1 |3 I, \ Include the name of the file and the line number of the code being printed for each of the two files5 N& H; f, Q- P& u! u1 q( C
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared  ?! R2 a) O4 e, w6 B8 ~; H
 the name, username and department of the user
' h+ V, Q5 ]6 _) q the statistics of the comparison% S; R' o  `( e8 o
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
! N5 a  V& X& g& e! `' m# } the recommendation for further checking
9 z, |8 }* g! y$ ^4 O- 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
8 i/ g  X! Y' ]- A, X( b7 ^2 [ the names of the two files compared
1 N: I% h2 T- Q4 R7 jd) Leave the program (exit): w. j& {6 o$ [
The ProgramCompare class: (Total maximum 20 marks available)5 B8 G  A2 p3 m# o
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)( l% w( v: q( A9 B* Q3 o7 F
a) provide an error message if the files are not found or there is a problem opening them
* x3 _+ D; ]* I7 z7 F- A; Q  y% m( }b) compare each line of code
2 B+ |9 W4 w: J: }4 ?9 H" @c) print out the lines that are the same
$ O  i6 x- f4 Pd) count the number of lines compared / lines the same; m$ e- q& e" B( `
The AuthorisedUsers class: (Total maximum 20 marks available)& d; k# C2 y9 i5 x
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)
, g/ |! G3 d8 G5 P4. Provide methods to:
5 v  q* W( d* z; L8 b8 Wa) 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
+ P3 n" a! t% e3 x' v# \b) return the name of the authorised user- |7 _0 x& q. I, T+ w! x3 U$ v
c) return the name of the department of the authorised user# |/ n+ i! Y; w, q5 t4 p! K
Individual Data (Maximum 20 marks available)+ z4 _: y. M1 `: o5 t5 B
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.+ c7 j; W7 b; \
Documentation (Maximum 10 marks available)
* S9 Q6 t3 T5 c# M7 B6. 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.
6 n: d$ K/ q2 M# HBSA104 Business Programming – 2007: Assignment 2
+ z- t. v  v4 D8 N" gPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了% G! O& y2 V+ U* f) c" i
不过你要翻JAVA的类库说明。你有下载没有?
9 O* P# f' I! k! b) [查询关于对比的函数。貌似关键字是contrast,还有compare% y. v2 x2 d# b  w3 w& Q6 G! A' _
+ W0 G- D! q8 N2 m; T, E
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
1 C, j+ d2 t  G" p' ^% B痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
* r( O9 _* o8 d可以下载到的 是 jdk-1_X_0-doc5 v) ^) R; B4 p# q  L" i, I
9 J, w7 S& h3 s; [) R( ^9 }
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-18 21:13

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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