找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1003|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急/ i- H6 g. P* [; K+ T7 I6 R- T . J, e. | D! z. s+ M6 B
回复

使用道具 举报

 楼主| 发表于 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 Q% }0 k: D+ ^, H% x
//  ProgramCompare.java         Provided by: DRS1 A( D) Q8 m. G  V0 @% ]
//
" v# O; e) x4 |//  Program shell for Assignment 28 X, R! i) q7 v2 S8 Z& Y  T
//1 b8 B( d4 E+ l1 U1 h) ^; [
//  Compares two text files line by line
+ J& g+ G: k7 b# t; }) E, C( y//*********************************************************************
: x0 ]4 N" h6 y( r+ H* X$ ^6 a* _( T% {+ ^! J0 t# x1 A# [
import java.io.*;8 k0 u; J0 K0 y
; _+ h3 \3 C0 C7 a% B
public class ProgramCompare2 o/ G% V4 O) e
{
* p8 J! }& ?2 Z, A, F& ~: g* v4 N' P        //-----------------------------------------------------------------5 K. g# q5 I! e; T( [6 k* `5 ?
        // Constructor5 A: Y9 e, _1 t9 k9 x$ O
        //-----------------------------------------------------------------5 {! d9 |- j. |
        public ProgramCompare()$ z0 M4 `0 E, t" ?1 N2 T
        {# ^  A, z9 e  F! i$ r5 A
        }% v! }1 D! s+ s6 n3 ?* @
5 ?  q- P7 p, H$ w- g2 [
        //-----------------------------------------------------------------" C; k! a2 @5 q. p
        // Method for testing that class has been reached, a4 V* ~# p( P
        //-----------------------------------------------------------------       
! f; J6 b6 Y7 ^* }6 g2 m  |/ T
, p3 X$ B/ y* b, f        public boolean ProgramCompareReached()        
* `6 d- ^0 ?$ v, X        {5 p# o) }, H! I3 a6 I
      try
, R% c# N5 V' b% q2 ^+ O; }$ p   {        
' Y& S$ o  Z, O7 c; g0 ?2 S                       
* ~. ?8 b8 ^* G$ z, N: L2 q                //********************************************************************
6 w4 x5 r% I! b; N7 S0 r9 U4 [0 \                // Try-Catch Statement is used to handle exceptions - such as file not found
, O3 \4 m) v: G. @1 q- \                // Reading the files will need to be placed inside a Try-Catch - just like this one!6 X. y0 p1 ]. o# q5 C8 b
                // For more information see page 534 of the textbook0 q5 ~" ]% @4 \! `0 x( M
                //********************************************************************, A" Q1 w& W$ y+ m/ V( C3 I
                    
1 |7 \  \* |& {' R6 t        }
& ^4 z4 P( e- R- ]+ x             catch (Exception ex) // Exception caught here and message displayed to the screen
  W! |! w  f' |& Y          {% m3 ]8 H5 K8 D
                    ex.printStackTrace (System.err);" l8 v! A0 y4 }' X: n% ?) J4 G' n1 @
           System.out.println ("Error message goes here"); // Replace this error message with your own         
% v) R7 h4 x7 y2 f        }
- d5 J) S$ Q: P. n                return true;6 Y! Q$ l: h5 @1 g3 x" ?& @
        }* M1 K: p3 W$ ]4 W1 _8 }4 n
3 a* ~% `3 y' r5 \/ O
} // end of class ProgramCompare
0 R* [2 z* {( j6 ]& j& H. M0 |. ^/ K  s8 ?* F: R, ]  j3 v3 b! J
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
* F4 y7 U$ v  m( e+ P$ }//  ProgramCompareMenu.java    Provided by: DRS$ ]. t7 V4 Z2 q4 [* K7 U' g
//
9 C$ \3 c7 u9 C( V/ y& z, R4 o. [//  Calls AuthorisedUsers.java and ProgramCompare.java
0 \) |: a& s7 y+ T* w  s5 ]//9 ^& k$ R+ d7 t" r1 \  d4 v
//  Driver shell for Assignment 2." K( B) C0 L7 D1 F1 a! K/ y6 q9 K2 H% }
//********************************************************************
6 Q1 N  ]/ X+ f5 X8 |( `
; t8 x9 S# S1 }9 ]  H" ]1 h% \class ProgramCompareMenu$ a2 ~* Y( u* q5 C# ^# M) k
{
/ \5 Y. n: w( S' k, [/ a) N    public static void main (String[] args)
5 A" T9 a; q6 d& }            {
8 f; m3 H1 Y1 M0 D  G# `/ I                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
& ]/ @+ ?# m" p                ProgramCompare reached1 = new ProgramCompare();
; x8 q" t1 k& o, B# K                AuthorisedUsers reached2 = new AuthorisedUsers();        , o9 Y% x6 Q6 @) z
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
+ P3 y- P8 R& @! N8 W; h0 K4 ]                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
! t7 I. K& x' s6 x. U        }7 `2 a' `0 S# j; @) y  \1 s* B
}// end of class ProgramCompareMenu
3 }& ]+ {1 g7 j3 g3 }& l: N3 t' V9 q( O2 \2 F) \( }
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************- x$ u' z6 r* v! k& v# k0 O
//          AuthorisedUsers.java          Provided by: DRS
( W. N2 ?9 [& \7 Z' o' _+ \# h+ v//               
  Q. J: x8 k: _0 L7 E  {//         Program shell for Assignment 2
+ e) v& H( s( b//% L) ?: y$ V7 |6 s
//         Represents facts about an AuthorisedUser
6 T# H5 W  \9 P* s//********************************************************************# c8 j5 o/ R& s+ f1 D+ [7 y0 R9 ?& |
% Q$ z; R1 x# V
public class AuthorisedUsers& x! n7 ?! h: E: W/ g. A9 M4 m: |
    {: E! Q( x6 u; q1 e% d

% c7 _. U$ l+ F: l5 t! ~5 C        //-----------------------------------------------------------------
* \( ]3 G" \/ j7 P        // Constructor
7 f! Y5 c8 X5 \7 K4 U        //-----------------------------------------------------------------
8 c1 P/ O& G$ i3 v: \) |4 K: J  i2 V; B/ q7 z3 M1 ?, J
        public AuthorisedUsers()
' Y  r& ^/ B( d                {
9 s; V* @0 G% W; ^$ f" M# F) Y                }5 S* N  ^; S) H. l) w( M; W7 q% ?& h
- F( U/ O$ o1 ~6 ]
        //------------------------------------------------------------------ w# A, ]3 m! G7 ~
        // Method for testing that class has been reached
! ^& Y. ~; G- y# |* n# o6 K        //-----------------------------------------------------------------        ) @+ c/ c3 V( J7 S
        public boolean AuthorisedUsersReached()
" V/ a5 Y5 g. Q% v  d) ~                {
6 K) K$ v7 Y. n$ m) w: w- R5 R5 ^                        return true;                       
5 D5 H6 y" l* F; H                }
8 _4 Z, U$ M8 F& ]; Y8 d                6 t) W! o8 l! J0 u
    } // end of class AuthorisedUsers
8 ~; a% ]1 o8 F) U9 _, h. B2 K//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming. f' u4 d& Y4 A
Shanghai - 2007/ o" j( V+ p+ b
Assignment 2( D- Z3 r4 b/ S! `8 _; u+ l" e! T* C" C
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)
- f6 v0 p) E! b5 D9 |2 \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.4 v& g4 P$ p! Z- w0 {+ }6 z2 n
The staff must be able to:  ~, C  L2 u& K2 Y# \
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.: T& E! X: |* O% n& Y" b5 w0 S
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.
! O3 q2 x  A% i- f: X7 M/ s+ y The interface should provide a menu so that the staff can:6 n+ ]' q& v9 [8 S( a" z
a) Enter the names of the two Java program files to be compared- H8 ?$ H7 X, t
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
: l* p' n+ Q$ [2 w! O1 k** 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).
+ l- J! m( J+ H; F2 \! p; v2 LBSA104 Business Programming – 2007: Assignment 2
1 r# y3 K! @. K1 r2 _Page 2 of 53 s5 i- ^& t  l/ s
b) Print out to the screen all the lines of code that are the same/ w. Q# J+ Z7 u* U; |! q
 Include the name of the file and the line number of the code being printed for each of the two files. a/ J4 g) Z) q2 B
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
, i0 K0 G) \, Q- w& K+ ]+ E the name, username and department of the user
  t7 c# R7 z  [# ^/ X: ` the statistics of the comparison
* f+ t9 n! K( n" K2 C/ h  [: k7 `- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different8 Z6 o  c# c* _+ N2 e
 the recommendation for further checking: u3 {6 K# {0 r6 B
- 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/ l5 f- z6 I& d$ [3 K
 the names of the two files compared
$ E2 [+ i$ k* W6 id) Leave the program (exit)
% a4 @  r; h8 W8 z0 u1 J6 K) }. IThe ProgramCompare class: (Total maximum 20 marks available)
' {) j, l/ M8 X- P& 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). o/ N# V8 k, Y( A
a) provide an error message if the files are not found or there is a problem opening them
9 w1 t0 M) q1 b' j% R: s& ^9 y/ [) ~b) compare each line of code
* n) l" F9 N; d( V& O+ ac) print out the lines that are the same
( R7 A+ l& t: o$ `6 |d) count the number of lines compared / lines the same
; }8 i7 V$ L' O( R+ RThe AuthorisedUsers class: (Total maximum 20 marks available)' e0 N2 c; U/ q/ M7 j7 V8 t
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)3 V5 d( {/ ~1 X+ i
4. Provide methods to:; ^7 _7 H' I/ N' A/ _
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
; B9 P2 K: _: K9 Rb) return the name of the authorised user9 ?; s. [5 @9 g
c) return the name of the department of the authorised user7 G  r/ ^1 w0 X( e
Individual Data (Maximum 20 marks available)
8 M" j2 a& A4 D  A5. 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.1 s0 W4 e9 c9 k+ d) s2 M
Documentation (Maximum 10 marks available)
8 I% O; y, `8 @5 N! x+ s  m3 o, O4 z7 z6. 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.; i# T  c6 w7 r* @" j# b- f- h, m7 W( p
BSA104 Business Programming – 2007: Assignment 2
: H7 H6 q& i7 s3 K) w. @Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了5 \7 v$ R: p' ?8 A4 e/ X) r# f8 G4 F
不过你要翻JAVA的类库说明。你有下载没有?( ]  \% e# P) B
查询关于对比的函数。貌似关键字是contrast,还有compare  P1 O* o1 X; ^) |& A
8 g  o3 w8 X0 i4 c
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
4 M( F! `$ L+ b+ P3 [# a痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。4 B" P: T2 P% r) U" ]
可以下载到的 是 jdk-1_X_0-doc9 f4 ]3 V4 b2 x( I5 c$ _8 \

2 R: V; h1 v' Y4 t[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-7 14:29

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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