找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1717|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 * f, }+ ~3 v* |) G" S" ]: n/ [ % e( V+ ?0 T0 _9 I* H! D; Y
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
. k0 l  R3 }- o# b. z9 Y  G# L//  ProgramCompare.java         Provided by: DRS
2 D$ t6 H8 Z0 N. T//0 z  v; m) G6 ^4 v; g- Z, o
//  Program shell for Assignment 2' {' T( K( A0 f/ B) K0 b/ k4 N' D
//; y4 g- R- }2 F
//  Compares two text files line by line2 S" q, }1 s; }  ?: j
//*********************************************************************2 G) Z  D6 @+ b  X6 J
! Y9 E3 F+ C) C: Y
import java.io.*;8 F7 Q' x3 {- C* I! M; u5 M2 Z" H1 o

  F3 W2 }% r! v/ T: ^7 U# `5 ]public class ProgramCompare2 s% }6 @1 g2 B5 {
{2 d/ N( |& E/ i6 Q: R" y% l
        //-----------------------------------------------------------------9 ~7 X. A. i: `% x4 I. |/ X9 q- x
        // Constructor' A% q8 F# X7 c* |6 j
        //-----------------------------------------------------------------5 m( f. D+ i0 {! j/ ^
        public ProgramCompare()
& b4 G: T) S8 I0 B+ ]        {
$ O' {7 _1 ?- @3 X        }
6 B2 d; B  y  a
* Z# f8 q" m2 W        //-----------------------------------------------------------------" Y3 q  Y0 ^, B/ m
        // Method for testing that class has been reached9 V; y' K+ Q1 t7 J, U1 M% \  X+ f
        //-----------------------------------------------------------------       
  M' z+ J2 V) @5 x2 @5 x# l. V- ?2 m* e/ x
        public boolean ProgramCompareReached()         % r+ U3 `8 m1 M6 s5 K' i' n* j1 ?
        {! H; b3 w6 x1 r& O
      try 1 K3 g. A/ T- M, g4 o
   {        
! t# i8 @6 E8 O$ c                        8 x% b) ]6 @2 |% J! |
                //********************************************************************
& a1 ~: a& E/ e7 T" x  I$ M                // Try-Catch Statement is used to handle exceptions - such as file not found ! }3 C8 N! e" }! y
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
4 Y$ W! V. c  r. l0 Q                // For more information see page 534 of the textbook% t6 |8 f: y2 R! y1 V; f
                //********************************************************************% u: _3 x2 B0 T/ F* |6 |/ y% @
                     5 q4 h! T. v5 n9 E+ E
        }  }9 Z% e! d( P
             catch (Exception ex) // Exception caught here and message displayed to the screen
2 Z& }3 i" O. G* |: Z$ ]          {
% C/ `% i, q- {- l/ p                    ex.printStackTrace (System.err);
5 u! p0 g5 A3 N2 }           System.out.println ("Error message goes here"); // Replace this error message with your own          & W" h, w" J, z7 O6 u; U- b$ ~
        }
5 {+ M& W; {, C( F, E/ i                return true;2 j" h5 Z, a- S" [% R  o( r- C# I
        }( a* K+ i0 e8 D- c. X
3 E0 e  m" T& E) T
} // end of class ProgramCompare
$ E7 G6 v4 U& Y' G& m' [/ r8 r$ O$ `9 A, s
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
9 {& j8 I. U6 O  b9 R" g0 C//  ProgramCompareMenu.java    Provided by: DRS
& M% D7 d. L( H2 f) {& j; p//
- O: k" o6 d. G% w& m8 _//  Calls AuthorisedUsers.java and ProgramCompare.java
) A. K8 y, \2 k/ F& [' m//) K/ M6 D! V% f! h4 {  H$ n/ k
//  Driver shell for Assignment 2." _6 [/ M9 `  [( U. M! m7 a& ~
//********************************************************************, `8 c# J! p% l; |8 q$ X$ t6 D4 B
  `: |" }, [9 C' D7 [
class ProgramCompareMenu
2 G, J" g8 a! \: V6 a# k; c{1 p; U6 |; K  D! \2 k
    public static void main (String[] args)
0 T+ Q4 t8 `4 o) Y- a6 q' j            {9 J2 `7 [3 s: O  i
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable6 d/ f8 M3 R! o' t! W
                ProgramCompare reached1 = new ProgramCompare(); ; ~8 e5 E& q! Z' i, a; W! {
                AuthorisedUsers reached2 = new AuthorisedUsers();        + ~" ^: f* M* I
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());4 ~1 N3 k7 n( ?% U: r0 a
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
3 p7 ~' q4 y* Z        }
3 p  B* ^6 D3 H* o# g, I% z% C% P}// end of class ProgramCompareMenu
1 A8 a3 ~8 R! e4 V+ c5 F, S0 @# m( q
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
3 R! m/ {' D  A7 Z& B//          AuthorisedUsers.java          Provided by: DRS" K  S: w8 i3 S: k9 K  t7 u
//               
3 p" [- v# o1 I5 a//         Program shell for Assignment 28 e( R; B+ `/ H' o
//  G0 Y3 H& c1 l! y3 h7 U
//         Represents facts about an AuthorisedUser. L9 c9 O$ q" D, Y! P( Q5 D
//********************************************************************; u) Q0 T# }( K4 r; Z2 Y

* ~) n" u7 s6 i3 X: Npublic class AuthorisedUsers
, ?- u6 v3 o& v7 t* a2 |9 B6 h    {6 ^0 k  ?6 g# V; E) W7 W

$ e( i4 l% ^8 X3 d/ Y        //-----------------------------------------------------------------
% s6 O/ B0 P7 R$ Q        // Constructor' z% D, Y4 w1 c
        //-----------------------------------------------------------------
6 o/ q: p7 {9 {- W4 T% V" z
' Z6 Y$ p% a) x7 x9 S# t( v) y        public AuthorisedUsers()6 m9 x" E! q, N/ r9 Q; ]  ^
                {
: Z0 Z# ]9 N9 C  ]! V+ G                }; l# p+ F9 C5 D( Z$ `
; ?. X/ d+ j: j3 l$ ^! E+ v, ]
        //-----------------------------------------------------------------
! n3 \) Y( ]1 D5 M8 E4 A        // Method for testing that class has been reached
( e% L% N8 w! ^/ U; g        //-----------------------------------------------------------------        3 D2 a2 m4 o: `; z- I$ ^
        public boolean AuthorisedUsersReached()) u- {2 r4 z& m% g; z7 N" h0 P
                {
1 U& A2 {+ u& Z8 N( ~0 U- g: x: U2 K                        return true;                       
8 b2 \" D; ?; h: `/ C7 h                }
: L' ~  b! d, _- e  w" |  E                5 G. i& t! j* m; f! I/ Q! B5 l: D
    } // end of class AuthorisedUsers
: z2 l, W  O8 s4 L7 H% a! |//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
! I, ^: b/ X, u0 FShanghai - 2007
- W# l; Z2 L. W* I/ AAssignment 2$ T/ M& ~( \( y% \
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)' x' g, u! h3 v* N5 B7 z6 X4 Y% H
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., v+ V" w  e) q5 K% C0 Z
The staff must be able to:
: J& y9 ]4 O& f& M: i7 V2 u Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.1 s2 a; m* H3 ?4 Z
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.- c/ R2 p) c: k+ B
 The interface should provide a menu so that the staff can:
& n2 A% ^2 i8 Q: W2 h. r& z: ma) Enter the names of the two Java program files to be compared6 b  e. V/ Y" F" R# b! A
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
( y" o4 w0 l. u3 `$ H/ D. ^4 N9 L** 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).
3 P' `% b0 f8 [$ Y9 q2 K0 m/ Y/ oBSA104 Business Programming – 2007: Assignment 29 D: n6 ~& i$ X0 {/ k5 Z2 I
Page 2 of 5
$ S( z5 [  Q. C, k2 }b) Print out to the screen all the lines of code that are the same& C8 }# \  B3 L$ V- E
 Include the name of the file and the line number of the code being printed for each of the two files
* K5 X1 S3 U3 @: B, Y! i. Ac) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
& l& J; ?: J) d the name, username and department of the user; P& U0 v: H7 Y% C2 z
 the statistics of the comparison/ {$ j. L3 @, A
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different' }: y+ e/ u- ?8 }3 q4 f
 the recommendation for further checking1 T! J' H5 F- I; _) [; p
- 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
6 ?* d8 x5 a/ K7 A& s; A( E the names of the two files compared
: |$ ~2 P% ]/ c9 [; H0 t9 Td) Leave the program (exit)
$ s6 B, k7 ~# X, TThe ProgramCompare class: (Total maximum 20 marks available)
. B. E! ^' j; C$ d2. 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)% N: \0 h1 L" @
a) provide an error message if the files are not found or there is a problem opening them
1 P; a/ d# A7 l0 e1 bb) compare each line of code
! w" e3 Q, T, j+ m7 d; J" s" e. ~: Zc) print out the lines that are the same* V( o9 X5 @, E- a( h
d) count the number of lines compared / lines the same6 I: }! N/ y7 @' g) @3 f( o
The AuthorisedUsers class: (Total maximum 20 marks available)5 [  Z1 V, u1 |- Y, E
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 a' C" c6 {* W' L4. Provide methods to:
7 _0 e5 v4 y" Y3 G8 P) ja) 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
6 {8 E1 x5 c" A0 n( Yb) return the name of the authorised user
" @% n4 b& O) p) Z) Ic) return the name of the department of the authorised user
$ H& t3 e, }! `8 E( c& XIndividual Data (Maximum 20 marks available)" }1 H- N& q  H6 `
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.& J( H' @  d- z* F* R* F( t7 I
Documentation (Maximum 10 marks available)
7 _) ?) R( [" `( ]! j$ G6. 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.
2 ?" P, S. D2 r4 g* ~BSA104 Business Programming – 2007: Assignment 2
! x! F  T1 D4 m) D, zPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
$ W% v, b5 Z: w1 G- b# t' i$ a5 t不过你要翻JAVA的类库说明。你有下载没有?+ a, G% P! `2 z( H, n8 J  h
查询关于对比的函数。貌似关键字是contrast,还有compare( C; L" G0 Z$ i! N4 ]$ L

9 R$ ]0 F1 B$ W[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
8 K% d1 _3 W) q痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。) N" C$ c* L* |
可以下载到的 是 jdk-1_X_0-doc
6 [) t: v; i3 _8 U2 P3 `6 `, t2 X* j+ u) E
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-10 11:03

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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