找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1048|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急9 H9 _( v/ k- b3 u ' o- q8 J: d5 y& F; Q# M
回复

使用道具 举报

 楼主| 发表于 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 [& \8 ~* C3 T- L1 s. R2 a
//  ProgramCompare.java         Provided by: DRS
# f& l: Z5 A6 E$ F% e' K& p//0 A4 I) ~1 ^) `( ?8 `+ E2 A
//  Program shell for Assignment 2
8 n4 D1 o( X8 m' W( t8 ~2 P//
+ {. P% M4 d- J//  Compares two text files line by line
1 ]: L+ g$ {3 I3 {//*********************************************************************, ]% M& Q3 V% K1 T$ [/ q5 w6 e3 f
' Z0 k; p, y( d/ j7 x2 O3 W
import java.io.*;
0 K* f) c' D" [/ r! S4 |% B$ ~% Z" g' z4 h3 o$ R1 H3 s& x: a) y
public class ProgramCompare. J. m; F8 S/ C/ w7 j5 U; R
{$ O) k& a+ ^0 l5 k
        //-----------------------------------------------------------------8 p( y" q" e9 _
        // Constructor: m( _6 B: @& _
        //-----------------------------------------------------------------( b9 I, R( P+ _3 t2 O/ d$ o
        public ProgramCompare()
, d9 u2 h* P! m; m: _2 V        {
2 s5 ]; e: H" X, w8 f' U+ o; o- G6 h        }
! C5 U! B2 U9 U$ Q6 A! B
( ?8 }) n, {) d6 V7 _$ N: d, `        //-----------------------------------------------------------------( S' K9 @: f' E2 ?
        // Method for testing that class has been reached
' w3 e. T$ {6 U        //-----------------------------------------------------------------       
' ~: o/ u0 R* z, d) H3 l& c
6 W& D8 ]1 t, Z% v. t, r* ^        public boolean ProgramCompareReached()         1 Q  l: |7 J0 ]5 \8 E) ~) Q4 d
        {
3 Q. i2 V) H' K; i; \! @6 z$ e      try
2 u" I4 G4 j+ B1 Y9 k- |% i   {        
0 Z7 c! A$ b5 V7 J  H6 ~- H                        9 u5 B+ I) X1 t) v2 ~
                //********************************************************************" `1 D5 y8 H0 k' U. ~+ b4 f
                // Try-Catch Statement is used to handle exceptions - such as file not found 8 Q# a. M) R& y  G  t6 |
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
& _2 o  y- z" F: j                // For more information see page 534 of the textbook
/ t. k1 R* e3 v/ @* m5 r  ~" W                //********************************************************************
0 n! h- `, k* r5 Q* d% p& j8 a                     $ U7 H$ j* |- }* A
        }3 u" r1 r8 W% f0 X/ d9 O. j* U9 k
             catch (Exception ex) // Exception caught here and message displayed to the screen
& X  Z2 F; G' K$ R2 `* s          {
/ h! n6 a- D3 e8 ]) e7 c& ^                    ex.printStackTrace (System.err);  M! M5 G$ N# R6 J$ C
           System.out.println ("Error message goes here"); // Replace this error message with your own          7 n8 Q6 C6 p/ O1 c) ~" ~
        }: Q- j% ?. c/ c% C  c
                return true;
3 ^' m: w* S2 Z; `; N        }2 E+ m2 {1 j: K$ i$ I$ @
- }( ~. L/ ~1 K9 v
} // end of class ProgramCompare9 E- o, W& B0 m! z- A
. q1 X4 z6 y+ F! R$ `, \" U( R6 T
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
4 x5 A6 m; v2 N//  ProgramCompareMenu.java    Provided by: DRS0 v$ o" _3 J& O" {( y' I. v  D
//
/ q5 ~- ~4 T, u$ l3 {; D9 P7 H4 f: D//  Calls AuthorisedUsers.java and ProgramCompare.java
& @7 d0 I9 D# u: _, ~//0 ]4 k& [" K; {; q4 H( t
//  Driver shell for Assignment 2.
2 G; j3 @8 J: W5 {, Q2 S& m//********************************************************************
  T# ^$ w3 O% R5 {+ |+ w' M$ ^; u% Q/ @. Y8 ]
class ProgramCompareMenu
" r2 C0 ~3 A7 Y1 b& }{  P+ H3 P9 y7 M5 n9 U& W0 k+ {- O
    public static void main (String[] args)
. U# Y' ~; V7 l  Y) @8 g% G            {
! p, h; |0 o; r, v% j- R                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
" n$ t9 c+ V+ e/ z9 M3 [: g                ProgramCompare reached1 = new ProgramCompare(); $ T  e+ o& v- T2 n, c# c
                AuthorisedUsers reached2 = new AuthorisedUsers();        1 h% X9 a3 Z1 t& Q" Y; g
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());0 W0 g# L$ e) \. B
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        . v2 O9 ?. m0 p3 h
        }! t" |8 b/ C! K7 F- a; o
}// end of class ProgramCompareMenu3 e6 p9 g; s- E; k4 B3 }# u2 E* A- [% A& N

, W& h. P( `9 K" n. I//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************' T& n' |: w% U' y1 P2 o
//          AuthorisedUsers.java          Provided by: DRS& Z# C& r, z" f3 [4 b# m/ a
//                " P0 L+ g$ n1 p% {
//         Program shell for Assignment 2
  ^# G2 U8 r  B2 _" V3 S$ ~) `+ }//
! `* h) u* a8 F/ z. H//         Represents facts about an AuthorisedUser
) j! x1 s- g1 `7 d7 R( _0 E//********************************************************************
9 E% }- [9 m& n$ P7 G2 F
$ i6 @- u' M6 H& Epublic class AuthorisedUsers
5 }6 u; K& M' U- K( y/ ]    {
2 u" P* U, _# n. O- N( ?! c& Y$ U+ A* O+ P& k
        //------------------------------------------------------------------ i; C( n! e# g* d  [, M! t
        // Constructor' \$ f2 Q- n& I; \  z& p4 w
        //-----------------------------------------------------------------2 H4 K  G) {8 s' Z
: |0 P6 M* U6 y6 E. K  b
        public AuthorisedUsers()
1 q$ r: e5 M5 C% I( Q8 ^                {/ E; z/ ?. S. N, k2 E/ {
                }2 }- ^/ ^* N+ V" {5 _- k4 B8 e9 ]
2 {( D+ d9 }. F% Z4 A6 }
        //-----------------------------------------------------------------
: M( t( T5 h2 k  d        // Method for testing that class has been reached$ Z$ m. O  V6 {  K$ x
        //-----------------------------------------------------------------        ; x/ v6 B1 G+ ?. t
        public boolean AuthorisedUsersReached()
- B$ q6 b3 q  N- p2 Q; _                {
' v( C% l# n6 g  o& A& m                        return true;                       
; C& H# a6 T2 _" o6 E9 r                }; \% I- r) k  U( W
                5 P4 B' e8 z5 a5 A& T& F2 V7 r8 \
    } // end of class AuthorisedUsers
$ }8 X( O! V- b4 E+ O//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
' R) @8 y  g( P0 m; z3 z- fShanghai - 2007
0 j0 I% r0 H* rAssignment 2
% t- W% T$ A5 ~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)" b- C2 v9 f# {
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.
% O, X: v4 W$ e% x3 h! P" _2 eThe staff must be able to:" _/ W, i! G+ ^
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.& ?# j: R+ Y& ~$ ^4 {; w+ o
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.
: X8 a- x+ e+ u+ Q6 u$ m  L The interface should provide a menu so that the staff can:' v7 r; V8 J' @3 [! Q) a5 \; c
a) Enter the names of the two Java program files to be compared/ o( g4 l, y6 O
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.4 v+ r' \  C. C
** 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: a5 a" U$ `' P; k9 ^  w& g2 IBSA104 Business Programming – 2007: Assignment 2/ w& q! h( I* M: A7 V4 k+ F) k
Page 2 of 5
0 t+ [* i  n- _- ~' A, Cb) Print out to the screen all the lines of code that are the same! ]9 o. m" `7 `6 `
 Include the name of the file and the line number of the code being printed for each of the two files
8 n7 ~( ?8 d3 f! g& r1 I" w( {+ \c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared1 _, x, c) |# y$ o2 U4 L
 the name, username and department of the user  d' X1 G/ l0 f# g* a# }% i1 {2 P
 the statistics of the comparison9 B5 q, a; C  H; w2 r
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
* v) w9 f0 n8 d3 F" v the recommendation for further checking
" K2 h! y* R4 g5 F6 T( ?! B; s; |' 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 closely1 g" y' u- P2 D4 t3 }8 x  _- c, H  r
 the names of the two files compared
0 s1 [  v, g- Xd) Leave the program (exit)
. n/ N% R1 T0 {) r- U6 U. S" XThe ProgramCompare class: (Total maximum 20 marks available)
; o; S8 |# @% f; @" t+ p2. 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)
' C$ u7 R. O0 b( d# qa) provide an error message if the files are not found or there is a problem opening them" o4 x) _7 [4 J2 h1 r3 U" X4 |+ x
b) compare each line of code
% M, h: V9 }" B- i. yc) print out the lines that are the same
& H4 y2 N8 f/ Pd) count the number of lines compared / lines the same
' n+ N+ |: r: \/ o: U& rThe AuthorisedUsers class: (Total maximum 20 marks available)
& z) l  F8 W1 \/ I, h4 K3. 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)
/ ?8 ~* K; V+ d/ _. @1 [4. Provide methods to:
3 P. D3 f& A2 c$ r& e1 J8 q4 p$ @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' \) w9 I  N- I; J; L3 ~) y
b) return the name of the authorised user
9 Z" b: V  d! g* p9 n4 Qc) return the name of the department of the authorised user
) }8 E( p7 j  pIndividual Data (Maximum 20 marks available)/ Y; O: n1 \$ ~0 t8 b
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.
5 f' i. o  B2 }& r2 h0 [& ODocumentation (Maximum 10 marks available)
4 _+ F# x  Q1 {( o: W% {3 U6. 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.  H6 a9 i& X2 s$ n; n' G8 [' P
BSA104 Business Programming – 2007: Assignment 27 c1 {5 e# j7 K& |4 K1 w
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
( @2 G6 Y, D% C, k, C1 ^5 d( }不过你要翻JAVA的类库说明。你有下载没有?* `4 [/ s3 p$ X; V$ z* p
查询关于对比的函数。貌似关键字是contrast,还有compare
3 \% l9 d6 z$ m, H3 L! A  V& F# e) ]& H  W1 o
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -+ L* a) T6 T6 q0 [
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
: T5 n% f, D! t0 B" M可以下载到的 是 jdk-1_X_0-doc7 a" P% G/ |! d
6 C3 j: }5 C0 E0 f  S
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-14 09:45

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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