找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1681|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 / Q0 M& X2 ]$ r3 `' ]. s/ z3 E% Q) Q* o# o- S) ?4 i
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************8 U1 a1 I7 ]7 j4 e$ E
//  ProgramCompare.java         Provided by: DRS' Y4 r; c( O+ K4 d4 }; k
//
0 Z- N% j4 N5 v0 O' a8 @: {: T//  Program shell for Assignment 2
: p9 v3 J: z3 x//
9 H% C5 t; |* ^3 a2 m* K//  Compares two text files line by line
5 K1 c, H/ X+ t; b) @9 N//*********************************************************************" M  i  \. S( _$ z4 r

" F+ H& @# z8 Himport java.io.*;$ r/ Z/ X/ |8 j
  J7 C/ u  w- r! s, e/ M! f
public class ProgramCompare
# i; W$ X. M# a: A( z9 s2 P/ P6 s. k{
; i3 d9 E: i* s8 X7 G8 W        //-----------------------------------------------------------------
- N8 r$ Q. O# C+ l1 \        // Constructor
9 t6 A0 g8 i  R$ L2 @; k        //-----------------------------------------------------------------
5 N# P3 [: ?- Q) D6 I# |        public ProgramCompare()) i( Z+ e8 c. v8 L7 b
        {
* A) e5 d1 }  g0 k& _' ~! D- P2 {        }, f8 u6 r# T; F/ K; l

  [% \" m- J% w7 C+ a        //-----------------------------------------------------------------
& Y  R0 `. S% w% u" O        // Method for testing that class has been reached
- [# H  E+ x& c4 y3 z  V; t( F% x        //-----------------------------------------------------------------       
9 |2 O( F9 I$ H% A
, O- Z( Z& d; t; k: O7 M: V9 ?        public boolean ProgramCompareReached()         3 r- E$ }0 W. o2 ^" N
        {/ |5 Q! V" Q& D2 d
      try 9 d. \7 h* U' K( C& }7 G
   {         0 [: x+ q* P( ^
                       
" o6 }( r7 p+ g: ?& t                //********************************************************************, v3 [6 E* L( A1 V( [  I% R
                // Try-Catch Statement is used to handle exceptions - such as file not found
; T& ~& h" r$ M, o0 l$ G: ?# i                // Reading the files will need to be placed inside a Try-Catch - just like this one!% h4 W# h* N( }! V# b4 ^# A
                // For more information see page 534 of the textbook0 i/ d; {3 H2 f3 L6 v$ ^
                //********************************************************************' d  c! R+ v' g6 M: V) e1 \( V- D; T  V
                    
, Z% B$ z- H9 M4 A" j1 g2 \# |4 x        }
. m0 m9 F# U$ o             catch (Exception ex) // Exception caught here and message displayed to the screen
7 g, f  A* e1 \5 [, v          {
+ H- o, w+ P' P. L+ T" w  p                    ex.printStackTrace (System.err);- t# ~/ ~3 i0 |& v0 I
           System.out.println ("Error message goes here"); // Replace this error message with your own         
7 _' u! M( O; q( I        }' ?4 [* ~# }! f) f+ y1 {  }
                return true;6 a' g/ C, M! x' R! q& a/ f
        }
( }/ C2 K4 ?8 x. d
- \- K. e3 q  H  v& I} // end of class ProgramCompare; x  Y) o( o' u" _$ M1 U% i
) t8 e# b) U) O) ?
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************6 N1 p+ e' R6 Q+ C; B
//  ProgramCompareMenu.java    Provided by: DRS
# S! d) R! @" o2 k" l//
7 r- N. ^/ P& U1 V$ W  [//  Calls AuthorisedUsers.java and ProgramCompare.java. k8 [) B8 T8 _4 x
//: \3 X: E; s" c: ~& W# M
//  Driver shell for Assignment 2.
; L) b0 L% |  E- {& L//********************************************************************
$ G: {- m8 s9 N/ A) \7 C! N8 f+ p5 I$ |, V
class ProgramCompareMenu
3 S. T: x4 P0 P{
) F+ U" E$ `0 v- x! v- q- r# ]# ?    public static void main (String[] args)  Z, F+ `3 {: N, U. b# f8 e
            {+ u9 s3 b; H: `
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
& O* F' ^9 R" h& b                ProgramCompare reached1 = new ProgramCompare(); 2 J% j8 x" m& o4 n- p
                AuthorisedUsers reached2 = new AuthorisedUsers();        4 K7 ?5 b* X8 H
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
* [) K9 F, }8 n8 A3 z                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
4 p. q& I4 r; M* {0 G  s        }! v1 I5 J* X( _+ F
}// end of class ProgramCompareMenu0 h  C, C+ ?. q9 x% P
9 q' a6 E" b: z6 H5 K, b
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************# n0 F* F3 A/ _; ^! x( X* o
//          AuthorisedUsers.java          Provided by: DRS! {5 T7 o7 ?4 a% J- v1 t8 u
//                % X- n0 R* l2 \
//         Program shell for Assignment 2
9 o3 P  ^' S- o+ ^2 r3 N" O//
) q4 V  r" }% Y( ?) C//         Represents facts about an AuthorisedUser
& b' w2 u; V% E2 ?$ z7 v//********************************************************************+ K+ I. W) u, R( S% y

' f) I1 K; X3 spublic class AuthorisedUsers. F  |+ W8 y) O3 l+ A& Q: e, f
    {, ]/ x  g* f. F; j3 v! h! k

* [; q% h4 D' A; O& e5 B0 C; K; r        //-----------------------------------------------------------------' n  ]  A8 a9 _, }3 s7 `. l* `
        // Constructor
5 ?+ C3 |8 Y6 h9 d1 X+ W& o" I        //-----------------------------------------------------------------
6 O0 A" x  _! _! m
7 [; f& m( f/ t  o        public AuthorisedUsers()" R# `4 J/ {/ \) k
                {
" [1 t% [8 X# v) T                }. w7 s; W+ {3 [

* v* f1 _0 |( S9 x" Y# s2 l        //-----------------------------------------------------------------3 o# l/ k; W, {; g* P! J+ m
        // Method for testing that class has been reached: W+ Q3 A2 z3 P- a4 ~* F
        //-----------------------------------------------------------------       
+ ?; X) ~' k0 s1 k5 Q        public boolean AuthorisedUsersReached()
* n; [$ l! _: F- E8 ?) y* l                {- ?4 a1 w: v* j! f% I. G
                        return true;                       
2 q% w2 ]# X  B+ B6 H                }
# x1 j$ O: \  \+ T% J, W                ; C# u: r( L+ O' u8 H
    } // end of class AuthorisedUsers
8 J* n1 _: H, i+ T4 V2 E//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
) m" ^! j. t% d# N1 N3 D( cShanghai - 2007
4 |/ _* g, ?5 i5 O! k! aAssignment 2% m: S' q0 I! K+ b7 s6 q$ ^% e
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): E' G4 k0 Z! b! }" U2 b
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.7 z: r7 z# x; X0 w- T/ c
The staff must be able to:: l! M4 S: p0 H9 U2 U/ u
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
  R, I1 e$ S* H$ N; y8 }0 C1. 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.
* `0 f$ u3 }. t The interface should provide a menu so that the staff can:
( p  W# f+ W4 u, U- x0 a# G6 ra) Enter the names of the two Java program files to be compared
% I3 W9 }' {. O5 s7 e+ }+ Q+ s. Z For this assignment, it will be assumed that the two Java program files are in the same folder as your program.$ t2 B0 [) Y+ C3 N, W# W
** 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 f% s( h+ Q" c! Q
BSA104 Business Programming – 2007: Assignment 20 {0 _+ D% {2 x+ p3 f6 Z( s& j4 q' G
Page 2 of 52 Q, K- S% t5 B7 @' c$ E
b) Print out to the screen all the lines of code that are the same
* Q' A6 Q1 l$ e6 i: r7 v Include the name of the file and the line number of the code being printed for each of the two files
: E4 T- o9 {( @* pc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared% F4 A/ q7 K$ h1 u  R4 N
 the name, username and department of the user
! m! |1 l5 h8 F the statistics of the comparison
& X; b) P2 r3 P9 c- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
1 {( z% r# o2 j0 \ the recommendation for further checking
* k$ S( q/ h  C4 b! }# g3 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
: n+ D6 @% l* ]* p' K( V the names of the two files compared
5 Z3 P! ]/ b3 r3 Q5 fd) Leave the program (exit)8 E& z* G3 w* Q$ ^1 b) i& r
The ProgramCompare class: (Total maximum 20 marks available)
7 B' v1 U8 n2 A; C0 j2. 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)
) @, K/ w3 `! pa) provide an error message if the files are not found or there is a problem opening them
( s* J- E: E" ]  w0 i( h8 F5 ab) compare each line of code
1 }* J1 D' V! J% oc) print out the lines that are the same
* X/ i6 C1 F, C4 C$ x1 z" ld) count the number of lines compared / lines the same
3 c% X+ A. i2 O: J! ?The AuthorisedUsers class: (Total maximum 20 marks available)4 N" T" y- J+ P7 K* p; d" D: 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)
+ u' [& `9 T5 m" \5 b4. Provide methods to:  W" M  y& ]0 Q& a
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+ Q/ W! F8 Y& [$ F6 g, G8 m
b) return the name of the authorised user% O5 T4 P3 ?* h" U* O% L1 `
c) return the name of the department of the authorised user
1 |& R' u/ o: y% c, u( z) N; p" GIndividual Data (Maximum 20 marks available)
5 @" c- d7 s5 ~( j0 a5. 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.
1 n. n/ K. I+ U( t) n1 eDocumentation (Maximum 10 marks available)
1 u' _! J" K6 [& k" J6. 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.& t: J# h$ ~- r
BSA104 Business Programming – 2007: Assignment 2' t8 T- M0 g% q8 _8 k/ }
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
% C4 K2 g  }# {. Y( \不过你要翻JAVA的类库说明。你有下载没有?+ \  g& G2 M" ?
查询关于对比的函数。貌似关键字是contrast,还有compare
$ l& w7 G% b3 k+ K- u2 I- J& d" O1 y
& c# E' {1 u9 t* {3 E[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
; K4 g7 D- \7 I* H; ?痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。8 j- s7 t# W, U/ L
可以下载到的 是 jdk-1_X_0-doc' f2 p, _1 K  b" ^8 R
5 i' v3 M" o( u$ a
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-29 05:16

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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