找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1103|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 b3 G: B; u! o& W" K, ] . h T4 s3 T( p/ {! @- u+ B
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************  m. w8 g' Z- W: W: h4 i
//  ProgramCompare.java         Provided by: DRS  m6 I/ f5 S% }
//
7 u: Z6 v& K4 q& S//  Program shell for Assignment 2- z* ^" D' T! z9 J0 V8 d
//9 D/ @% ^3 N1 n
//  Compares two text files line by line
8 s* \+ N( P+ M# A8 w$ Q# w! C//*********************************************************************
: D) u1 n1 O6 }8 e+ ^/ d  F2 S
' f  b# }& i. timport java.io.*;
3 Q5 I! e5 c" ~9 m
4 R9 V. |9 e( }% H. Bpublic class ProgramCompare+ k2 D) K  e1 T5 C3 |' M
{8 N7 d  b9 g: F) M
        //-----------------------------------------------------------------& D: g% J4 E7 u/ h* Q5 W
        // Constructor
$ x/ \. `" n; A7 W, J5 X! N        //-----------------------------------------------------------------, {$ o" [! M( p1 @, C
        public ProgramCompare()( {) J! }9 I0 w* B# m: G
        {
! t' W$ t$ Y5 ]+ E% R        }- x# U; j: l, I1 ]0 P# T6 I* j
  g" X. r& x( y8 l6 D+ Q) `. Z
        //-----------------------------------------------------------------& |2 D" K. k' M, c" x
        // Method for testing that class has been reached8 F" [) n: Y3 L& z- O
        //-----------------------------------------------------------------       
/ ~8 ~5 b8 o* m2 u6 @& v. W7 x' e/ g. {6 g8 g8 a
        public boolean ProgramCompareReached()        
% ^* o- A& t) ?# M% s        {+ w; L" t' ]5 h# M5 _' \/ b1 V6 z
      try ) [, U9 s1 \" Q5 M6 r, k6 }
   {        
; N4 o4 W7 L; S# B$ d" T8 l0 t, q                       
; j4 S4 f; h$ [                //********************************************************************
0 N$ W: A  R1 X9 A5 ~/ Q                // Try-Catch Statement is used to handle exceptions - such as file not found
; ^# I8 s  j& ?5 h4 s                // Reading the files will need to be placed inside a Try-Catch - just like this one!
) b& {' I$ Z" r  f1 [                // For more information see page 534 of the textbook
& G" R5 X4 b+ [) t( K. |                //********************************************************************
9 g4 `( N3 H9 W1 A4 M% A                     0 w0 H7 l9 F, A$ {. S
        }
, M" N# |4 B* Z& @8 t             catch (Exception ex) // Exception caught here and message displayed to the screen ; s$ ]2 ?% W, e* b4 k
          {
, k1 {. {, v$ N                    ex.printStackTrace (System.err);1 n2 f' [8 Y* P1 K& C% j3 J' {
           System.out.println ("Error message goes here"); // Replace this error message with your own         
4 F' x( [& W) o        }) P. [, `8 E: i+ K. b
                return true;" Y0 b7 g( |2 z' h
        }
$ y3 }) G. n2 X) P  O# o9 r
& `) @% Y/ g8 C. I} // end of class ProgramCompare: i3 r& j& I6 b( [! _

' X( a# g7 B1 o$ c# G! L//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
  W$ [* |2 o8 o6 V7 [+ z+ F% h" y//  ProgramCompareMenu.java    Provided by: DRS& h7 c# ~7 q, s' x
//! o: Z. t% r9 m/ G: y
//  Calls AuthorisedUsers.java and ProgramCompare.java
8 S- k) P8 G) d- T0 ]//  `, w5 ]/ ^2 `- {2 q  Q
//  Driver shell for Assignment 2.
  U3 G% P, q  C7 v+ G//********************************************************************
4 _$ r# n/ s/ [% L! ]8 z. \$ t( L1 l  e% w
class ProgramCompareMenu* P4 n' p8 E0 T3 ?/ j" }
{
) U8 C5 k' y. ~+ q    public static void main (String[] args)6 V! m+ h5 \8 L$ P
            {
/ h3 Z! W5 D. h                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable- w# K, f$ [3 B( I6 H
                ProgramCompare reached1 = new ProgramCompare();
% u: Y0 p1 f" \$ g                AuthorisedUsers reached2 = new AuthorisedUsers();        * T' E. n5 t" y* j" c7 y
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
$ Q$ P; u# _) I0 _                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
5 X9 U% N" _3 q        }; U+ m5 w1 P  u: K; `
}// end of class ProgramCompareMenu9 x) o" J( d2 E# v. @

& B. s) d. J) v' @2 z' I4 A+ E//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************, L/ D; V/ S/ T
//          AuthorisedUsers.java          Provided by: DRS, x) W* {* A1 e( ~! A% f$ X+ C* w
//                ) ^9 `  V6 J9 R" g5 e. f/ ]
//         Program shell for Assignment 20 p. }/ n0 W5 K1 F8 o+ \, }+ u8 V. [
//
1 T$ X0 M$ a9 Z//         Represents facts about an AuthorisedUser
1 ~& ^% C2 k! z! |/ v. ?% k//********************************************************************+ ]$ G2 l4 F/ p( A/ j8 q" B7 W, n
* B8 |1 B% }" ]4 |- q0 x8 u. r" c
public class AuthorisedUsers. S$ B  f, _( U# q) {% }0 V) U
    {
% ^! k2 H/ I. A# w! {4 L  w0 Q8 m6 I, D8 c6 T: b: j
        //-----------------------------------------------------------------  }( A/ I$ T) b- q* [- w, y
        // Constructor
# v+ z2 p, S( g        //-----------------------------------------------------------------
, P1 C/ T: a; |# p
9 A% y6 s0 g- s- p        public AuthorisedUsers()
% k* ?/ ], a/ z2 ^                {0 V4 j" ^$ W  b0 P3 N: ?2 [
                }
) Y4 a6 r5 o  d9 Z8 D7 g+ e  |
- j: f. W' H) B* }        //-----------------------------------------------------------------2 T& x  b8 B3 E& O4 }. ~7 N& B
        // Method for testing that class has been reached
$ n8 k* X& {( a0 h3 E; ?        //-----------------------------------------------------------------        0 _* _3 z6 [- e, u9 Q' y7 k  ]! B
        public boolean AuthorisedUsersReached()
7 \/ w- R3 l. P5 b7 f9 c                {
$ j, T8 r4 D8 ~# r! Z                        return true;                        ' x- U8 i' o; m0 G$ m% C% O
                }
9 v' r2 B% S5 k$ q4 o               
7 ~  k8 ]- Z7 }; \    } // end of class AuthorisedUsers
- Y4 q0 w$ G, T& q/ f% ]//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming4 v8 D1 b3 ^; L( r4 s' `
Shanghai - 2007
) v; B( O: e  l/ C  [, Z* T3 _Assignment 2
3 J+ t; n9 [* \5 e! Y- j7 l& x) X4 DDeadline 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)/ J( a- l/ D8 W  ^; H' N* c: |
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.- Y  z+ b8 `# ^
The staff must be able to:
9 K5 V! C' T$ o3 ^! z! \ Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.- Q9 _$ D4 X- 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.4 @* h" A  t/ o4 R
 The interface should provide a menu so that the staff can:! S5 c0 A$ ?) ~( J2 O8 \/ B
a) Enter the names of the two Java program files to be compared
9 h; W$ J& Z4 u" {7 s' ` For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
" l8 p' a* k  w$ x; t2 Q2 K* 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)./ a: n, ^0 e" {, b1 g# q
BSA104 Business Programming – 2007: Assignment 27 C3 u4 X% j- B2 N9 n( r1 T
Page 2 of 5
/ k+ D. j5 J4 u- K3 V8 tb) Print out to the screen all the lines of code that are the same# T! G2 Y/ y0 M6 R! X5 _5 ~0 I
 Include the name of the file and the line number of the code being printed for each of the two files
( d% R2 h- Y' ]+ s& _2 |c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
7 s3 q2 h% e8 U  a* a the name, username and department of the user
& `6 r  J' S3 S1 U" d the statistics of the comparison
) d- M( H  U  h- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different8 j, L* I* A# P" @
 the recommendation for further checking
( ~4 n+ o9 C5 `* S- 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 closely0 T8 o) y( @! ?7 i% j
 the names of the two files compared) y( M6 j7 B  N; {. [
d) Leave the program (exit)3 v1 d; y, O+ d" [
The ProgramCompare class: (Total maximum 20 marks available)* @8 }, p3 P2 ]7 k1 J" X
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)
/ R9 G  P" J; t& ]6 b8 w2 Ka) provide an error message if the files are not found or there is a problem opening them
; f7 [  x2 t& c' Tb) compare each line of code
2 D% o: a% x$ v  k1 v6 Mc) print out the lines that are the same% w0 h1 _4 N& v
d) count the number of lines compared / lines the same
. E& V3 r- q# ?: b5 x! DThe AuthorisedUsers class: (Total maximum 20 marks available)
" ?9 k3 N3 P) Q0 e3. 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)
( A6 d1 Z7 R+ x, Q1 v4. Provide methods to:
$ o! g8 u( Z8 l( la) 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! ]9 m  e% w' v2 F( Tb) return the name of the authorised user/ _  O- ]# w. n7 n, }8 x
c) return the name of the department of the authorised user1 |/ J* T0 A# }* a3 ]/ ^8 o
Individual Data (Maximum 20 marks available)
# f2 t0 i8 l% f: N5. 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.
& S. U' F, ^0 J( J- l& C2 A& WDocumentation (Maximum 10 marks available)# h, u0 c& H) ~6 a" r+ W
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.6 y- K+ X# R- Z1 l. A
BSA104 Business Programming – 2007: Assignment 2. R+ t/ s- b. E& [( |4 E6 w( P  D  d
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了7 u$ h, M& R, t
不过你要翻JAVA的类库说明。你有下载没有?$ A1 P& V; O5 T, Y
查询关于对比的函数。貌似关键字是contrast,还有compare/ D: \( ]# [* d8 N

. r( Z$ L2 ^" E" w  }" ?& b. ]& s! {[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -! o# x$ I" p1 ]9 @7 D) f$ `
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
! `, O" m1 D; T/ l1 B可以下载到的 是 jdk-1_X_0-doc
8 K0 q7 @- j4 u* p
6 R9 J7 K( `" q- ^( r[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-3-10 07:52

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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