找回密码
 注册

QQ登录

只需一步,快速开始

查看: 986|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急# p2 b' N# F2 O- l! o + |3 l7 y% h& N) m5 O
回复

使用道具 举报

 楼主| 发表于 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 b+ b0 B! m. n6 z//  ProgramCompare.java         Provided by: DRS* K& H5 H! \! Q. C: \+ Q' n
//& Q5 F7 f& B" K7 I
//  Program shell for Assignment 2
0 s. [! l0 M: W) t9 `# j" T//6 m0 _. B) S* W5 Q
//  Compares two text files line by line
( q. y+ a2 x% p2 e$ r! e//*********************************************************************
7 C' P3 S! `( ~. N# I
5 i' o. S3 K1 J: pimport java.io.*;
) A# \: Y5 S7 Z. S; E7 P9 m" \3 ]7 w$ w1 K
public class ProgramCompare; M3 Z+ S9 g- i. {
{
6 K3 A, @1 |6 C/ k        //-----------------------------------------------------------------( }- b: w' m3 {, ^# i* X: a! e
        // Constructor; w% U% A" ~5 Q# U, ~, ]
        //-----------------------------------------------------------------
+ e+ y, O# P5 O' i8 S# ^2 W        public ProgramCompare()
. J, @! {9 T& h7 i4 ]$ s9 v% |        {1 L8 o4 E. ^+ a% f% |( ?! l
        }
( S7 @3 i  `& {/ A! i7 W& ^$ Q. v6 e
        //-----------------------------------------------------------------/ b: z$ }: I5 C7 J; d
        // Method for testing that class has been reached1 ^6 A. L. h& x
        //-----------------------------------------------------------------        & }5 Z) U+ u9 e) }& D/ S
; Z: ?2 R# t# J/ X" R/ i
        public boolean ProgramCompareReached()         2 A, [  D8 ]2 d# a
        {
% s  T$ o" p6 o3 Z" A      try
- N) n. {0 X' r; d) i6 S* j   {         3 O& l. K/ W4 S% w  D* C4 r
                        " D8 ~# q, d: e/ V8 \; `
                //********************************************************************9 W* w0 R; e" w* T# {1 I" Z
                // Try-Catch Statement is used to handle exceptions - such as file not found
/ l5 X* B6 Y" Y7 J2 z1 X% o                // Reading the files will need to be placed inside a Try-Catch - just like this one!& Z* ~* q- b8 b3 c/ `
                // For more information see page 534 of the textbook$ ^( k; l1 N/ R. y3 o
                //********************************************************************
8 q4 k- ^) K5 b                     $ x9 M: R; y; Y" _/ X- k
        }+ k& T) H% w. P7 m7 \; K, Z
             catch (Exception ex) // Exception caught here and message displayed to the screen ' \7 l: H" W) X
          {7 o; e$ y  M& s7 I8 Y5 t
                    ex.printStackTrace (System.err);! ?; M% x) z) d& T, E) I0 O
           System.out.println ("Error message goes here"); // Replace this error message with your own          8 V. o% p) Q9 f! e+ e6 ]% m
        }; A/ _2 c8 G# r
                return true;
( ?9 S9 N6 r) q" l! @        }
& }1 a5 v' ]1 [2 y$ s: D7 [) y, u6 N' T! `6 s
} // end of class ProgramCompare+ @8 W+ [6 O+ k# N+ g3 y

; C4 k: N# k2 U! H7 A4 }6 ]+ t//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************/ o0 p, P* q# D* W
//  ProgramCompareMenu.java    Provided by: DRS: Y, I  M3 n. W$ `4 x: ?
//% W1 y( r: v8 ^5 m
//  Calls AuthorisedUsers.java and ProgramCompare.java2 S  @$ ~; S- H" k. B) B% ~
//+ t: B' \. K% R" z
//  Driver shell for Assignment 2.
$ T" X8 }! w  r# V) y" K3 Y//********************************************************************9 r1 m' K! _* i: ^! r; x; H! `  P
  v2 [4 c$ H" F4 |5 v! A
class ProgramCompareMenu* w2 d& l! Q9 U  L' d( ?3 N" y
{  p; O4 |4 f4 `, Z4 V
    public static void main (String[] args)9 h" w8 ]2 H  o
            {
6 k& j, ^7 H8 U$ \                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
$ o/ k$ [) P; i3 i- s% o8 O                ProgramCompare reached1 = new ProgramCompare(); + q- C- j+ R2 Z8 G8 f9 D. e, o0 e
                AuthorisedUsers reached2 = new AuthorisedUsers();        5 z4 }0 ]$ i" i9 K
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
# i2 o$ P3 D4 l3 |# j                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
0 j) r" f4 D  {, S+ F6 K        }; ?* ]- B8 ~: P0 K" w  l+ H
}// end of class ProgramCompareMenu. J& j$ M. |' T. [$ V% F, k; h

+ W& i! L7 i* G: T//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************$ t6 u/ B( D, o# g
//          AuthorisedUsers.java          Provided by: DRS6 u3 P$ a; ]8 h' b; K
//               
8 J: E+ o% g7 f1 G//         Program shell for Assignment 2" N+ }6 Z# {! w2 ?; K4 b
//
# x% I) i* w. a/ ]/ ^0 R//         Represents facts about an AuthorisedUser# o4 |6 o( T  A
//********************************************************************
7 T! V) G/ ^  u- X5 s; Y4 M
" e: [' {6 G: S& K" A/ ^public class AuthorisedUsers+ H; @- O0 }$ {2 j3 Y
    {" T+ d8 `5 _9 ~! F( h2 R9 h  F

8 h1 F  E4 V- h/ F8 ]# F# T: l; u4 \        //-----------------------------------------------------------------1 H- F% k& {" q6 R# h) ?; ?; L
        // Constructor# J; T/ L' M- Q  _- f3 T
        //-----------------------------------------------------------------& n1 o* W5 h# _* Z& {& t

2 o9 T1 u5 S- Y% _% ~4 ^# r( w        public AuthorisedUsers(); T) c) }# K; Y' Q" {- k% A8 A
                {4 p4 [8 F- {; f. i3 u! S1 Q  l5 {2 D: \
                }
% K) h. s9 p  Z+ e: l: }+ l5 O, T0 P; o' B; p% J
        //-----------------------------------------------------------------* K$ q; _+ V5 J7 h. x1 h; U0 E
        // Method for testing that class has been reached- m5 ^3 t# w% Z) U; ]
        //-----------------------------------------------------------------        ' X' A4 a! ]1 x" E. N$ e" c' \( C
        public boolean AuthorisedUsersReached()# W5 P4 q4 O/ S( Y5 Q# j% E# q2 b
                {0 L, X5 f' M1 ?9 |( _/ D; F7 s% j( S
                        return true;                        . o& X) L% G; E% E8 [
                }+ J% |9 z% l5 p" X
               
9 N& p; @- G( h1 h    } // end of class AuthorisedUsers
# J2 q% d6 R4 x, o/ j//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming# r$ L2 N& X4 b5 r* m1 N3 W
Shanghai - 2007
7 ~  ~* `$ m% H7 [( R; b0 k! kAssignment 2! P6 x$ |7 y! r; U0 x, S) j
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)
" U" M( o  f! a% ?2 S9 W5 K0 b1. 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.
  b% p8 ?6 ~4 k. W, p+ rThe staff must be able to:9 j4 B" ~. K: j' {4 \: p1 b
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
' }+ C! C- q3 A# I$ z4 g1. 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.
/ L% e+ \4 V7 {6 z The interface should provide a menu so that the staff can:; G( l0 c( k3 x- I$ _0 ?) @
a) Enter the names of the two Java program files to be compared
: X  p! f) f" o1 }9 R8 b2 l For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
5 |/ D0 J8 i- g** 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).
- d' S/ P- N1 q$ i1 [( o6 hBSA104 Business Programming – 2007: Assignment 2
) x7 b. M, ]" M8 PPage 2 of 5$ y5 c8 E. _4 \3 u8 P$ ?/ {
b) Print out to the screen all the lines of code that are the same
& g% `: K4 T0 N, R5 R+ C4 ~) Y Include the name of the file and the line number of the code being printed for each of the two files
5 v3 r  v( X" {3 z" y" Q0 Kc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
- C. |9 @; l* V! p the name, username and department of the user
3 F. C. m/ N5 X1 n+ r$ |. X6 [5 a the statistics of the comparison) i4 f- n# {: V+ l: E
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
# C$ \. j- V; d' o the recommendation for further checking
8 |9 T/ y" Y1 F! h/ J. x- 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
! d* Y5 S5 ~, e the names of the two files compared5 Y6 I& K7 |+ j" M; F
d) Leave the program (exit)
2 q. K& l2 M* m9 Z5 U: ]2 DThe ProgramCompare class: (Total maximum 20 marks available)
8 S, P+ t  d: {& K! I2. 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)
3 v' H, r! S; |. `, D- ea) provide an error message if the files are not found or there is a problem opening them
3 W/ A4 p" a1 V0 P$ @$ r, ob) compare each line of code# E6 v# L+ O5 g7 T2 ?8 y
c) print out the lines that are the same  _6 m" H* H; J4 v
d) count the number of lines compared / lines the same# P( N: n2 _6 `# t( C  C. ?& U
The AuthorisedUsers class: (Total maximum 20 marks available)
" j7 |) q+ [- \4 Z$ e9 s, \8 d/ 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)' g6 H! d% A) @( g8 V/ `2 F/ z
4. Provide methods to:4 R- S' h& T9 A2 E: F
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 match1 [# V# O8 |, x2 U7 u
b) return the name of the authorised user0 L3 Q$ q3 i$ i, G5 g
c) return the name of the department of the authorised user& r* i6 }& x5 y0 V2 `- @
Individual Data (Maximum 20 marks available)  i+ F0 \8 s6 \- 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.0 C. g# _' ^( R$ f, w0 g# _; u
Documentation (Maximum 10 marks available)
. R/ S# U6 |& [! |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.; d& E- u0 _, o; s; q
BSA104 Business Programming – 2007: Assignment 2
. X4 [2 L# @! D8 hPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
/ x1 V. B- N6 |4 b- q. ~, V9 f不过你要翻JAVA的类库说明。你有下载没有?
. y/ U' B% N( I, o* U" m2 h查询关于对比的函数。貌似关键字是contrast,还有compare
$ t1 |+ W3 I/ I7 q) R+ \( X, f0 ]& T- P" K5 E% U; Z5 t
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
1 ]4 H  d$ n# l. t; M痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
+ x/ c& |( ~( ]" b  H7 e可以下载到的 是 jdk-1_X_0-doc
- d6 Z6 l( Z) Z5 Y% U) M
+ ~9 q. Y4 Z1 O* c! T[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-1 00:59

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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