找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1263|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 4 j$ i; x3 z! z4 F5 S) m' D 4 P* D) t! R9 L8 n
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************  W+ q4 x6 E  j  ]
//  ProgramCompare.java         Provided by: DRS
( B1 _; T; V9 E, a5 ]//
6 A- d  h+ e- q//  Program shell for Assignment 2- P$ J2 @2 Q4 B. Q) B/ H
//# S# |6 x' I1 ]" z& W, R! n
//  Compares two text files line by line" u  s4 o6 U% L6 y. {2 B
//*********************************************************************
! E* P/ ?. E" ?$ _& O3 L# `8 B( G' _
1 z6 Y- q  o. S* zimport java.io.*;, r* L/ I5 Z3 j1 P* [$ ^
- u; h5 }  \3 P% j
public class ProgramCompare
  v( Q3 K+ K5 P0 ^/ @{+ T: n* Q. k9 i
        //-----------------------------------------------------------------
/ i' g& u: P0 w! a. q0 e: @        // Constructor
# v7 b) W+ I9 G# X! w; G        //-----------------------------------------------------------------
# y8 s7 U& b$ L* x) B' I        public ProgramCompare()% H, s8 k9 T; g, o4 h8 Z
        {
: Z3 P+ K. n1 }9 ~" [) ?7 d) @        }
, h8 M3 i: w) q
; Y/ o8 s& b: l        //-----------------------------------------------------------------1 j( Z, I: W1 X" o6 W
        // Method for testing that class has been reached* @' y% i' ]( |  q& q
        //-----------------------------------------------------------------        : b6 f% V# R; |) C
- f0 w1 J9 `+ R1 K4 Y$ m: X  e
        public boolean ProgramCompareReached()         % s" z# A1 n! k- g$ A* o* M+ i, C
        {1 n3 R: G1 \! Y: y' d# d* X
      try
5 Q' t& M  L( t; s: J1 T   {         2 I' g! S7 [8 y
                        $ A, q# N0 _* W2 v' M* x
                //********************************************************************1 A4 a' S7 X$ @% S9 v& W
                // Try-Catch Statement is used to handle exceptions - such as file not found
0 Q( K' i3 D" i7 J: n5 p' N2 B. J                // Reading the files will need to be placed inside a Try-Catch - just like this one!
  j( Y# [3 c. j: P4 a% u4 r) S( X                // For more information see page 534 of the textbook3 y2 U8 }" c' e% Z" X  n
                //********************************************************************: I1 N" a3 Y0 H2 c8 S8 B
                     2 L& ?% H0 M) T/ H- K9 d4 I* R7 G$ K
        }( u; ^& X' U; D' |% X
             catch (Exception ex) // Exception caught here and message displayed to the screen 2 R1 N4 z* g! T- `0 G
          {( s$ G% G" x( L4 M
                    ex.printStackTrace (System.err);8 a( i8 u# @( |" }1 o/ U0 s
           System.out.println ("Error message goes here"); // Replace this error message with your own          & `6 _# z) \# M3 I
        }
5 ]; h' S( b7 O, m+ T" I                return true;. ~. S* l0 z% A
        }- k& k0 g; b- N
# R8 X5 ]8 J. L1 W) x
} // end of class ProgramCompare( i' W, |* P; l4 ~8 v

3 y1 G" ]0 c  N$ Q) m& y6 H8 h//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************7 D* G- \! u/ Q9 }, K
//  ProgramCompareMenu.java    Provided by: DRS, o) X  S! O& \" C5 J+ O! M
//) i! Q& _9 }' u7 s: }7 ?
//  Calls AuthorisedUsers.java and ProgramCompare.java
% t$ ^+ L1 x# w& G' c, y//
  ~( s9 x) S! d: k2 j5 f//  Driver shell for Assignment 2.+ h3 p; u* q" L( l! m
//********************************************************************
8 v: ~7 T% G4 |8 @8 E7 R& \
- z8 e4 u  Z8 N2 x- _/ j4 Yclass ProgramCompareMenu
- X- D* x( A( u1 ^. K{
  h, _4 T) d$ B( V    public static void main (String[] args): I: u0 r( s* a4 U& x9 N- G
            {7 Q1 N) G9 Y( P, G/ u; a* V+ M
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable$ Z+ F. S. ]7 L: M& f5 ^, N) N
                ProgramCompare reached1 = new ProgramCompare(); $ V( e, ?" r0 J- g
                AuthorisedUsers reached2 = new AuthorisedUsers();        6 f& m$ ]: K( t" t! `
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
" J" o$ ?( l# n2 L0 C5 e                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
* p; p6 f" |. v+ j" e        }
  g# \7 J( Z3 e" x3 {& C}// end of class ProgramCompareMenu! h& }. k' \" x$ u

- i' ?& e1 Y( X! f, q, L% r//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************. e0 s4 j3 K7 P3 Q  M7 ]
//          AuthorisedUsers.java          Provided by: DRS0 O$ \" A  q4 |# C4 O* Z' e$ M9 c( y
//               
; K1 x$ T1 |, D8 m//         Program shell for Assignment 24 A; J0 o) w* `7 f+ m% s
//8 ?% ]) S) ~5 Y0 t' F
//         Represents facts about an AuthorisedUser9 f7 u# U2 `3 ^7 }% l+ F5 w
//********************************************************************
$ E- L9 n" _0 f" B1 t5 L7 U4 X# F: e" v5 n0 S) b, j- J
public class AuthorisedUsers0 S4 H" o) m% h1 L' w
    {. B$ Z& d. K8 g3 S9 j" w  N

0 }" t0 c) L$ Z% X9 F        //-----------------------------------------------------------------
/ A, R% J- D: [! k5 ^+ H  {; R' c5 U        // Constructor
  p. D4 \7 L) y7 a- u        //-----------------------------------------------------------------/ S9 \# E" k8 |$ x
7 ~) ~$ O6 G9 B: `% M
        public AuthorisedUsers()
6 O8 n1 e) M8 X# J; a5 f  d# B  h  e# u                {
& O5 I% p. W$ y( U0 `4 l                }9 t) s5 w! k9 i" z. Z/ o( `
$ O6 r$ F1 d0 D# x* z! H9 K+ u! _3 c
        //-----------------------------------------------------------------: h- V: g  @2 z2 m
        // Method for testing that class has been reached
. Y* L! A; u0 T1 u/ F        //-----------------------------------------------------------------        : ^7 A3 K& o6 i  @. W' R1 _
        public boolean AuthorisedUsersReached()3 r. s4 A; A7 g) R1 z
                {
9 m, q* S3 @# O; J3 E4 C; J                        return true;                        6 t+ P9 _, i  a- O; n) L
                }
/ X& q  y% i! A! H5 l" X& f4 o2 r               
! _1 p4 {) w. J0 G) d    } // end of class AuthorisedUsers
0 \. o8 F/ |0 z* C' p//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
3 v5 q1 T; g- z! C/ U: N, _Shanghai - 2007
( A/ g; i5 y, R; Q2 g' M$ X6 x9 gAssignment 2# E# h* V' U# p
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)0 ^3 r* J3 q& t8 B% T
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.
1 @1 U4 l* J1 \! z0 T6 tThe staff must be able to:
. w0 }$ x3 F5 J, t3 \1 E7 { Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
: X. C! R7 n" _9 U  g4 S1. 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 H+ @, _% G- C0 J4 W0 n4 L: c! L The interface should provide a menu so that the staff can:
9 ~. G7 M# K, l" }' g5 O. k; ia) Enter the names of the two Java program files to be compared
, J3 k: D0 y- A" E* A For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
) U! X3 u% p& I* V# A) C8 R** 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).
& k5 V% y1 n; J. j+ o/ _: qBSA104 Business Programming – 2007: Assignment 2
/ b6 R/ H* D& i7 z! Y) oPage 2 of 5; {# [8 [0 q( o
b) Print out to the screen all the lines of code that are the same5 _7 q! c7 I8 D  h9 d; K+ K1 H
 Include the name of the file and the line number of the code being printed for each of the two files
# w% Z# @6 z& _c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared5 g1 K) F  ]* t1 F
 the name, username and department of the user
: J+ x, m9 m; O# b# J the statistics of the comparison% D$ k* d) L  r0 V8 y1 w
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different. `7 a7 K1 X. w% y+ D* j
 the recommendation for further checking; z! T( `' m/ Z0 z- o. d
- 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# }* p; e( y- q2 w6 u4 G, p
 the names of the two files compared
# _: c  F  v* o. ], pd) Leave the program (exit)# P7 S! H! r" o: U
The ProgramCompare class: (Total maximum 20 marks available)
7 N% p  p& ^8 Q# t' W2. 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)
+ m5 L! _, Y( u( Xa) provide an error message if the files are not found or there is a problem opening them8 V! h8 K3 m) C$ j; Y+ E5 I2 t- |
b) compare each line of code8 P5 l4 J9 I' B) _; z# t3 c
c) print out the lines that are the same
0 ^: O2 C  B) t' g/ Y; a1 Cd) count the number of lines compared / lines the same( a* [* L  K+ M: M5 {
The AuthorisedUsers class: (Total maximum 20 marks available)
+ e. s6 k/ e2 v# {* P3. 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)
. r/ ?4 R, Q( B/ D. ?4 ^4. Provide methods to:; A- K- c- k' ^' [/ s  W
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 T) Q4 c8 {# F0 q, G5 x5 E# O
b) return the name of the authorised user
2 y7 d3 `! {$ l3 R8 I! ?c) return the name of the department of the authorised user
) h$ C' n. d$ `) Z( c! FIndividual Data (Maximum 20 marks available)5 c# c0 `, [' w4 G& o" ^& A
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.2 N' }; W: e) y) A7 \  G3 J$ _) `1 @
Documentation (Maximum 10 marks available)
; d  i. U9 Z( z6. 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.
, Q1 K$ t+ ?" fBSA104 Business Programming – 2007: Assignment 2
, d. n7 x$ V. L) O( g" g) X4 ]+ pPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了) ~$ i( @, a' M  G" D& X
不过你要翻JAVA的类库说明。你有下载没有?
, F1 L" M' A) L' A& g查询关于对比的函数。貌似关键字是contrast,还有compare
  ?+ \) e+ q1 Z5 R* N
$ H# ^/ ]+ r- }' m3 L% ^[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -0 u0 V6 @( J: T7 b  y
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
! A* z# i' j6 q可以下载到的 是 jdk-1_X_0-doc
0 M" Z9 b1 c! I( _
/ x# E; t# w9 w1 u[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-11 07:26

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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