找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1425|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ) k( ^6 ^7 c! U% [ 1 d& E7 A+ w) E8 X0 }
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
& e  j  A& ]7 P//  ProgramCompare.java         Provided by: DRS
/ z3 r; ^$ F4 i4 w//- X' e. H( H; D
//  Program shell for Assignment 2
% n6 p0 C8 E: r//
/ Y& t* x+ `$ v! J//  Compares two text files line by line) |" P/ B4 f7 t+ W; l
//*********************************************************************3 p6 D3 y# \+ A( }% L- p# L
5 u7 Q9 H7 I/ m0 M
import java.io.*;
% s1 u/ U0 S3 Q2 E( d5 p) I1 q  k, @9 k. P4 }- C3 j" y; @: J
public class ProgramCompare
7 ?4 D0 q+ j/ l$ J: r. X# d{
% \/ l$ J( J+ l3 A! n3 j3 e. ]/ V4 [        //-----------------------------------------------------------------
, n  l/ j8 _4 ^8 z) \        // Constructor
5 V& S! x& a5 R) |0 D" V# k5 ~        //-----------------------------------------------------------------
% Y8 |. M! {( v. z# a* \' [! B1 H        public ProgramCompare()) [8 D& [2 n; |: R
        {( @. d9 p( A- N" N7 |1 V' A
        }
. Z( B6 F" M' n' Q* K$ x! ~4 Q& v5 z4 g% c
        //-----------------------------------------------------------------3 R5 c/ _! X. @: I* S0 y% b1 K  F; {  k
        // Method for testing that class has been reached
/ n6 `! b3 ]# k6 {        //-----------------------------------------------------------------        & ~( n/ L2 K' L1 m  d: j

! _  i9 B, m+ z8 g- f8 \        public boolean ProgramCompareReached()         / l1 B9 }+ q1 J* J" {
        {
( k% A( P" G9 t, ~      try
7 L  ]7 L; U( N$ J0 Q. f0 c% m   {         1 h9 h) j" R# ]! i* Y& t% k
                        : t0 `4 K9 B9 ~) r
                //********************************************************************
" F% w/ E8 N) k/ \& p+ \                // Try-Catch Statement is used to handle exceptions - such as file not found 6 o) _4 r. X4 K, B% d: {* r
                // Reading the files will need to be placed inside a Try-Catch - just like this one!0 I$ \/ {" P2 X. V
                // For more information see page 534 of the textbook& \! f6 b$ S: f& W& B
                //********************************************************************: i$ V: Y0 A0 B- @
                    
9 Q! Y& l/ @( w- H        }( D, w7 E2 ]5 k+ ^2 B; g8 f
             catch (Exception ex) // Exception caught here and message displayed to the screen
1 q6 U  {. V/ [+ w1 ]: P. \# U8 i          {
" z" H. x& n  y1 s! @# x: f                    ex.printStackTrace (System.err);
7 I7 e" j/ b4 y4 ~/ m           System.out.println ("Error message goes here"); // Replace this error message with your own          : i  k8 L9 T. P( Q4 G; i8 K
        }. q7 r6 @9 e# C
                return true;
/ U. E  K) |% S  G/ ^/ s( u2 V        }
% ]8 s- g5 I9 z2 e9 k
3 ?1 Q& x/ n" \6 \8 B} // end of class ProgramCompare
4 H3 Z$ V: q. T" D, N
* ^/ u- E' Z" N8 T& e0 _- R- n//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************" X: l' R5 N2 I8 T7 b
//  ProgramCompareMenu.java    Provided by: DRS4 C0 C8 o5 t# W6 Q; s
//* Z2 D3 e; k/ R6 I6 d+ w) [- C* ~
//  Calls AuthorisedUsers.java and ProgramCompare.java/ I3 |6 Z& |2 ~$ S4 T4 j' E; J
//7 o# N$ N  t) v# v1 ^$ m
//  Driver shell for Assignment 2.
4 F$ Q* g  i- G* U. w//********************************************************************) k. s& m9 z0 F* K

0 D+ C1 j* i) |% G% U- `% c- U7 bclass ProgramCompareMenu, x7 Z$ n( x( r! O3 u
{6 e  C6 s# g4 m  s, P& L
    public static void main (String[] args)
7 P/ Y" x' d; y; z0 n( j2 s$ U            {  X6 S" h, b7 R$ L
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
# @% D% c# \8 \                ProgramCompare reached1 = new ProgramCompare(); 3 j: H5 ~2 U& H) c
                AuthorisedUsers reached2 = new AuthorisedUsers();        + \* ?; ]7 k3 [2 R4 k2 h: G
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
& S# Y6 P9 B% ?' F3 K# x6 E( l/ R                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        $ y9 n& X0 m1 e9 z) e& u$ @1 I1 o9 K
        }8 p( M; F/ |2 u, c
}// end of class ProgramCompareMenu0 {7 U) }" _+ s( |2 W) U8 T

. L5 k4 m. s7 E. |. m, E/ T  C//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************. Q5 I1 ?9 f: ]1 Z) a
//          AuthorisedUsers.java          Provided by: DRS0 m8 q- o7 F' N4 W
//               
/ M& L" N/ G! n+ B/ u6 T//         Program shell for Assignment 2" k# ]3 x' }. O4 Z
//. K' a: |1 W( W3 ^3 [2 z0 n' r3 B
//         Represents facts about an AuthorisedUser
+ q* J. P+ c$ K' t//********************************************************************
: f6 d& m! M& u7 z! D' S: S4 C4 J2 i& s; T* A8 G
public class AuthorisedUsers6 L: ~0 \5 |7 \- [8 Z
    {4 p" a5 A! F' S# C7 `1 w) K/ t  I
' w. W/ P9 G+ M& [+ {
        //-----------------------------------------------------------------7 [7 O! e1 w7 x8 G3 g1 ^
        // Constructor
. x# X7 |* w* q' @        //-----------------------------------------------------------------5 `: K/ y6 V8 o( J8 j4 Y
2 Q! h3 }9 k" h) m4 a
        public AuthorisedUsers()
$ t0 [: \& o7 l' x  L8 L                {- Y" m# M1 i- o+ i& p4 B
                }9 V2 S7 I5 S. n' o6 v
* g7 P" B7 x% d$ P
        //-----------------------------------------------------------------
) i0 [. `6 H" h; y# u3 U4 n0 [        // Method for testing that class has been reached  f* P3 _7 z& l6 l" P
        //-----------------------------------------------------------------       
: y1 r$ {) H/ v1 R        public boolean AuthorisedUsersReached()
$ p/ p. `; J4 t3 J                {
7 z$ `, M& v0 @+ T& @                        return true;                        / m. f/ ]/ R1 y/ b$ c
                }& q4 I; y) M3 u8 L' G
               
! |% l7 ?+ g' N$ X' z1 D! I    } // end of class AuthorisedUsers
. R9 c4 ]4 Q* Z2 Q//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming- m6 t8 i7 G7 O5 q8 X4 }, z7 B: M
Shanghai - 2007
* }" b+ i6 i: N2 X5 @! @Assignment 21 j! P. @! t. I5 t; V
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)' A/ c( c# {. `, \. D
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.
3 I7 T3 p7 G8 @% y. KThe staff must be able to:
' c% r1 X( Y# I+ _1 Y2 N Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.# D2 G- k9 a( q( x9 s2 ^
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.
6 \+ d( X1 }3 t& o4 Z The interface should provide a menu so that the staff can:+ j  s: r2 w* D- R& z8 m; U7 D& i
a) Enter the names of the two Java program files to be compared
: j9 l# O  M: {6 z4 T For this assignment, it will be assumed that the two Java program files are in the same folder as your program.4 y% j. W8 l- {+ m
** 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).
$ R7 M  k6 l, [& E5 }3 E9 {6 CBSA104 Business Programming – 2007: Assignment 2
, p$ H9 Q3 u. \. B% L* ^# v- A% q# k, YPage 2 of 5
, a( [/ |$ l: W! r  x+ x' }b) Print out to the screen all the lines of code that are the same* s' C1 E; V7 g% @8 m) ~$ L" t
 Include the name of the file and the line number of the code being printed for each of the two files# u! v$ i: g9 \
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared& \+ \7 s! O% M% X: z# s- N
 the name, username and department of the user: n0 R& n* g8 b% b6 ]
 the statistics of the comparison) d) v+ _+ F0 [( I
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different& b' M- k. z/ m8 e. F- \: x
 the recommendation for further checking. j; u5 q0 I  v3 v  ~8 U7 _3 h
- 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
* I, F. i5 ~( d/ ]- a4 V the names of the two files compared9 o( a1 F3 @: ~6 n2 G
d) Leave the program (exit)
+ K3 O, G+ o1 H/ }# rThe ProgramCompare class: (Total maximum 20 marks available)
8 ?+ {" R4 `9 g  B1 m2. 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)
% M" B* |1 d5 E" q: |6 ja) provide an error message if the files are not found or there is a problem opening them
; R4 G4 L+ I8 Q9 P4 r+ d. k3 L9 W- ^b) compare each line of code6 x7 _9 a) T: o: \6 p4 b
c) print out the lines that are the same6 t2 I. ]- J- |
d) count the number of lines compared / lines the same2 n8 V& w& a6 P1 |- W5 b& g
The AuthorisedUsers class: (Total maximum 20 marks available)7 B9 w& ?2 [4 |
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)) _* `7 z; Q9 u- C6 k. a5 J' I
4. Provide methods to:
% c' l0 b- Q! `) q' {" ~5 |2 Ka) 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, o" i+ X: n) ?- S) K5 [. Z6 Z
b) return the name of the authorised user
7 k( r9 v* G0 }% ?c) return the name of the department of the authorised user  m1 d2 M7 Y1 \& v2 \! U6 Y6 Y
Individual Data (Maximum 20 marks available)
, J+ D9 u2 m0 y5 U2 A4 ]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." h6 w5 U# c! C. t* B
Documentation (Maximum 10 marks available)
6 `2 w, V0 N& D$ y6. 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.5 x: K. G6 j5 U, i- p! M
BSA104 Business Programming – 2007: Assignment 2$ _' w' z, ~. @; q0 g- A
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了# J6 R6 J9 O" R9 N5 y; `
不过你要翻JAVA的类库说明。你有下载没有?
3 w* j3 T" G! E8 n查询关于对比的函数。貌似关键字是contrast,还有compare
) N; s, S* a" s9 L1 X  Q5 G" }8 L
! |! ]$ J% |* |( M$ y[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -7 x* y; Y+ n2 n+ y/ n* ~0 ?
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。/ g8 B# x9 v8 s0 g3 Q* e3 l+ _
可以下载到的 是 jdk-1_X_0-doc
8 u$ y  O# k/ j' }/ ]- m0 S" }. l, B
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-30 18:48

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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