找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1179|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 H& T0 m) N$ ` 2 b& L; H! K% R1 e
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************2 n' ^& G# c- ]/ x% s! D* H
//  ProgramCompare.java         Provided by: DRS% V* w- c" X. g2 X3 ?8 [
//2 j' ~$ D5 O8 S0 l
//  Program shell for Assignment 2
0 Z( M9 [# @, C6 G//" E3 H. D. o& a  I
//  Compares two text files line by line
8 o2 @. P- G' a//*********************************************************************
3 j9 N: D! u% I
/ @! a) s4 ]6 c8 A0 U2 i7 Himport java.io.*;
6 t: Q) d1 ?8 U  [* R9 ^# B" V* n8 u, P2 y' r; f9 P
public class ProgramCompare+ `6 l' C' u9 }* z0 d+ u
{
. M$ b4 Z, M/ x4 Y, v7 U        //-----------------------------------------------------------------# }3 d" I! P' c, u) H
        // Constructor
6 D3 s, q0 W- X( o8 c        //-----------------------------------------------------------------
3 [' q" }. u2 M( C        public ProgramCompare()) N. o" v/ T# {$ k8 A6 E% O
        {
9 s' v& i' B3 X( F+ W4 O        }
. `1 ]& @3 ?0 |" `; m6 u8 x* d0 P0 t+ u# }
        //-----------------------------------------------------------------
% F8 c; `+ f4 U) m$ T. ~        // Method for testing that class has been reached
7 F' E" Q4 {4 p4 X7 u1 a  n        //-----------------------------------------------------------------        & J) S& n$ X( p7 b, d

3 Y5 [) F7 i- n: U        public boolean ProgramCompareReached()        
+ n6 K1 v! C# M0 K+ B7 I        {
3 S! Y6 W3 J4 f- U/ }) t2 X      try
, v! i# D+ \2 P. n/ [1 A2 _, I  i# _' q8 q   {         , L( Z( b- d' J4 i! b' w2 J9 y
                        / D! O. c; s+ P( V, c! a
                //********************************************************************2 M, B7 W1 A& ^- g' U6 Q
                // Try-Catch Statement is used to handle exceptions - such as file not found
0 W' c7 ~! ~; ]/ I, W6 M                // Reading the files will need to be placed inside a Try-Catch - just like this one!
1 i. }% J! p$ E$ U' B                // For more information see page 534 of the textbook
! L# I$ r( z! P$ n                //********************************************************************
1 g# K0 \( _, g" s$ c6 d                    
$ `. t! c% P% _5 b6 p  ?" F/ ?        }' ]7 P. V; L5 O, E  B- j
             catch (Exception ex) // Exception caught here and message displayed to the screen 6 p& [- ?1 B: X: D; n9 X6 }
          {
- W6 [8 S9 T6 z6 U7 P+ v+ @                    ex.printStackTrace (System.err);! V4 }8 r  W& F( V# P4 N
           System.out.println ("Error message goes here"); // Replace this error message with your own          2 N8 @% ~$ k$ U. ^2 `. G, b+ k0 t
        }
- R7 h: h! `4 i7 }+ k. D) K( p                return true;
7 G9 f- ~1 Y* a$ A/ Z. x. L8 u0 w        }
% E/ S5 N  j; ?3 ~$ [3 H8 L. o/ I  g9 `! o. T$ m
} // end of class ProgramCompare* |) L- |2 j" t' u
; B$ X) q+ y) k, m  r
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************+ U' r" A7 w1 U5 V0 o) e+ [; f2 w
//  ProgramCompareMenu.java    Provided by: DRS% J/ l1 I# L9 x/ O4 p
//  ]3 R( q; V' q" ^! @- s5 \- P
//  Calls AuthorisedUsers.java and ProgramCompare.java
* g0 t' r$ X  `/ z4 K! p/ ?//
. a! o4 k4 r( {0 l; }//  Driver shell for Assignment 2.
. \* {8 y) L& Z* r6 ~$ |//********************************************************************
' S2 l# v$ |* ]( _' A
+ v, x6 Y* c- l/ A1 oclass ProgramCompareMenu" K( A* P1 a4 h3 \" G" o2 x
{
2 r8 w" x5 x  D0 ^+ l    public static void main (String[] args)
3 @; g6 s% ]8 U1 F1 z+ N" V9 O            {
& M/ e8 C. `, ]0 [- w$ P; w                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
3 h" f! G; }, C% B0 g                ProgramCompare reached1 = new ProgramCompare(); 6 P+ t  A: L8 N7 ?) P" y
                AuthorisedUsers reached2 = new AuthorisedUsers();       
8 ]8 G  j3 I1 @# k/ ^8 j                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());: _" ^4 d. g: \; H* v2 _3 p) J; ~, s
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
/ F9 R0 w) E* t) o6 r; B! }        }
( a- j" P1 Q( B! v& M2 l) }}// end of class ProgramCompareMenu9 h, K" R5 d/ E. Q! Z
( Y* A2 [4 R& P! |- C
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
- m1 o8 y& g0 ^, [+ r//          AuthorisedUsers.java          Provided by: DRS/ @  Z: \3 C) S; u' i6 O4 H3 }
//               
+ Y/ V, {  ~* T' J' |8 R- D//         Program shell for Assignment 2
. t7 a" N: G# H  k0 \" d1 h7 Z//( F- S, M$ c# H; e6 h/ p
//         Represents facts about an AuthorisedUser; W( d+ O( o8 ?! K9 p3 V& ?. p' o
//********************************************************************
6 z7 G3 F7 v% a9 X  B
( V. X: v) S: }4 G! ^8 n/ G9 Xpublic class AuthorisedUsers/ k/ F  n1 u1 C; I% Z
    {
* ^; o. y3 N, y( T% p$ \5 j  y2 B
        //-----------------------------------------------------------------8 E0 v7 Z; ^  K! ^7 T
        // Constructor
) Y" \  t: y& N. n; o8 \        //-----------------------------------------------------------------
0 h1 Q# A2 ~# P% f/ U# R* y( d3 C# D0 E0 a7 ]
        public AuthorisedUsers()
+ \' `  o0 {2 Q8 g2 Q* g! l                {
' ^! r5 G: R. ]/ f' y3 v. J                }  k! i4 @" N& j8 p( O* }

' W0 o1 {, F6 l; W5 \( ?) n" y, N        //-----------------------------------------------------------------
& L1 c& o- k$ @8 ~        // Method for testing that class has been reached
0 S$ c  v9 f$ }! Q        //-----------------------------------------------------------------        6 b' d2 |* A! x! O9 m0 ]6 ?
        public boolean AuthorisedUsersReached()/ j" `: K$ {  c, `0 _' {8 X& \7 f7 E7 \
                {
$ z8 h* _0 [- ^6 e                        return true;                       
; ?/ h. ?' M( k% g; A; _                }5 D% H! c  h- t4 T: L% o
                , q: p2 P7 Y! H5 G& z5 y
    } // end of class AuthorisedUsers
9 e* F- Y, S( ?//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming: x7 g6 }; }1 c2 T- H
Shanghai - 2007# z3 R9 z( n* s) @9 x% B% c
Assignment 26 I: J+ w+ m  D* z$ o
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)- K- m5 ?! B  ]0 B( u
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.+ P3 \0 P, n8 q
The staff must be able to:
) m" M  y' d2 j( I Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.% F& m7 t0 y" m3 |
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.
& z  _: `; {7 w  u9 o The interface should provide a menu so that the staff can:6 T8 D1 H/ M9 w$ X/ l
a) Enter the names of the two Java program files to be compared
0 x- s$ W8 `& s, e$ p0 f& j For this assignment, it will be assumed that the two Java program files are in the same folder as your program.! K1 R$ n2 {  p& y4 w( s
** 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).
$ q8 b. y. o" Q0 l  Q, v- DBSA104 Business Programming – 2007: Assignment 2, G; X& R; \* u3 F, X5 @
Page 2 of 5
; c6 Y1 N  q* V- Pb) Print out to the screen all the lines of code that are the same" K2 b+ y" i" U& H" Q0 m
 Include the name of the file and the line number of the code being printed for each of the two files
+ C9 e) K1 d) c" v9 hc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared. C3 d% t: n. P% ^6 f* J* M3 W
 the name, username and department of the user
+ }$ L* Z7 m' J( d7 F  _' `3 D/ H the statistics of the comparison8 x# M$ Q, c& x( H; |4 G3 V
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different0 ^- C& P/ {( e7 G  v/ o
 the recommendation for further checking
" Q8 t/ }- k' f* E- 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
( ?1 c# b) M7 g- P+ F4 M the names of the two files compared
0 m2 h. u( l8 u8 Y# A7 n- `d) Leave the program (exit)
$ y7 P1 [# ^6 y- u! jThe ProgramCompare class: (Total maximum 20 marks available)
6 U0 T7 s0 G- u/ }5 q8 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)
1 v* U: _- K$ {$ O9 ga) provide an error message if the files are not found or there is a problem opening them! A4 b4 z& [* c% x5 C8 c; d
b) compare each line of code
( I) S) ~& Q, q  J8 ?) z' i* Xc) print out the lines that are the same8 H/ ]# W* y2 o9 u
d) count the number of lines compared / lines the same
! g3 \$ U0 b( u2 `- N2 g. l; EThe AuthorisedUsers class: (Total maximum 20 marks available)
4 |& q3 k" Y& }+ G; X3 k; e* o+ V3. 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)
/ |% N6 T0 e$ T7 [! j% V# q& k4. Provide methods to:
8 w" i  V+ L0 |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 match6 ?# Q  R$ N  F" P" N5 N1 K4 |
b) return the name of the authorised user" k0 c$ y* _# d3 @
c) return the name of the department of the authorised user
0 ]$ N5 v; R4 K" N7 O- C4 d$ oIndividual Data (Maximum 20 marks available)+ J0 u! F4 }9 X7 @. E7 w6 d( `
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.# M+ n  U7 p1 Y/ B+ i$ P
Documentation (Maximum 10 marks available)% ]; v  D+ V% U2 w+ q
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.) @, U# J) n9 I: Q- C2 G: a0 u
BSA104 Business Programming – 2007: Assignment 27 _& n% i! j* _5 K  K: A
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
" a/ U8 ]" w1 O, E# }$ _) H% N不过你要翻JAVA的类库说明。你有下载没有?7 g) P. }' t5 o4 g' {- a! h
查询关于对比的函数。貌似关键字是contrast,还有compare
0 X0 p$ \8 }0 d: s
9 Z0 k, ^3 p9 n; R8 q, @) }( k7 n[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -/ R" d! P6 }4 Q/ O
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。1 L7 P" |: z, R
可以下载到的 是 jdk-1_X_0-doc
/ c( M2 N) c# @7 ]3 Q6 i6 B- N# S# p, N
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-10 22:47

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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