找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1721|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急4 \# l% H$ [; o9 r3 u7 x0 Y ! Y0 R6 L$ F. I, A" t
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************3 Y0 x. q! n$ ]
//  ProgramCompare.java         Provided by: DRS, C. X+ N) J( R
//' a8 ]8 z$ L6 M* V' X: X( G
//  Program shell for Assignment 2( x) D) D' A7 m
//
9 Q0 m9 I2 I% J; @//  Compares two text files line by line
' E0 i( A! j. U; g//*********************************************************************
8 c6 A, z1 N5 d7 U5 y! \# n/ I2 P4 D: p' K2 L
import java.io.*;$ ?/ n- i) s+ `4 P/ @

) S9 ~: `+ M) e$ S+ T2 a  [5 vpublic class ProgramCompare
3 S0 w4 }, ~4 Q* O& ?7 R  [4 |{
3 w  g- V' w$ w0 _6 p/ r        //-----------------------------------------------------------------
1 X6 R5 b% ~6 `8 E5 F: n8 b3 ~        // Constructor3 W& U% ?7 A: f7 r" [3 `8 a
        //-----------------------------------------------------------------! o& @2 m. ]2 O" t  |5 [/ [3 f# Y  |
        public ProgramCompare()
: _6 q( V/ ]5 [  K        {
* R% E/ y9 B  P$ g& U$ q' E  J1 h  e        }1 C2 o3 D: d! E9 q; ?
/ v. y$ L/ E% }2 c7 q7 t" @( j3 [
        //-----------------------------------------------------------------
4 B3 |6 K! T3 D        // Method for testing that class has been reached
$ L- \' p) N: d1 b3 Y( ^        //-----------------------------------------------------------------        * v1 V' k; C9 K( m$ H4 S
. W% u/ u, [" y% t' V/ g2 z3 Z" D
        public boolean ProgramCompareReached()        
& ^* F# {) v/ j        {
' e. u! \: }( a, X7 w: |* D5 D; }      try
& g" s0 J* o7 l9 d0 r! p9 B: E   {        
& R3 P9 r, g' Y) @% ^                       
" C7 _1 i/ D3 Z3 ~                //********************************************************************
9 t) ?; U  e4 [& |+ M# O5 `                // Try-Catch Statement is used to handle exceptions - such as file not found
% x0 V' S- }7 A                // Reading the files will need to be placed inside a Try-Catch - just like this one!/ `) _7 o( r; R! e
                // For more information see page 534 of the textbook* w4 c: O% s  l! l6 w7 u
                //********************************************************************1 G1 d; N+ ?- e% L+ r
                     7 n2 U" B* B4 R+ L8 z% p; @8 S6 h
        }7 z5 L& c, u+ q0 K, l8 r+ ~
             catch (Exception ex) // Exception caught here and message displayed to the screen
  k3 L' \( x3 e! ~* p5 j% v* E          {# _  [0 @- B# T8 l3 a4 {. a
                    ex.printStackTrace (System.err);
( l* C* P* I, @           System.out.println ("Error message goes here"); // Replace this error message with your own          " ]& ~2 Q0 o+ H! B* y2 O) P% E' O
        }: f# k6 P; c: {3 n5 u" M. T
                return true;
* {" w1 i0 v5 X+ p        }
# z# N; Z* i. _+ I; x+ n( ~5 D  P2 X1 z7 [) c( ^
} // end of class ProgramCompare; k( j1 O  C: N3 p
2 J2 _3 w8 x2 C& j- E
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************* W3 o# v4 n5 S" p, y7 z, @
//  ProgramCompareMenu.java    Provided by: DRS
& a7 L4 M2 [' T) G# {; B//2 \; _% `" ^3 t2 l7 v6 \
//  Calls AuthorisedUsers.java and ProgramCompare.java& [8 K( f( K1 C, v; U
//, F! U( H' Z: f) W7 q
//  Driver shell for Assignment 2./ G  d6 A. p; h3 m1 a. A; A
//********************************************************************
; V; G7 P+ C5 ]  V
# g" \$ {3 H: b+ R' ~" tclass ProgramCompareMenu
, z; s; {. g9 R/ s) p3 v{
) [3 ]) y& a# M4 o7 v' @& S    public static void main (String[] args)) {' |* ?1 Q1 p. G4 J
            {
) @4 t* u3 s! y* L                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable, A* c( R  j& z0 Z& o! V
                ProgramCompare reached1 = new ProgramCompare();
( Y; @0 ~0 Q9 N# Q7 |                AuthorisedUsers reached2 = new AuthorisedUsers();        0 J4 {& B2 [9 ~( h
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());6 G4 u4 x: `; Z
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
& N! U. Z/ s# ]  g: u" b        }& k$ O2 k8 U  P2 W7 I4 J1 K; p$ {
}// end of class ProgramCompareMenu0 O: [4 q4 e) d- |! x1 d
. D9 l* p# [& ?. I1 Q/ h. }8 P2 N
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
: u0 k( k  w$ a//          AuthorisedUsers.java          Provided by: DRS
) H6 P& ~$ P- W( o" V- {//               
6 D- Q' g( @' [//         Program shell for Assignment 2) I2 ~' Q/ ~% d) p7 S
//; I1 F. W& x" R( H( Q/ T1 a
//         Represents facts about an AuthorisedUser
( Y" Z0 l( I; a/ g: a3 }//********************************************************************! k+ ]3 Z- k- O4 r9 [1 `

/ W; D9 i) g4 cpublic class AuthorisedUsers
, ?. s' a1 E9 x  y& j* o    {
& b: E! p8 U8 {- j& b& \" Y3 F  h1 k7 d7 i& |3 [
        //-----------------------------------------------------------------
+ n1 N/ L7 F. X$ }# h# F! ^" ]0 K: K/ R        // Constructor
( E5 F. N$ K. @8 o% Y        //-----------------------------------------------------------------
9 j9 |8 U: S) D  d% K: c0 }3 {
        public AuthorisedUsers()
6 c; ~, V: @7 Q7 N9 Q                {
+ M4 ]4 i. }5 ]7 ~1 V6 k                }  i5 f% j/ l2 G/ Q

+ Q* j" Z# }4 {1 {+ m        //-----------------------------------------------------------------" b% F! Y( k6 I2 ]5 ~
        // Method for testing that class has been reached" B, O6 i! o, `, ~$ a
        //-----------------------------------------------------------------        * T1 ^- q. ^1 ]
        public boolean AuthorisedUsersReached()  G3 @" e5 A& \8 T  w8 W
                {
* F: M/ J! g" ~2 Z1 D                        return true;                        7 t/ b# _0 U7 ]$ H* z, ]
                }
; t4 b. B  {3 b: ^2 ^                # m3 x  d% g8 C
    } // end of class AuthorisedUsers( D$ u$ x+ m, ~  _# k/ O! L* {, r
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
5 @5 H3 ?- Y* W2 o& {Shanghai - 2007! w4 s4 m$ G8 y0 V, H: {
Assignment 28 M- A; x# L2 [- F6 p
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)$ p& p1 Y7 L' t8 g* u2 D$ C
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.
8 w' B5 P4 z- YThe staff must be able to:
+ I0 N  F" G& }5 |) k7 [# F8 o3 [ Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
0 K0 k1 t0 r) 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.' @1 X) A) s4 F5 {) S1 Z
 The interface should provide a menu so that the staff can:
' N! G) r2 ^3 ?1 t& L4 a8 X5 ia) Enter the names of the two Java program files to be compared0 V! ]* ^' m3 {" s" C
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
1 H0 n! S; 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).7 k; K; t7 j) ?( }+ ^0 z
BSA104 Business Programming – 2007: Assignment 2  u6 t' \9 C; r. I; @
Page 2 of 5
2 e7 V2 u( Z+ T# jb) Print out to the screen all the lines of code that are the same
( o0 |$ L6 x- b. R Include the name of the file and the line number of the code being printed for each of the two files) D; z1 ^4 L3 i
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared" }$ R  k. L4 I0 b& R! W
 the name, username and department of the user
' l( O0 Z0 Z( b* T9 D6 d the statistics of the comparison
  o( x- z+ Z- |4 `9 j- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
# ?# Q, j. I, }5 k' p, g( R the recommendation for further checking* N2 N- i+ C0 g6 ^% n1 o* O
- 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; V2 p+ B" [( w( F/ c1 Y) ]
 the names of the two files compared
$ _5 h; _8 o  ?d) Leave the program (exit)$ p- F  X! x& l1 Z$ L6 Y, B1 t& R; L
The ProgramCompare class: (Total maximum 20 marks available)
  {/ c$ i% _$ B; S$ c2. 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)5 l, ?3 `$ s3 O
a) provide an error message if the files are not found or there is a problem opening them. r  z* d* F/ K$ f
b) compare each line of code. V6 T. L- y9 C& M
c) print out the lines that are the same
& ~* p2 K9 P0 V8 X* b! ]d) count the number of lines compared / lines the same& z7 g9 h  X; \4 S9 H& _2 f2 |
The AuthorisedUsers class: (Total maximum 20 marks available)! ^" y$ X; N; t2 r" h: I
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)0 e# \6 C* m" J
4. Provide methods to:7 d) a! |9 v& n3 ^- ]
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
3 s' w- e5 m0 k" b, wb) return the name of the authorised user5 J* E+ j  g$ Y; o
c) return the name of the department of the authorised user
. _$ w" n7 Y0 F& W, TIndividual Data (Maximum 20 marks available)! N1 n+ b9 A& J7 i
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.# n9 @& @, {% W0 T, C# E
Documentation (Maximum 10 marks available)
- D( z! [6 B# @3 j6. 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.
6 p5 B; e, U$ A+ GBSA104 Business Programming – 2007: Assignment 2
4 |+ P0 F2 V3 @$ `- Z. iPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
! n( d! W$ G3 @) i. r不过你要翻JAVA的类库说明。你有下载没有?
1 M: l7 ^! W( n; ^查询关于对比的函数。貌似关键字是contrast,还有compare" ~$ a: n- B5 n6 y
6 a& Y) p& S) i/ {! {" I; ?
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
2 c  G* u- b. e: }* A痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
' H7 u" R8 q% V: b. A可以下载到的 是 jdk-1_X_0-doc
: s6 `: o1 {& o4 s. D* [/ G4 p9 f: l7 M% Y* t
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-12 13:47

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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