找回密码
 注册

QQ登录

只需一步,快速开始

查看: 987|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 * |0 K" }6 _& w$ k5 O1 R y7 j. y/ F. C
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************9 j$ A1 }) s, O' m) s
//  ProgramCompare.java         Provided by: DRS  C$ W% O" |( g6 _; S
//
, n) w5 G3 B# [; z3 T; n//  Program shell for Assignment 2
! ^, y# W  a' V3 t2 w//6 X3 @3 A2 L2 z* w) Z0 m+ W- _
//  Compares two text files line by line$ J8 c) e* _) j! y, P
//*********************************************************************4 m7 k9 t2 a% j9 E) ]7 n8 D4 F. \$ t
- `1 K0 o% {$ H6 y* l$ Y* z
import java.io.*;1 ^/ i" j( e( W
1 ?! [+ n9 f/ J. q
public class ProgramCompare2 i+ A! p+ b$ q0 o' t* C
{8 |; \# T3 b" E- n3 X5 E
        //-----------------------------------------------------------------
: b7 z5 D" V9 U6 \        // Constructor
; d! q/ q; q* M+ V/ R4 u9 \  K: o        //-----------------------------------------------------------------
& Q( H! x; x8 z) W        public ProgramCompare()
6 l+ J+ s1 c3 E7 w, N        {
  L# }8 m' Z1 k9 e% H        }* X' L3 k  Y! H6 Y2 d

8 z6 a: Z( d4 g1 n9 B, y* n        //-----------------------------------------------------------------0 D9 ^" K3 P# z$ T
        // Method for testing that class has been reached
% n4 c% S1 K- H1 g, J6 k6 Z) Y$ r        //-----------------------------------------------------------------       
% F5 ^9 F( X) j4 U2 q
+ l! b) b) ]2 Z        public boolean ProgramCompareReached()         ( o% O$ [  x: }. K2 @
        {( z  g' P3 ]  a& f
      try
  S+ J) Q! V7 [: Y   {         8 l5 [4 K6 a0 y$ P+ s  U
                       
+ X$ Z) i9 }" C& r* \                //********************************************************************) W. [! W' h& v( G# ?7 v
                // Try-Catch Statement is used to handle exceptions - such as file not found ' L" m3 @, G6 V% h
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
" h: d% o! U) `* ^& `0 f8 p                // For more information see page 534 of the textbook
& A9 f% {& v- l" o                //********************************************************************
6 G" o- D) u4 W( a                     7 M( j/ S9 o# s/ d* q4 k
        }- y# d5 j" @4 C$ p0 q
             catch (Exception ex) // Exception caught here and message displayed to the screen ! X/ \( J1 r# Z5 |( [. @+ L6 m
          {1 C8 I7 }1 G; P' z2 ~+ d" G" o
                    ex.printStackTrace (System.err);
6 ?/ U' K6 j) W5 L3 `: d9 x           System.out.println ("Error message goes here"); // Replace this error message with your own          - Z) T+ d0 K: h' [
        }
# y. ]7 f7 s- u2 D) B8 y                return true;
6 {3 p+ I- ^$ T& n/ I( N5 c        }
9 H3 N- h4 [- ~3 S/ E" `* Q: W$ L; a9 }) s7 u; C, w/ U
} // end of class ProgramCompare- o2 y, C: d& f
/ V' }4 V5 T  y* @* O4 o
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
# A; m7 e8 O9 ~1 |4 e7 ?//  ProgramCompareMenu.java    Provided by: DRS; I7 H+ Z) {- g" r: ?. s; u
//+ i3 a4 P3 X/ S6 ^! x
//  Calls AuthorisedUsers.java and ProgramCompare.java
. p. e. U( O8 H8 n0 y5 i9 {; ?//$ q; S. _* Y0 Q0 i
//  Driver shell for Assignment 2.+ o# Y% i' O% \: l. c( X
//********************************************************************
# _. X7 |( V' X, f
* V% F+ N, j5 \) O# B" T0 ^/ sclass ProgramCompareMenu
: ]" J/ P6 J* T& N{) ~  n/ i& E+ c, S: s0 Z+ s" P
    public static void main (String[] args)
# F( P# f0 w/ I- u            {
" F5 f9 b4 Z. p                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
. @+ z0 N. @2 C# S7 i  J4 _8 r& ~                ProgramCompare reached1 = new ProgramCompare(); 3 d: v' D3 P) J* D2 c. v1 b
                AuthorisedUsers reached2 = new AuthorisedUsers();       
; j. [1 s4 `$ ~. T$ F+ [8 c                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
' J* Y: |. l- w+ e$ b, m) o                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
' i( e+ ~9 j, k; \. j8 H! ~7 _        }5 h! ]. E4 K  a9 T6 c
}// end of class ProgramCompareMenu
$ P; D' l% x4 S0 d; S% K& j( K9 p0 w* P; ^# F
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
9 k" L8 ?( V3 S$ @1 M//          AuthorisedUsers.java          Provided by: DRS: U9 Y+ w  U" [! i- P& D
//                , m  o: u. `0 e" K9 c" n
//         Program shell for Assignment 2. C$ r2 }% ^$ H
//
$ r+ S  K2 I! w* `! R/ u( e. J//         Represents facts about an AuthorisedUser$ w- t* v5 @0 f# F0 w" h  k2 |0 }
//********************************************************************
) A! A' o" ^. l. _& k  s$ `0 F1 s  g, T# G: O  P
public class AuthorisedUsers* t& R- i( V5 X) K; I
    {+ T- y! k3 m6 I+ l( f
) s+ u; j# T. L! W; Y0 t4 c+ y: w
        //------------------------------------------------------------------ e. w- x/ @4 V: K# c! F
        // Constructor  ~0 y& f, s7 q4 i# n
        //-----------------------------------------------------------------
- ?: G( a9 r. n$ s9 P) \" N) z% D
        public AuthorisedUsers(). w4 C4 k& Y) [& v0 L4 o
                {
& L0 b3 L! K% R7 S                }
3 D4 S) r" V' O7 C" h
: T) L: A3 D6 [9 K6 Z, Q1 c        //-----------------------------------------------------------------& U" }" A" i$ k& i* C0 v
        // Method for testing that class has been reached- c8 e4 [- v- o9 b
        //-----------------------------------------------------------------        * |0 \  I* }& e% H7 `% _0 v  T
        public boolean AuthorisedUsersReached()
; j8 W, n5 g) W( e* q                {- o  b+ r; @/ m% w: v3 j
                        return true;                        ! {6 t3 [) K' S4 U4 k$ |
                }0 e5 x/ X# B' f1 L# e0 F$ t: q
               
, |8 m9 z  i# ^( Z    } // end of class AuthorisedUsers
: q8 _7 L( I. d2 x7 w//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
; X# _9 J( N: ?5 @4 ?8 Q% FShanghai - 2007
) r/ m8 ~% J; W3 RAssignment 2* v" H& z- N/ r1 Q5 L
Deadline 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)
* ?, b" \$ |1 Y( T" t1. 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.
- S3 B) y) }% a0 g7 n+ qThe staff must be able to:
& O# K5 f. `! h) h  P Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.( p! s# X/ [) s) A  s
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.
: a/ t* l. v2 d6 S$ b; d The interface should provide a menu so that the staff can:) c( ^' X5 Y/ B, ^- P
a) Enter the names of the two Java program files to be compared* ?2 C0 T# o5 t, e8 ]' k
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
. K. X2 }7 G7 b0 {, T** 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).! I; d  @& C" N0 X9 z
BSA104 Business Programming – 2007: Assignment 2  V. s$ C& {( _- w
Page 2 of 5
% Y! n! w4 ]) d' G, wb) Print out to the screen all the lines of code that are the same
& a6 B" R6 H$ A$ A" @ Include the name of the file and the line number of the code being printed for each of the two files
8 ~9 [9 _0 n; e7 `: gc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared- r' J) U  [6 e, E* B, _- q$ p
 the name, username and department of the user" n8 m2 E$ ?0 B0 u1 d
 the statistics of the comparison
0 M" F% A) N$ n1 m1 ^- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different$ z' I! U1 R" F5 q6 L
 the recommendation for further checking
: V- z4 G& L+ n9 i0 f- 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- @6 y- w$ ?3 F1 j+ o9 h0 X
 the names of the two files compared0 |+ [4 v: a% j7 I
d) Leave the program (exit)" V$ E  ~* {% s6 o
The ProgramCompare class: (Total maximum 20 marks available)- j- t5 \. }" Y
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)
) q) Z( }( v9 Aa) provide an error message if the files are not found or there is a problem opening them
$ k8 R" O, Q3 j3 e; Lb) compare each line of code
* n/ d1 M' n2 ~4 o% q  ]c) print out the lines that are the same
0 \2 m6 L8 f: Q+ G' S* n8 rd) count the number of lines compared / lines the same
7 I6 i4 H: Y, H* l# l$ Q$ YThe AuthorisedUsers class: (Total maximum 20 marks available)
# t9 C& |: g( Y3. 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)
0 [3 l% a9 G1 R1 p: Q$ ]" h+ f1 Y4. Provide methods to:& S* r* ~; {6 _" H% `* c
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
% u7 X' D1 G3 t( pb) return the name of the authorised user' y2 m, g1 G# ~; b* C8 }0 x/ F
c) return the name of the department of the authorised user- L/ f( F2 @+ J0 w* x5 x" P
Individual Data (Maximum 20 marks available)
$ O& E- L# W' O/ f5. 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.
) D* R; l8 l8 {Documentation (Maximum 10 marks available)
/ t2 Y1 w: r- W; T! l2 z5 y  f6. 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.
& M( _3 r- U$ P+ ^/ YBSA104 Business Programming – 2007: Assignment 23 w0 H6 B+ w& s/ l
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了7 |$ V/ A4 e6 |7 D7 M) w, W+ J
不过你要翻JAVA的类库说明。你有下载没有?' Q/ u6 \" A+ x4 }1 C9 z8 p9 j
查询关于对比的函数。貌似关键字是contrast,还有compare
6 ?+ S5 w/ \% Z' s$ S$ ?
5 G8 {" B3 j  m7 j[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -8 j+ a& H) }% n0 r$ ?
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。' P" _6 w: ~) k7 s+ P" Y
可以下载到的 是 jdk-1_X_0-doc6 x6 b5 H; D( Y8 m# R* A+ K
, }8 i4 B' ~. g2 w4 @0 F6 L
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-1 13:08

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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