找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1403|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急( n: T7 Z7 T! @: j 4 e6 {. Q- h; B! X" R
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
1 D( `7 K; o0 b) c- F//  ProgramCompare.java         Provided by: DRS
8 `9 \, Z% a. F7 V1 w/ u  m5 u//% v) U+ r5 Y1 J$ d2 C
//  Program shell for Assignment 2
( h. z! G! |- ?; K8 r; B//
1 b; Y3 W6 ]( z/ I2 Z% z/ w& K//  Compares two text files line by line
; O5 A  b7 D' o7 _3 s% R6 s: K//*********************************************************************8 J% z) k, I; s2 F/ v

3 I' w9 H2 f9 I0 Q! y8 Eimport java.io.*;5 x6 Z/ M. d. t0 d5 Q

: A; W5 d* g% V# I: g1 C3 Hpublic class ProgramCompare
- t8 p7 m# T! p$ a! N( j/ w{- z# Y3 t+ I& K7 z# _' j4 ~3 B
        //-----------------------------------------------------------------
& Z, a3 f! ?( S6 p' r& ^. X' H  p        // Constructor
- l' e& N. f# ^6 i        //-----------------------------------------------------------------
! x" A8 v9 H% Y# k! t1 R        public ProgramCompare()
0 u4 J) Z- E& q# @        {
0 R6 @3 b  Z; M2 J; Q4 O; U        }
- `% o. ?% P" h7 K: M% U
& b0 Y+ E* z& j3 q        //-----------------------------------------------------------------
4 M4 J: M: M, {& `7 a; d+ h) {        // Method for testing that class has been reached
, a5 M" u1 }# n% M        //-----------------------------------------------------------------       
+ g6 U: R- H3 a7 Q' A; ]! H2 W4 r, _, E0 }
        public boolean ProgramCompareReached()        
  S2 `- }& D2 r& ]/ x9 R        {/ u! f" O2 W3 g% B( K' s6 m9 C
      try 7 K' J1 ~$ G! q! `; }2 [- }6 G+ ]
   {         + C* P& E0 d' t$ F
                       
! l, v& q! F1 @& b  X8 l                //********************************************************************
3 S& M& n  F3 a# I                // Try-Catch Statement is used to handle exceptions - such as file not found 4 B# G1 @2 ^) _4 Y
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
. M) E7 t2 ^* _; W$ F9 o; _                // For more information see page 534 of the textbook3 H* K: t8 m7 m$ U' }8 l" }2 q
                //********************************************************************
( k5 u% e- k( A( N. f/ w                    
  a/ u$ r+ X1 C% X8 P) p- C9 A        }
5 y$ J  e0 c3 X( l8 C+ P) r             catch (Exception ex) // Exception caught here and message displayed to the screen ! U5 w: k& C- K( Q
          {
0 Y/ ?, w; I  i& ^; @" `! R* a$ Y                    ex.printStackTrace (System.err);
9 y; X0 E' }! z. D( H1 y( D; @           System.out.println ("Error message goes here"); // Replace this error message with your own          3 M8 N  p9 h) E
        }
: O0 u' @8 p$ b5 S% m4 \2 f                return true;* d  r) _, `3 J
        }6 t! G( `- m" _& W5 C* d, K3 @: _1 S

2 v4 h6 a8 f) p0 V. U2 j- f} // end of class ProgramCompare
% \& W' v4 w( |  Y5 y2 L7 E5 g/ S
' k7 L, n: j: F5 N& W/ w//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************; w3 V8 Z  J% l0 P& v6 K
//  ProgramCompareMenu.java    Provided by: DRS
/ t, j% n- D/ L) T0 q//
4 |! S* ]8 @! Q$ J- C4 X* e//  Calls AuthorisedUsers.java and ProgramCompare.java4 `$ d, E6 |7 Z! j
//
; n7 r: }; \) r7 _+ ?* U//  Driver shell for Assignment 2.! H) @8 @0 S$ n( d9 K
//********************************************************************
7 x4 {0 X" E& N- _
' [0 \) m1 g0 _; Z$ b) Uclass ProgramCompareMenu5 K1 Q5 V( v. _
{; _7 Z% f  t% o$ d. S
    public static void main (String[] args)
# v, m5 L' L! k, a6 o8 d# |            {& @$ @0 K1 Z3 v8 K' v% J, _% n
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
8 o" o) a. O. y* m5 N                ProgramCompare reached1 = new ProgramCompare();
2 U! o  D3 Y" w* q' a& h9 G                AuthorisedUsers reached2 = new AuthorisedUsers();       
8 e" [! P8 [1 E# t- Y0 S+ b  O" I4 d                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());, b8 f- @. ]& y
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
1 z0 F' b, T6 d! X' ^        }9 N! l  K4 V. d5 E7 u- o
}// end of class ProgramCompareMenu
" k, ]' l: J' K& h2 N
5 k. |4 p! v8 {5 C//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************( `% Q6 s7 F2 e9 o6 q( e
//          AuthorisedUsers.java          Provided by: DRS+ l+ X) |/ f+ X" x6 e
//               
& J1 t! e6 ?. w& x, p, g; c9 H//         Program shell for Assignment 2
( _+ B. w8 S1 |" }8 B" T//  q1 P8 a% J8 a) e# U. u+ ]# [
//         Represents facts about an AuthorisedUser
' ^1 q8 b1 J) p: `! d2 y+ `/ A//********************************************************************0 N& F, s8 p7 }6 R
, B% f4 L/ @- E8 F+ _, u: `; j
public class AuthorisedUsers  H) G# h# H/ @) o2 b( z
    {
; h& o5 E7 b/ g& d& u4 b
+ L* H* y5 x. i3 P# |        //-----------------------------------------------------------------
3 t' Z0 U* O# b' m2 h& j1 ?        // Constructor" J1 q! k; _2 X3 |
        //-----------------------------------------------------------------
/ C7 W) [+ ^# \8 U( J9 |5 U: o; u5 x9 }& M/ K& r% ?
        public AuthorisedUsers()3 Z5 G! [% ?3 m, _: p1 \2 x# I
                {
& D! z5 X& d9 h; Y7 }% C                }
  U' F( m4 ^, c, z: z% o7 M
5 G+ C- t6 H3 v( `- {        //-----------------------------------------------------------------1 o& w* d# `) r1 p
        // Method for testing that class has been reached
0 w! t0 X$ G, R. q/ K. J        //-----------------------------------------------------------------        0 h6 b6 R0 U8 J. v/ Z3 G
        public boolean AuthorisedUsersReached()
6 b% Y$ V4 n) E& D( n3 U                {0 T2 l- }/ U: X, k: c# B1 a+ K
                        return true;                        ' m9 I3 f5 J( q, Y) L/ a7 e
                }( I6 n2 d3 E+ q5 I3 {
               
/ @; Q$ ^( T$ Q# m$ `, b  h0 |    } // end of class AuthorisedUsers& _- j) \- _; u$ x1 ^  U
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming- L; t6 `, G/ P
Shanghai - 2007
6 b  _" r5 |, a1 D3 `7 cAssignment 2: e2 `. C3 b+ K6 i2 Y4 v. `% i8 R
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)
  `: \3 ^& a; B0 X1. 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.% Q+ w5 y) }, [( k* r/ ^# z9 z7 l2 U. o
The staff must be able to:
4 H. L( G: T) ?, H) L: z Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.6 c" s. u% h) V7 E
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." r+ U/ ?$ K- \2 v! h4 b  g/ c8 s3 ~2 `
 The interface should provide a menu so that the staff can:
, {. l" f: k. A* g/ n0 Ta) Enter the names of the two Java program files to be compared
' M5 o# i/ }: l7 S; Y For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
7 `  \' _- ?3 G; u2 c0 n3 F** 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).4 l# X9 k6 H& D# G4 {9 @! `
BSA104 Business Programming – 2007: Assignment 2
" U% F4 g8 s) {, }$ U$ [  aPage 2 of 5) t) V' Q& m4 ~" n! e7 N# I
b) Print out to the screen all the lines of code that are the same
6 \* L  e' W( E* c3 J# i- g Include the name of the file and the line number of the code being printed for each of the two files6 e. L$ E- J2 w/ x* M; ~
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
* D& Q& _& s) ] the name, username and department of the user: ]/ S$ R# x' i
 the statistics of the comparison/ t' b* t+ {, g4 r$ o
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
' O8 e. d3 {- z, s% N the recommendation for further checking
# h. A' ?% f- K- t+ f2 h& w- 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
) {! E! q4 S4 _2 g the names of the two files compared
5 {; G8 ^5 p0 N- C' L# J# Od) Leave the program (exit)
5 P6 W$ E4 o, n6 f( k- C$ P3 tThe ProgramCompare class: (Total maximum 20 marks available)
( z2 P( B1 F) g7 J9 @& b: e2. 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)( A. M1 k; \6 D5 K
a) provide an error message if the files are not found or there is a problem opening them
7 m' s1 y3 b! I4 s3 i$ h' T  |) I/ gb) compare each line of code
. g# ~# b# D' Gc) print out the lines that are the same+ B  b' H% ?& s$ z/ |) e
d) count the number of lines compared / lines the same
, y% H- k" u7 @, W0 `The AuthorisedUsers class: (Total maximum 20 marks available)
4 ], m8 l2 T) f. n- j; W9 _0 `" ~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)5 v8 y$ m4 o- ?. J
4. Provide methods to:
$ o0 P* k/ M4 ?4 S8 ]0 Oa) 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
  {0 f4 y1 y1 i( Y8 G3 ab) return the name of the authorised user
; n' f' O9 J& M& r. Y  H+ N3 cc) return the name of the department of the authorised user2 m* G  j& G+ O9 }  }2 c- r: \0 z
Individual Data (Maximum 20 marks available)$ [" J" M+ w/ e  F( b8 ?
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.2 z! s2 N; ^7 ~$ ~6 A( u
Documentation (Maximum 10 marks available)
! T" a# x* z) B# H6. 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.
8 v5 A7 v3 }2 B% z- rBSA104 Business Programming – 2007: Assignment 2
8 ]5 q" ^1 F. [& w) _1 C4 |  h+ rPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了2 l9 C1 r8 d7 B9 {7 p0 f  f. b$ y4 W
不过你要翻JAVA的类库说明。你有下载没有?, b1 ~2 ?* a( g" g
查询关于对比的函数。貌似关键字是contrast,还有compare
" e# \1 @! r' v; d8 V8 ]2 B! b+ a, h5 h9 k
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -4 X- X0 W7 W0 X+ {: i, y% x$ R6 y  }
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
' y" O  f4 ]4 Q$ Z可以下载到的 是 jdk-1_X_0-doc
8 c) G# E$ q/ d! r" ?
! S& j: d3 g2 i2 U7 z2 D2 _) K[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-22 09:07

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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