找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1156|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急7 }' x, X# U& G8 z3 G9 x1 X ( f0 H' p; Y& i" l
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************3 l* {) R% ^' C2 @
//  ProgramCompare.java         Provided by: DRS; |# C- o* F( ~3 I# T+ n) Y# Z
//
2 |: P) S6 e' b0 g//  Program shell for Assignment 26 j; s1 F$ z1 E( ~
//
. x- H8 r! q( k* U8 _+ Z//  Compares two text files line by line
4 n1 F0 e2 F6 `8 W3 y& ]% y! w//*********************************************************************/ }2 Z( s5 d( b3 W* z* `
& Y# ?* p% G+ ~" l
import java.io.*;& D  E+ c4 G, h4 \& L  E
( E& q$ G* ?* S4 k9 R0 z
public class ProgramCompare  H# a+ E1 ~% [$ Z7 g/ w: Y9 @2 X
{" G; T! Q+ y4 m1 w3 f
        //-----------------------------------------------------------------
# D$ q$ ^' y& q2 l: l) _7 z        // Constructor
+ L4 }, T( J& u: U        //-----------------------------------------------------------------
0 W6 }" A7 U2 A1 u2 S0 H7 i        public ProgramCompare()
7 R& T4 \9 _) B- l" S5 k1 U        {
) R# U& `  [( `1 D        }
& Z- J* M9 a0 f  t; h0 x
! y: h& W; I0 k2 p3 R7 n        //-----------------------------------------------------------------) H4 h5 y+ M8 q- d7 J
        // Method for testing that class has been reached  ^" f0 d* o; z
        //-----------------------------------------------------------------        # W- G; v3 i$ E: d: K

2 E) s0 M3 `! N# A# M        public boolean ProgramCompareReached()        
9 }0 u/ a- n1 `! k0 T' @7 |        {0 M4 P- f4 s+ y' J( G# O
      try
3 `. Y+ @- u& E, P, @   {        
0 \0 }( S; l1 j8 {, [. g7 r                       
, s2 X; _! Q' D/ T7 W3 `; G                //********************************************************************
. h: }6 y# L% ^" u1 Q" `                // Try-Catch Statement is used to handle exceptions - such as file not found
' S/ l5 w2 X  v3 D- U                // Reading the files will need to be placed inside a Try-Catch - just like this one!" `; q$ U# `  X/ D' e
                // For more information see page 534 of the textbook
' A. g9 _! j4 l; D                //********************************************************************
: s# V! |" L3 C9 u5 u# A5 W                     7 t+ d5 \5 F* F+ [/ k# m
        }' r8 L* o9 g: e8 n) f% |
             catch (Exception ex) // Exception caught here and message displayed to the screen - M6 h& ^& P  F" p8 ~& [" u- O; {
          {; Q1 C1 @  z; P, c2 c# c1 i
                    ex.printStackTrace (System.err);
5 [7 v3 D7 B* Q* b/ f0 ?           System.out.println ("Error message goes here"); // Replace this error message with your own          * e! L0 W9 _5 ]
        }
1 w& N: o" Y3 y/ z4 l9 ]* Z  [                return true;
5 i* S9 G& Y1 c6 i        }
% N3 k5 `: j8 E9 w: W) n: G8 V8 b% G4 V& Y% O  E- u
} // end of class ProgramCompare2 {7 ?3 D1 }7 A0 j1 z

: l0 X1 T3 N" P//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
3 l' }) ?8 }) t: P6 q: {//  ProgramCompareMenu.java    Provided by: DRS
; b+ G0 h  I$ d5 b5 Y//
# X1 C! @, g) N# ?) V//  Calls AuthorisedUsers.java and ProgramCompare.java8 S* |  J" l4 T4 ~
/// a% M8 f: O8 p4 K
//  Driver shell for Assignment 2.
# G/ n+ U8 a/ U3 S8 o: O6 m; Y7 \6 }//********************************************************************
2 ]0 j& S3 o1 }$ ~+ b+ ^; v: x8 V- u% h& |$ a! U* `: U. K# p& c) r
class ProgramCompareMenu
8 `/ J. s2 z8 W' A8 Y* l  S: j, f{
& d7 G4 t( M' F/ k1 |* g2 W    public static void main (String[] args)& u# g/ `& z& d, x0 c
            {
7 b* a* `; l8 q6 w" `3 g                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
0 \; [8 B* d2 c' l, V1 z7 q                ProgramCompare reached1 = new ProgramCompare();
% t" G2 T) Q1 }- {3 F/ M) I. n                AuthorisedUsers reached2 = new AuthorisedUsers();       
# {; L& \4 }9 R$ q                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());. T9 q# {0 u$ W/ e5 b: Z, q. Y. N
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        5 c2 ^, u+ C9 ^* f# m; U
        }
3 o# n' \# V) q# d, v9 X% @}// end of class ProgramCompareMenu
, C- A5 b+ C! j. [- M4 a
: F8 L6 l  ^9 G. F  T7 J//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
8 E* M' s, S9 w; B//          AuthorisedUsers.java          Provided by: DRS1 z3 G. L* f) m1 m' K( X
//                3 d! k: T* N# @  J) y1 o) w
//         Program shell for Assignment 2
% C% H: e6 _& b1 L) _//
& d! T- N) V( ]' W2 z3 L# M//         Represents facts about an AuthorisedUser
; l7 U8 o+ e9 R//********************************************************************6 c+ c0 L8 d9 O$ z* c* x5 L+ P

( y5 t. w6 n" M' l# m" b' opublic class AuthorisedUsers9 M9 F1 r3 ]" N# L& h+ B$ H6 q
    {# g$ ~) I3 K0 F; D

- j- b* G" \# J+ G        //-----------------------------------------------------------------
) H5 J1 y6 m/ B        // Constructor
# a; {, g. s* }* ?+ y& Y        //-----------------------------------------------------------------: r0 D( X4 r1 }
" b0 N. S& Y5 j6 `7 `" C- Z
        public AuthorisedUsers()
3 Z  C8 O$ F: J                {
1 Y/ K3 `% K  q, }                }
! e" r2 e, ^. E7 f+ C( K7 F% x/ m
* e& N; X' k4 ]5 F* n        //-----------------------------------------------------------------% v% O! w+ `: \! P, Q2 v! B$ `
        // Method for testing that class has been reached( Q( x2 {- {6 O% J; |
        //-----------------------------------------------------------------        9 H4 `# j! }0 b( _3 Q) ?5 H
        public boolean AuthorisedUsersReached()
+ Y9 F: t3 ?0 `; \                {3 b! Q: [" Q8 f" Y* m; h" Q
                        return true;                        2 ?3 J- r# |6 `4 A7 b
                }
5 W* Y. S3 W1 G; n               
. U8 b* K1 U" s0 w    } // end of class AuthorisedUsers
' k7 w( c1 N  B; X//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming1 Q$ v  h' @4 b" H1 N
Shanghai - 2007
- [+ X9 k# O% R" _( F& YAssignment 2. v: P* c* g& T% C" e( A* I8 U/ f
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)' n6 m3 X7 k. t" y" h6 J# b* k
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.$ ?: n$ ?& o2 }# [2 z' |
The staff must be able to:0 |# K' t2 j+ |( r1 g
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
& L- D- w# V! b0 ?; V4 o' P1. 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.
% B6 o# \+ D$ \ The interface should provide a menu so that the staff can:+ F! J$ e( F2 c/ U  L8 d3 ^
a) Enter the names of the two Java program files to be compared
! Y3 k/ ~8 a& c8 a For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
2 n+ _- P4 p) O** 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).+ |6 O/ j. [; A) m3 o7 G. V7 n8 ~
BSA104 Business Programming – 2007: Assignment 2# o2 p. Y: k- _
Page 2 of 5
. h7 U' r% h) d" S/ Tb) Print out to the screen all the lines of code that are the same
0 }0 o5 q" v% Y7 d) i Include the name of the file and the line number of the code being printed for each of the two files/ g3 P8 Z0 R8 k2 t( Q
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared2 z, a  [% L8 P; J' Y
 the name, username and department of the user
8 y- q. j2 @9 q2 D' k. x6 W; l the statistics of the comparison6 @/ U1 t+ g9 B5 Y/ X! f* @
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different$ Y" _+ C" F" H1 P5 O0 H
 the recommendation for further checking
4 \  ?2 c/ ~* E; Z& ?- 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
* C1 q; `: l# Y3 _+ R- Y% | the names of the two files compared
- m3 Z/ O) O' e; F6 @7 c  x) Jd) Leave the program (exit)
# y8 n5 t/ B7 C/ r+ c$ w7 UThe ProgramCompare class: (Total maximum 20 marks available)
3 q1 O) i# Y4 l' {; j8 ]4 P" Z2. 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)
4 N: z6 t0 i% P; C% [+ c! ba) provide an error message if the files are not found or there is a problem opening them
6 i# u$ m( m& O+ G- F4 Kb) compare each line of code# m% n& O7 A5 X" Q6 p
c) print out the lines that are the same
; N0 G* @& z# L8 P, V/ rd) count the number of lines compared / lines the same: t- A6 O  }7 v7 C* v0 ?0 _1 S- A
The AuthorisedUsers class: (Total maximum 20 marks available)
: s  k- S! r1 v6 I3 g$ |$ a3. 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)
: h5 g' Z6 ^6 ~6 w4. Provide methods to:
# X$ Y- E) c: t! M- 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 match0 k' K- C4 \7 S
b) return the name of the authorised user
+ l9 F( y. D  e- f: Lc) return the name of the department of the authorised user
2 _. }1 y; b! O' n% w7 iIndividual Data (Maximum 20 marks available)4 }8 G* b: O! \5 z9 _! _% I# J
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.
: i  O5 o0 ]$ d/ u5 O7 PDocumentation (Maximum 10 marks available)  Z6 p+ n" z% f: i2 b& n
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.% A3 F7 e3 M9 ]; i
BSA104 Business Programming – 2007: Assignment 22 j( A* |" K4 m
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了8 y! w0 U$ H1 S% w, a4 ?
不过你要翻JAVA的类库说明。你有下载没有?; A$ R' Z; Y" g7 j" e5 d* p1 K
查询关于对比的函数。貌似关键字是contrast,还有compare
- n4 Y. P8 r$ `6 y$ @2 J
/ M8 S  I% t* f, z, V5 J2 R7 q[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
8 `3 c+ t' u% H' E& Q+ S! h痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
% h( D2 R0 ?6 ?! o; u可以下载到的 是 jdk-1_X_0-doc, ?; H1 @# m/ r; s" m8 r; F

' Q0 d+ Q6 N  b& _[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-3 22:41

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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