找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1379|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急% k% O; d7 U+ f, Y + }: b0 Z0 ~7 B, Z. J& X9 @
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************( u) b; E1 h6 d, ?
//  ProgramCompare.java         Provided by: DRS
$ Y) H9 A' f0 r) W/ u//
  j; Y5 V  [: @. H: n//  Program shell for Assignment 2" G5 o2 k( g9 O! }
//9 o# c4 y5 q4 Q/ h5 |
//  Compares two text files line by line
, \8 n, {3 i# y  N" `2 b//*********************************************************************
" s# k9 g1 G$ e3 z  P, a4 U  P/ L& i' H" _; @* y- X
import java.io.*;
$ Y2 H$ d- N( N6 e6 `/ |2 _
, [) O+ V* X3 y4 Jpublic class ProgramCompare
6 H+ W- E) F+ c4 s{$ {& a( {2 T3 b1 B
        //-----------------------------------------------------------------
" _/ t1 _5 S2 |1 D( E! q        // Constructor
# r7 [1 z; o! P# Y; {+ E        //-----------------------------------------------------------------
; k2 _, r6 I8 h4 o        public ProgramCompare()
; _" O+ U3 m, P  B) o        {% x. @  e4 E6 q$ ~9 v5 _
        }
7 ?; Y: Y: J. f6 u( ?5 D8 a( x: A" m: _/ s# O
        //-----------------------------------------------------------------7 H$ k6 e) M# @' Y! m: R
        // Method for testing that class has been reached
: S$ W7 R& I: [        //-----------------------------------------------------------------       
8 n7 K2 }  {$ v; E  Y' K% ^" _1 Q# d' v7 ]7 a- H
        public boolean ProgramCompareReached()         9 q! [  R2 |3 A, T
        {. \- k/ Z0 ^$ N5 n
      try
6 h) X: V6 |$ y6 E, G# Z   {        
0 Z- E7 j6 }, {                       
0 o5 y2 z1 W7 i; s: r$ E, _                //********************************************************************4 j1 \: J6 @1 Z' ^4 h. J- U$ [
                // Try-Catch Statement is used to handle exceptions - such as file not found ' H' z5 _# U8 D* E2 V. b- Q+ b
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
0 _6 o. O8 ~5 M) u4 E                // For more information see page 534 of the textbook/ Q3 ]3 u+ l2 {+ t
                //********************************************************************( ^! Q+ ?5 L; t# l5 L! ?7 `7 O
                     8 Q4 _) D9 w- J
        }9 I6 V3 j3 a( ~/ Y" ^4 w
             catch (Exception ex) // Exception caught here and message displayed to the screen 4 [7 g4 V" }0 @& @
          {6 t$ w) u% \0 c$ _
                    ex.printStackTrace (System.err);
) ^4 Q$ F; ^! I, }9 E4 b+ s           System.out.println ("Error message goes here"); // Replace this error message with your own         
, W$ V% U. h9 k( P; \$ ~        }' h8 z7 T0 h8 o9 B" g2 U0 G
                return true;6 {9 ~5 H$ g) E" S! \
        }) l7 F# z5 X8 N# ]
7 X# F  E) X" Z6 e! S) M8 p
} // end of class ProgramCompare3 }% h# a' U' D, P" B

* L+ c' X3 V; }8 f6 ]$ R3 f4 {* H//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
' z2 Q$ n, {$ ]6 m. M//  ProgramCompareMenu.java    Provided by: DRS: E8 u; _- H; m
//% e! P. v; u- m1 E
//  Calls AuthorisedUsers.java and ProgramCompare.java
4 B% t% F: l# G+ I$ u/ _9 [//1 t5 o$ ]: V  {( P
//  Driver shell for Assignment 2.
. l2 S! C' P% K  M//********************************************************************
. t& v# @' e* d5 B  O! @! y; [2 u7 p2 \. Q
class ProgramCompareMenu
% j$ z1 ^& s7 K{
) h  ?/ n* p# ]+ U$ |    public static void main (String[] args)
2 W& z, p( h4 y: Y            {
% H8 k9 ~# k5 x1 n                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
8 }% ~! \  g* H; y; D  J$ J                ProgramCompare reached1 = new ProgramCompare();
( s3 f- R! l, {' H% V9 h                AuthorisedUsers reached2 = new AuthorisedUsers();       
' w$ \" g2 p6 {5 Q                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());- H$ g# r- _+ Y, G  ^2 m& d- Z6 ~7 a
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        # r! f- A6 \  \8 t9 [
        }
% n" P: s. }; v: W% Y9 P9 s/ J" z}// end of class ProgramCompareMenu
6 \3 c" r) y$ ]# s9 m* y1 b* @- T  ?3 v2 s" I7 ]
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
8 W1 ~9 N1 m; b1 H  A& o//          AuthorisedUsers.java          Provided by: DRS, O+ M; [: I# L, _9 F
//               
" r; c$ ]: d& T! X0 V* Q//         Program shell for Assignment 2  ]1 K( E" P+ g9 O
//( i, T/ {* x9 J* T& Y' {
//         Represents facts about an AuthorisedUser
8 ~# f2 m" k$ Q4 v//********************************************************************
0 B# x, b& w$ J$ `) |' c7 G" z. _7 |: _* W$ d
public class AuthorisedUsers3 e. Z+ B% `, v& b- X
    {0 ]( I' i' {6 Q3 z" U( D0 p
1 c) M9 ~7 }6 g8 }2 Q
        //-----------------------------------------------------------------
2 H) M. `* @! g8 }, v. C; Y5 V        // Constructor
1 K5 v6 F% ]: x6 E0 Z: v        //-----------------------------------------------------------------
; f1 ^( H) }( B( |: y* v* ~8 o. ?' J1 B* @3 B' p4 r
        public AuthorisedUsers()$ Z; K: s; m0 V, W- L* d: D7 M
                {
8 J+ r! ?2 }3 J7 ~                }& W4 {8 A1 S0 |6 y/ F) C
6 ^; y/ C' j0 L, k  m" q) p; i
        //-----------------------------------------------------------------
$ T7 _/ ~1 T# }        // Method for testing that class has been reached, n* V+ G& ]  x5 B. R. D& T
        //-----------------------------------------------------------------       
% d$ g3 A4 Z# `: k        public boolean AuthorisedUsersReached(); A3 z' n; g8 v2 T( U
                {
& v7 t' S9 {7 m                        return true;                       
7 q& c1 u7 |+ K5 c, B' q( `                }; a( [4 _" I; B/ n5 J1 j
               
# @* }! [, \( n2 A  d    } // end of class AuthorisedUsers
# q1 e8 d8 d3 v% u; ]6 X, o//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
! e; o2 N% j( b9 d" s2 XShanghai - 2007
: [6 l6 x! q2 A, U3 QAssignment 29 K# N. o, V* M4 J& C7 f2 ~
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)/ n( W/ ]/ E' R5 f. `# G
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# n! R3 {2 d" |& \! n' j( WThe staff must be able to:3 Z( o# x7 k$ y0 @+ n  Y* v7 j
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
! C) u8 H' r9 \/ v1. 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." d2 _. }0 t0 |
 The interface should provide a menu so that the staff can:4 F6 K+ j- u! p1 J3 b( [
a) Enter the names of the two Java program files to be compared
2 j: r9 ?! v) i For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
1 u$ r& T# h) }/ G4 }% }% b** 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/ v3 O: |+ I& y- o" e5 [
BSA104 Business Programming – 2007: Assignment 21 l& K* ]" ]2 B  ~2 g
Page 2 of 5
. U! Y+ x) _4 F* m& `1 ^, eb) Print out to the screen all the lines of code that are the same
& z) {4 t! b2 P% {6 T Include the name of the file and the line number of the code being printed for each of the two files
4 I( R  o3 R& M# [$ yc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
# G9 B( [/ U% h  H1 N) ` the name, username and department of the user
$ W- S  J3 O! W3 _4 Q6 b the statistics of the comparison
1 T' E! A, M0 |) [" P- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different" c( i# X. b: ?( I1 z( z
 the recommendation for further checking' R, {3 i9 O: d- u- t, F( n
- 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  m" l/ |3 X- S: p; O
 the names of the two files compared, @& z! t8 X7 }) h- j% K3 ~- P! `- k
d) Leave the program (exit)# E0 \% I* E- J3 p+ Q7 J. [
The ProgramCompare class: (Total maximum 20 marks available)  x9 s) W! A: ]8 L* t3 }6 u( m
2. 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)
7 L( v3 U* v9 j8 d0 r( u- o: Ja) provide an error message if the files are not found or there is a problem opening them0 i5 y& O) x* O" G& W! o# \7 @( o
b) compare each line of code
1 d% _8 s' u( d7 d9 @c) print out the lines that are the same5 c1 ]4 \3 q; j0 g8 a! F6 N% x
d) count the number of lines compared / lines the same
+ e- A) D* e7 n1 iThe AuthorisedUsers class: (Total maximum 20 marks available)
2 ~0 {. e; }; H3 N( R4 }3. 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)
2 p& C9 B( a* y4. Provide methods to:
6 u+ [1 K. p% ]* k8 c8 _" aa) 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
( d+ r3 g6 }& O* k- L2 w8 rb) return the name of the authorised user/ p0 x8 F4 z3 q% e8 f# l4 E
c) return the name of the department of the authorised user" P7 w3 W; S; U
Individual Data (Maximum 20 marks available)/ Q+ W1 r/ q0 G7 i. ]$ q9 o
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.
" y2 r: \: U: B. @, aDocumentation (Maximum 10 marks available)
0 b5 I' x# w- w4 D9 K" ?, x& c- ~4 y; a6. 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.. @/ C3 {0 U9 Q: x% l( I
BSA104 Business Programming – 2007: Assignment 2
2 W8 k" T. Y7 C4 ^; EPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
8 V3 }. y7 E$ S7 }不过你要翻JAVA的类库说明。你有下载没有?
' ?1 s4 x; A8 N- ]: ?8 e查询关于对比的函数。貌似关键字是contrast,还有compare+ F3 f2 L9 S' x  V! f( r
# N0 P2 v( S" f* M
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -* }" g) J' ?6 m+ l, J$ d6 N
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
$ h# w5 ^9 f) S, _  c- I可以下载到的 是 jdk-1_X_0-doc8 y" z3 B) _0 l$ E) ~+ i& y
) T0 g. j, F! N' d7 Z4 K" T
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-12 22:29

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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