找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1075|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 : V; y1 ]( m+ W8 _& m1 T' |6 e! N- p1 }1 q4 W" 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 | 显示全部楼层
//*********************************************************************
+ j: J: I5 Z6 K5 ^0 C: k//  ProgramCompare.java         Provided by: DRS
1 S; H/ ^: V; q//
# u- u; l& l6 X+ W//  Program shell for Assignment 2+ [2 v1 Y9 W1 N' k8 j1 Q
//
0 _/ g6 j, U4 g9 t//  Compares two text files line by line
7 E/ S) \3 ]. z7 |4 S% I//*********************************************************************
0 R0 D6 d8 J- k' c/ |1 X& E  O5 T2 ~1 h3 {2 x
import java.io.*;
  c6 }8 {- W: @9 O1 m6 [* O- l
# {2 J: h( D7 t) c- `( Ypublic class ProgramCompare9 x* I/ S+ b# v( S& b' R: x
{1 p+ v+ }, b4 T9 R
        //-----------------------------------------------------------------
! u' Z9 I* }& c        // Constructor
' r# T( r& C) b5 }% J' D  b4 b9 H9 m        //-----------------------------------------------------------------
$ j0 ]1 n+ H- E9 W/ A        public ProgramCompare()* `8 Y# K, D7 l1 K  B/ l  C! [* Y2 R
        {
% Z$ @8 c" v, `+ z2 S        }* \1 i# y% S* t0 t, v% L( F. I

; P+ {4 O- L) G2 C# A/ u- D        //-----------------------------------------------------------------3 h; R  R# S& j. x. A
        // Method for testing that class has been reached+ o  U) u. T0 {
        //-----------------------------------------------------------------        - @- {5 L# J; @1 L4 D! q6 s3 y0 S

- l& ]; r9 W* h        public boolean ProgramCompareReached()         4 H5 S6 u8 o- f
        {0 V1 i: I# l$ e0 n) l4 j" y
      try
4 Q& h3 Y) W( o3 \1 o   {         0 D+ i0 B3 m% K% c( h* k# {: d
                       
$ S3 b, ]( H0 T9 h                //********************************************************************* N( `- [. R. d+ Z7 b4 l
                // Try-Catch Statement is used to handle exceptions - such as file not found
' V4 K& ~2 u  T                // Reading the files will need to be placed inside a Try-Catch - just like this one!
; L2 u( m3 C3 w% A: A* Q                // For more information see page 534 of the textbook
6 `6 b7 }: B2 b2 x/ X1 ?                //********************************************************************* l1 I* M: k1 r: l
                    
9 z( v" u1 q2 c2 }, G8 V2 S        }
* }, P$ d9 R9 `- R             catch (Exception ex) // Exception caught here and message displayed to the screen % s* s; B& [8 Y2 c6 z4 [
          {" C, |* x1 T& q3 o2 ^, x
                    ex.printStackTrace (System.err);3 E% `6 V" Z! F& C5 y9 x: U. V
           System.out.println ("Error message goes here"); // Replace this error message with your own          - [) Y. k! x" P+ c
        }9 l( |& _  W3 g: W8 ], n2 j  B
                return true;2 G8 W; O$ }' s
        }
+ V8 I7 S- a5 Q. F3 _8 ~" F2 }0 M; {1 b# F- F# x: ^2 ^
} // end of class ProgramCompare. q' M/ y+ c/ S  G/ Y

- }0 Q- i- P& J: }* L$ E" r' M//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
7 K" a3 B4 f- _, }2 a' B//  ProgramCompareMenu.java    Provided by: DRS
2 X) _* J! w' @1 }5 d5 T//
8 @; M2 v4 W6 ?3 O; [//  Calls AuthorisedUsers.java and ProgramCompare.java, y4 g* H7 T# O) p& Y+ M7 a3 S
//
6 g  M% `' L7 f1 N! a( D//  Driver shell for Assignment 2./ r' F* _( l, s' p' p
//********************************************************************
2 H2 _8 `9 }/ r1 z) T- z8 i  _' x8 g3 ?2 }4 S! H6 H$ m, E: K
class ProgramCompareMenu( T- O) j4 a$ n: c3 I
{
9 D4 y1 u$ m1 Q( k) X3 e1 J7 O7 B    public static void main (String[] args)4 [3 r! l; p( e* C
            {8 H9 ^( G1 D$ l" w4 |$ t
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable& m$ p% s; `/ G  s: d
                ProgramCompare reached1 = new ProgramCompare();
7 h" E$ q7 K* x. M  K                AuthorisedUsers reached2 = new AuthorisedUsers();        7 ~! i1 z& {4 y* [' }2 R
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());3 m! {) ]) f8 X/ c
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ) \# T( l) H( q+ @
        }# u( \8 l7 |* F. r3 A# Z! m
}// end of class ProgramCompareMenu
8 ^' R3 ^* [1 j0 x* F; R. b
7 T3 F7 _# c) G* s//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************3 _: k# w- n( D* Q7 X0 K8 `
//          AuthorisedUsers.java          Provided by: DRS7 |0 N- e# l8 S  T9 H- E
//               
/ D% [/ h5 ^5 s//         Program shell for Assignment 22 ?% ^- R+ J, ]
//
$ \( v8 v* f8 S$ p//         Represents facts about an AuthorisedUser7 x- z' ~) T: U4 g: e* s, r$ m9 r; c# e
//********************************************************************
5 ^& k$ H5 H, ]4 O6 x: K
/ r+ H7 r) M4 ypublic class AuthorisedUsers
9 c; o' j4 X6 O/ H7 K; I: E% F    {
" C( B1 ?0 s: ~" C7 b  k% U; }, W' r; G
        //-----------------------------------------------------------------
+ n; i0 h2 }) }+ _8 o; c        // Constructor
  l4 b: H5 j9 g' k        //-----------------------------------------------------------------
2 W1 |, E; E8 o- s! |
7 J/ {" O4 A  w        public AuthorisedUsers()
/ S: n4 U8 G$ t% i# c                {% k) e& B3 S  S- n! Z: m
                }  l/ E/ ~5 \/ C! i
+ v* S& r9 f! U) g, Z9 R
        //-----------------------------------------------------------------
, |  v9 z. }4 W+ o8 o6 a        // Method for testing that class has been reached
. F3 W( I* K3 n1 e9 p/ [& X        //-----------------------------------------------------------------        ; n$ _; q3 E) |% X) M  Q
        public boolean AuthorisedUsersReached()" g: ?+ p# G0 [& E2 G3 M
                {4 m! Z5 T" g6 z9 u
                        return true;                        ' [& S, O6 `" P1 @# D& p7 p
                }  G. J$ d5 c2 j- E& C
                : H# e% ~) l; D1 H& b% ~
    } // end of class AuthorisedUsers
& \+ A  n+ j# f- e$ h//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
; t$ R* I5 e/ B5 [. @/ SShanghai - 2007
% [% E/ u; U4 Z5 xAssignment 21 P& e' Y- s. V- ^& ~9 [
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)
1 p+ T* D2 ?0 n& O+ y  ^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.+ I( X6 l! ]4 {/ _* i
The staff must be able to:+ N' w: C5 _# I
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
/ x% X4 I, r5 C( L/ Y1. 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.
; @; P6 `' i3 U8 G The interface should provide a menu so that the staff can:
- A, l+ z6 ]2 w" p& i1 Ia) Enter the names of the two Java program files to be compared9 r4 ~, }# X* J* t  ?
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
( ~9 S+ T# G/ {" S9 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).
5 y4 m: J# F- {BSA104 Business Programming – 2007: Assignment 2* t& j3 s) m4 x8 i3 X
Page 2 of 5
% B! [" e9 q4 Db) Print out to the screen all the lines of code that are the same# p; ^0 P9 t+ S5 r$ _1 d
 Include the name of the file and the line number of the code being printed for each of the two files' g) [6 m! S; u7 x2 {3 y% v) \
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
6 {4 {: Q  @& R; Z- N. u  U( C* g the name, username and department of the user: z/ v; a3 f! d3 j2 ^+ }4 K- m: x
 the statistics of the comparison! `7 t0 a6 s: R1 W, |0 x+ w' R
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different; q* ?( Q  @- A* @4 I7 a) H
 the recommendation for further checking/ j- r( B( X& B5 `0 X' p
- 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( n- O; R: J/ F( y
 the names of the two files compared
8 a  {  e$ u$ A9 ud) Leave the program (exit)/ h6 }2 o8 ]3 ^, r& f, |" [
The ProgramCompare class: (Total maximum 20 marks available): L" ^& f6 x* V; I6 G1 t
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)- ~# n/ {: K( }- Z; g- b" z
a) provide an error message if the files are not found or there is a problem opening them
1 M" d0 A  y# V! ~, J+ K. I- `b) compare each line of code: D, `7 A1 E2 x7 M( @
c) print out the lines that are the same" S& ]/ U; c5 G0 D1 h. c
d) count the number of lines compared / lines the same# C9 J: \. c2 O. s+ z; w2 y
The AuthorisedUsers class: (Total maximum 20 marks available)
3 ?% Z/ y$ }8 ^# u& U, X' P' c3. 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)
5 k, w3 F! ?3 X7 W0 D' w4. Provide methods to:
1 |8 f1 M% F8 j* @' a8 qa) 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! k3 k0 l. }( N, n
b) return the name of the authorised user
3 S8 R3 T0 c4 ?0 E+ gc) return the name of the department of the authorised user8 `& j% `5 V) v* W
Individual Data (Maximum 20 marks available)
( i  S1 J% T, N1 l2 t5. 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.) E  n0 g/ o& v
Documentation (Maximum 10 marks available)+ }0 R1 {; D& m* i
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.3 H: d1 ~$ m; |* p1 o: J
BSA104 Business Programming – 2007: Assignment 22 ~( n# y7 n* v7 B: x) U
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了  M: {# P! E3 S8 U2 r; a
不过你要翻JAVA的类库说明。你有下载没有?" r# |8 b1 \' s
查询关于对比的函数。貌似关键字是contrast,还有compare
! \& l; ^) U" y  h" p( y' L$ [
- i* b  W5 q4 w% F[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -4 o! ]# o3 W2 ~! _0 h
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
" u) A- M" F+ ~可以下载到的 是 jdk-1_X_0-doc% u/ F5 l" [% }1 t) X3 ~# j
3 {  I/ @/ ~& _8 @
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-26 17:56

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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