找回密码
 注册

QQ登录

只需一步,快速开始

查看: 965|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急0 i. N8 M" r4 {" } ( P9 s9 G. g+ I: y" L3 X$ ~
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************% n7 b" r" Q7 ]' J6 C* N0 y/ F2 F# f
//  ProgramCompare.java         Provided by: DRS  c+ L& h0 K: y, Y
//
( S$ b3 T5 o! Z' k$ M8 ]. W: ]& b  X//  Program shell for Assignment 27 v6 L. ~! C2 S6 o; o. e
//9 u# m5 |# ?4 n
//  Compares two text files line by line* i: w* q0 |$ Q1 a
//*********************************************************************" Q* U1 ]" C8 ~

8 v; |: M* R1 R) limport java.io.*;
$ f9 F  q* E/ E: r# T# \. ]3 k6 @$ G9 L# [9 ^  l$ P* ^
public class ProgramCompare
% U/ P3 }$ g+ i" W1 `! }/ K5 K' A{8 \2 v9 f+ |# z7 `9 C7 \& }
        //-----------------------------------------------------------------
2 \* f" x* s- H8 p, b9 V        // Constructor/ f0 i$ |8 G. E, o
        //-----------------------------------------------------------------
; b' F# b% @& H7 K  Y        public ProgramCompare()" o1 s/ |( {% ]
        {& G" z! J6 n; C: o6 ^5 b( ~
        }$ W7 F) \2 V* \2 g* R7 A! Q

/ C" v7 K3 o( }! @        //-----------------------------------------------------------------+ @) S& V7 }3 y& e
        // Method for testing that class has been reached
% }  b# |6 F6 B  U9 ~+ C        //-----------------------------------------------------------------        " D9 l& h& ?5 G: N: U% O
: l% O5 B" B2 d  T
        public boolean ProgramCompareReached()         & I; |' \7 n9 L2 \* B
        {
& p5 ?1 `; F' h4 \5 ]1 R* u' E* V7 u( v! Z      try * S% W5 z4 }6 Y" T: Q( s! s
   {        
  T, E, n. ^$ `4 |# d0 w                       
/ X! t% K* H& Y0 }8 o# E                //********************************************************************
# G7 k' q; {  l: b' ]                // Try-Catch Statement is used to handle exceptions - such as file not found 8 D- R8 N: B! K( s# \. m: N
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
2 d, y: r* b1 j& k" M                // For more information see page 534 of the textbook
* W8 L, V. X: d* @2 |- A! Z                //********************************************************************  E5 `. ]! r3 g  s. t
                    
1 b; A0 l+ T+ H$ \        }
% a( s! [! K6 k             catch (Exception ex) // Exception caught here and message displayed to the screen
3 [: @3 w% q# O6 }7 j: \2 x+ Z1 e          {
) f: t7 r' L" D4 S& K                    ex.printStackTrace (System.err);
; \4 P* ], Y/ v5 k           System.out.println ("Error message goes here"); // Replace this error message with your own         
$ P' M7 J+ T; R- Z6 W        }
: C; N  V8 c( V7 j& t5 D                return true;
6 A/ |3 b2 R, N        }  \, E2 }7 m# g# [: Z0 x4 V% |

7 ]' u3 V& N$ q; |} // end of class ProgramCompare% s2 T0 x9 P7 G% T. U8 o
" B4 d% `  C+ H, @7 B  G  A4 O
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************$ q( ^9 a7 a; {) P. Q7 ^
//  ProgramCompareMenu.java    Provided by: DRS
3 E9 K$ Y9 t4 e- ~$ P4 y( e" a//
' u5 u! B. S! I5 _, I//  Calls AuthorisedUsers.java and ProgramCompare.java2 ?! t; H* U7 S1 f8 F# h( l6 W
//4 d/ u( h( f3 R! w8 @* D
//  Driver shell for Assignment 2.6 H2 N5 s/ X9 {3 T
//********************************************************************; W) n# k3 ]) C- |# ]

/ N' Z5 h3 e! S: g4 m# bclass ProgramCompareMenu
6 z3 Z. m. s* _8 S3 G: v{0 Z6 X' x& ~' b1 r# l5 N; ^
    public static void main (String[] args)
+ j6 w! _4 u) G- }% M. x            {2 }; g" Y& D% V$ p
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable$ |9 m- ~2 W- [; ^5 }' D4 j
                ProgramCompare reached1 = new ProgramCompare();
: [* }! O7 Y# d/ Y4 a8 ~                AuthorisedUsers reached2 = new AuthorisedUsers();       
  l7 F! i8 U0 I  g  K9 W                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
# [+ J9 B& ~( p( z                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
! t$ Q1 r3 W" k' {* e) @% {5 h        }7 g: ?7 I$ c. B- L. B. h
}// end of class ProgramCompareMenu
, E, O- t( ^. a" G
7 n$ q' R" D: Q- @* [8 ~//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
0 `4 o" {" m; K; a//          AuthorisedUsers.java          Provided by: DRS6 h4 \6 o5 J+ ~
//               
4 h% J. B: T1 o. ^+ S  K" m//         Program shell for Assignment 2
6 S$ O6 h4 b' p6 T6 Q+ U) n$ O//" E) W- V9 a, n! v. t/ S
//         Represents facts about an AuthorisedUser
& i" M# i1 V) u% K//********************************************************************
: }" B2 B' h  u' F) ?! r7 c( s3 {. l; h# w
public class AuthorisedUsers
8 x, q) }1 T% j5 w3 e; |    {' G0 y9 C# G" {
: v" n( R7 X: }0 c' w' H5 u! {* P
        //-----------------------------------------------------------------' \& i& ]: Y4 x
        // Constructor8 \3 A; f- i3 Q; U* B+ _
        //-----------------------------------------------------------------
6 D% I9 e- ]3 B; S5 X
" V8 h# |% s. a: ~, w7 N        public AuthorisedUsers()
* ^5 |# X" ?1 l! f                {" t* }, q! c7 e" h: L2 ?3 n
                }3 O4 q  a6 H1 q/ @: w% Q) C
6 X$ Y3 l% `7 w: c8 X( G! W: _
        //-----------------------------------------------------------------& G: d# d; ^3 k0 T" b; s! f
        // Method for testing that class has been reached
+ Y, Z- o+ S  ~$ l# Y+ g1 b        //-----------------------------------------------------------------       
5 }# `8 S3 s' x' l3 U        public boolean AuthorisedUsersReached(), s4 ]5 G* i! g1 H% p1 S6 o# g
                {" |. V0 L' y5 N' [" G
                        return true;                       
# b# n2 m, k& ?9 O                }
2 [7 q6 f0 u* r' [5 \; V0 x                4 V2 y6 }; Q% q# W9 E9 t4 v
    } // end of class AuthorisedUsers$ ^" ~$ m, G, K" C  y( `; ^7 ^
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming. {" |/ @" I8 p
Shanghai - 2007
/ J6 z8 K0 }& E# MAssignment 2
7 B0 G3 U1 y+ {# GDeadline 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)
2 p- E  }; W% z* W) {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.
2 }4 f( s9 {- p$ @+ n: fThe staff must be able to:
$ L! v* U5 T# q: c% I2 ^8 @- y0 o Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.4 m- c8 w0 y& d# R
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.
* S: t( Y0 m) O1 [% n The interface should provide a menu so that the staff can:0 T2 Q# l. |' F+ O7 T  o3 P5 {9 f
a) Enter the names of the two Java program files to be compared5 \) O2 V9 }# X! v/ D1 v$ b
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.+ m  z3 b/ j. j+ h* }
** 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).
% p8 i$ M& A7 l" X" u# ^BSA104 Business Programming – 2007: Assignment 2% W% }3 k3 V; c3 a( P! [
Page 2 of 5/ u, U$ G2 Z6 |+ n' a& Q
b) Print out to the screen all the lines of code that are the same
  I; n& r7 k- Y8 Q! J2 {" P Include the name of the file and the line number of the code being printed for each of the two files
, j8 W( P) Q: P" n  Ic) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared) M" f* w0 m7 w$ H0 V6 x; m
 the name, username and department of the user
1 ?* o0 W7 N+ H" H the statistics of the comparison( ~" K0 B0 R# n; y
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
/ h9 `6 }" [, {3 d the recommendation for further checking- I' G; x/ ~2 W+ o4 B5 O) n# H
- 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
0 y; @. e* R1 G- _* B+ e  \ the names of the two files compared
0 h1 w2 j) J6 n; P# \  G3 _' ad) Leave the program (exit)
. ~. p( Y( ?" N9 `7 A6 [The ProgramCompare class: (Total maximum 20 marks available)
, r* ~2 t7 a1 W* q! G: 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); f: T% Z3 T4 s6 V8 p
a) provide an error message if the files are not found or there is a problem opening them# `7 [: k6 j+ g# s
b) compare each line of code3 a& M, s' p# G1 F
c) print out the lines that are the same
  d/ }& c5 |+ q; m6 u0 c$ x: u4 {d) count the number of lines compared / lines the same
3 q! @6 a4 D1 CThe AuthorisedUsers class: (Total maximum 20 marks available)
% @& I! a' I$ 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)
9 `# [# Z; C- r' x4 r, ?! e9 V4. Provide methods to:
, @  [8 W" l2 H# }8 ua) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match8 l, ?% G6 `) D3 z
b) return the name of the authorised user. k" `$ b3 j% u; Q8 c
c) return the name of the department of the authorised user
3 ^; ]: R6 O/ @  [; q, I: RIndividual Data (Maximum 20 marks available)2 z6 Z" y% W5 @8 V
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.
8 }) H: @2 P: F( |/ f% A0 @4 NDocumentation (Maximum 10 marks available)5 B( v& u5 m+ a, @# T
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.
" ?+ }  q# d  _2 N+ d: ^BSA104 Business Programming – 2007: Assignment 27 K- e% ~" t% q3 @/ A6 ?+ M
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了- \; [0 D# M2 _& a! _1 N
不过你要翻JAVA的类库说明。你有下载没有?5 M% S) h' @9 q/ b
查询关于对比的函数。貌似关键字是contrast,还有compare6 X) |- Q0 c. O6 X* b3 [
; G- F: l% s7 G1 s& Y" ?/ [
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -6 g. Q8 c8 S! |8 o
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
5 k& o5 u9 _7 ]& |! b' @可以下载到的 是 jdk-1_X_0-doc( ~4 i% z' X, Y% g

: U* ?: I; i9 b) Q+ t  }1 v4 P! N[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-25 01:50

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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