找回密码
 注册

QQ登录

只需一步,快速开始

查看: 946|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 % L- E( `# G I ) q: \/ B- e5 w# ^+ f7 z8 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 | 显示全部楼层
//*********************************************************************, I4 }( n+ I# _( h/ p$ [# |
//  ProgramCompare.java         Provided by: DRS
  |1 h- k& @6 @5 s  U, k4 A& R6 M7 r//* L  ]0 S" X/ l, p1 P1 l+ P
//  Program shell for Assignment 2
: u5 d/ R: {3 A/ p$ d) J//% T* ]8 l9 [% ]& `3 T7 n8 _/ v
//  Compares two text files line by line
( W, H. {6 c5 a5 J//*********************************************************************6 u: G/ ?9 n- U- x3 V$ s

: p4 h- u6 c8 Z* |! J& h) s- Ximport java.io.*;
2 G' m1 B  A. H8 e& o; G2 g; u- n8 r1 |) C2 K! b- U- M5 M
public class ProgramCompare* s! u/ m6 O9 x# [  k; J- T
{6 o7 C" P% i% Z# U4 g7 G
        //-----------------------------------------------------------------' _1 v2 M7 N* D! U1 w; V* c9 J
        // Constructor( ]" J1 d- Z. |( o/ x
        //-----------------------------------------------------------------! u0 J! g# |# }9 W
        public ProgramCompare()3 G; \; s: m' v% \) d
        {2 y! [# D# ?& T  F* p4 C
        }
& v# G  c2 `0 {2 }
' B' W# s! ^1 I/ V; D7 P4 y        //-----------------------------------------------------------------/ ]" m+ N% ~! z( E
        // Method for testing that class has been reached
! T* I. |  a* ]) ^$ c) z$ M        //-----------------------------------------------------------------       
% T* n1 O. N! K/ h; c) I1 G& V
        public boolean ProgramCompareReached()        
9 T$ O# j( j; F  p) I& L. D        {
$ U0 k+ B# _; K  Q& G# e/ \; T% Z4 D0 G      try
/ w) d, ^! R0 Y5 d  i: u   {         , D0 g2 \! b9 j! |, i# ?  ]
                        ( f/ _8 h6 m7 w$ k9 g4 e
                //********************************************************************7 h8 L4 _, h8 c$ W
                // Try-Catch Statement is used to handle exceptions - such as file not found
+ F4 v  n  e' _1 w6 y                // Reading the files will need to be placed inside a Try-Catch - just like this one!
8 e1 C7 l- ?. ~2 c                // For more information see page 534 of the textbook- R3 J7 h/ G% A9 N8 t
                //********************************************************************
( h8 o' G7 N5 ^                     / q$ p% V9 |" E* d; M2 [1 y1 _& N
        }8 W* I  H4 b' @
             catch (Exception ex) // Exception caught here and message displayed to the screen 8 n+ J( _( i4 j" p+ N+ S; s
          {
2 G" K4 k' L& Y9 I                    ex.printStackTrace (System.err);) j2 r3 G# P  W7 y7 Z& U
           System.out.println ("Error message goes here"); // Replace this error message with your own          - L2 e; g  E% o* U: M' m
        }
+ |8 e2 V* V. s- v! g' n0 L* u  Y                return true;
: s! u2 i2 W3 L; s: g0 ]        }
! o, q6 {0 r( }; ~' G$ {! K$ d) x9 g( B, N
} // end of class ProgramCompare3 b8 ]$ O  w0 X' [

- ?1 S* l. `' `* b" H0 l! A//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************) K& f! q; P$ C2 ]* ~  |0 b% W7 l7 W
//  ProgramCompareMenu.java    Provided by: DRS
) C/ \, L+ x  h# z8 a//3 ]! I6 X! h! {/ b, b$ [
//  Calls AuthorisedUsers.java and ProgramCompare.java  x. z5 d# d7 w. O0 o/ e/ N
//$ ]7 S. ^1 {0 s; n
//  Driver shell for Assignment 2.8 W3 q& Z/ ~9 Q
//********************************************************************
( o/ a  K4 U- F$ w+ e9 B% ^0 S
class ProgramCompareMenu
0 M6 H9 v  z) e- ~6 ]{2 Y" d* _1 }; e
    public static void main (String[] args)
; ?% c6 Z, E: s1 D! E- }/ C: ?            {
  l) T8 b# n4 ?5 s( `2 q8 `! {                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
* N7 B$ q$ I+ r2 |/ g                ProgramCompare reached1 = new ProgramCompare(); * w+ A6 L( Z7 q% a$ G
                AuthorisedUsers reached2 = new AuthorisedUsers();       
! V$ u6 x+ Q% f7 g/ K" M5 d" q' _( p                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
6 [  e2 B' M0 u1 L. Q                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        4 @# S/ a7 }9 Q
        }
) }0 b: N  j6 f5 R}// end of class ProgramCompareMenu
/ `) l6 p* J7 v1 }9 z1 L/ p
# m. t2 R- e5 [- r//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
3 S/ L$ H$ a" ?: l; k8 }//          AuthorisedUsers.java          Provided by: DRS; B, j1 S( l! j3 `8 K3 k
//               
" a* n4 [3 [' g$ h1 c" ]//         Program shell for Assignment 2& c7 L/ |; F5 v+ |, J3 U
//
+ m' @8 H3 s. v) I9 }2 w- y9 G' E# s//         Represents facts about an AuthorisedUser
3 ~% B" h. N( U9 A//********************************************************************
. m% I9 W( U# [8 M: B' F. X1 ^2 D( D/ m4 q3 T
public class AuthorisedUsers
* I6 y4 P' J' U, m% ]    {( m. e/ [8 R/ H. a0 _" k8 T( M

& q" B1 Y' ^. }; W        //-----------------------------------------------------------------
7 ~( i7 \1 \+ \7 }- T. E        // Constructor% }0 f; [: |+ f9 q, s4 e5 ?! v6 G
        //-----------------------------------------------------------------' x; t9 [9 M# A8 S/ m2 [, q

, y; ?  @1 L+ I% o' j" ~; [        public AuthorisedUsers()5 d: D1 Y! U( q6 c
                {/ Q/ \2 v& X7 s& ]5 I
                }* u8 \& j, ^6 U/ H8 l1 G

8 }: r- x: J1 R, i# D+ X4 e        //-----------------------------------------------------------------
5 A, P; y9 B& R' \9 @% d& E        // Method for testing that class has been reached4 f9 W9 g( A0 L0 X0 l3 f
        //-----------------------------------------------------------------       
) l* Y3 l# \# F* w' U# x        public boolean AuthorisedUsersReached()* t/ n; d; }, ^, n7 o! L: m4 S
                {/ Y, R1 J6 [+ T/ J6 b" R6 ?
                        return true;                       
3 a' V+ [$ V* F0 s                }4 m# R9 ^# g( z; E
                / n: i3 C8 z' @% H
    } // end of class AuthorisedUsers# w; G7 J( `$ i' _0 n" {! t" _: X$ z
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
; ]( s, I0 o- LShanghai - 2007
+ s3 ]4 y3 z3 c' vAssignment 2
. a3 e4 F* _7 eDeadline 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)
: A( |; n$ t8 Y' T# X4 A, L1. 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: H1 j8 ~; g& R$ B% E! |
The staff must be able to:
- M0 I4 i  D; N- H5 {% S' e4 q Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.  l) Y  v- E  W1 z4 w* d3 Q1 s6 W
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.
3 C& x5 l7 \0 w4 M0 J% x The interface should provide a menu so that the staff can:
! E% z+ p5 {; y" u9 n0 Ua) Enter the names of the two Java program files to be compared0 s1 R+ r' t: U7 z+ l
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.$ M( I6 F/ X! T, L/ e7 q7 t
** 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).
9 q* m! Z7 \) i) d" C) q8 TBSA104 Business Programming – 2007: Assignment 2
' ?; \* S1 H( p, _9 kPage 2 of 5
- e; y4 K4 {8 F3 L6 n% Z) r/ rb) Print out to the screen all the lines of code that are the same
! h6 k4 e0 o9 H; G9 X( d8 g Include the name of the file and the line number of the code being printed for each of the two files
3 L4 u5 S. W1 G: Oc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared" `4 u4 D% y  C. r, e: W9 `* Z
 the name, username and department of the user" D1 A, G- q- g/ f" N9 P
 the statistics of the comparison
  o0 D- g6 Z; q+ F" a9 k7 S- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
( I3 x+ W) i/ Z+ W7 s+ S* u) _* A5 K the recommendation for further checking
/ [! c1 Y) M# }( I* K! M- 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# K+ P. r( J9 G# a$ M$ d
 the names of the two files compared
( u" z! q/ W, W+ ]3 l) gd) Leave the program (exit)
, ]6 g3 a5 K1 B# x+ D& p# i, ^The ProgramCompare class: (Total maximum 20 marks available)8 ]3 i) g: j- L1 q& B' F
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)( _- P3 t8 ^- Y
a) provide an error message if the files are not found or there is a problem opening them3 J! S2 E  \" K4 p
b) compare each line of code9 u2 }, `. t- j8 s3 }/ }. S" t
c) print out the lines that are the same
/ A$ g' h: K  k2 W6 [$ [; M5 K3 Od) count the number of lines compared / lines the same7 E/ L9 }9 p: A; I4 Z& N: j
The AuthorisedUsers class: (Total maximum 20 marks available)
7 Z. n' v! z& J3. 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)
7 H1 ^5 j) i9 @& v; v( ~* }. n4. Provide methods to:* D' h2 ~1 K2 M3 Y; Y2 q4 G
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
, H3 L3 S% ]5 i1 K5 jb) return the name of the authorised user2 o% u; k  E- H0 ?# N, F* u6 u
c) return the name of the department of the authorised user$ f- I: a9 f( O) A% b1 |
Individual Data (Maximum 20 marks available)
2 A. B/ i3 S$ |1 ?# w5. 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.7 `8 k5 y3 ?6 o5 k1 T
Documentation (Maximum 10 marks available)" G8 j+ B; T' e
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., Q6 M! d8 T7 P  J  W! ]
BSA104 Business Programming – 2007: Assignment 2
4 n8 \3 R6 @5 I* D. sPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了( {+ J; T# E6 e4 K8 @
不过你要翻JAVA的类库说明。你有下载没有?
$ `# k$ O. j5 \. O  `; N查询关于对比的函数。貌似关键字是contrast,还有compare
! w: X) O# L& P: H8 ]
, A; l% [- t" `/ i[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
4 _/ c& h3 s0 j- i! [8 L痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。3 |2 `" K  ~8 @& f
可以下载到的 是 jdk-1_X_0-doc, F3 [) }6 b# v7 ?
! `- B1 {7 O. A( C8 p# S* c
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-16 08:04

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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