找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1453|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 + n3 _, }3 o2 J8 D/ ^* ^0 `* [3 S7 t6 D9 J7 Y, X
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************' K* l8 t* A& `
//  ProgramCompare.java         Provided by: DRS
8 W& [: d; a$ f( \: {8 K4 _//1 [5 v1 G, E' e! J# l! `2 f# \- t( f
//  Program shell for Assignment 2! I, {; z/ L& ^+ u
//' S& \( e: ?. d1 n7 s
//  Compares two text files line by line
1 c7 H8 I/ H, W6 g& x1 S; m; P; O//*********************************************************************4 f$ U5 k! A0 r- g! r) N$ E1 n
; Q9 V+ X) a( J0 u4 Z  z
import java.io.*;
$ v2 `2 q3 I1 ~; P& r' i- d; e3 W% B1 b+ i
9 l- H% n$ O+ S4 g. A  Rpublic class ProgramCompare
7 O% ^0 y. N+ X, t: |+ g{& P0 m5 o. j; q* z
        //-----------------------------------------------------------------, ^) f% I1 i2 |8 _- D7 }
        // Constructor7 y2 r* v% Y7 o6 c3 z+ w0 w
        //-----------------------------------------------------------------
2 i& ^+ [: f: d1 X+ Q8 \        public ProgramCompare()# \+ y5 q% L. m$ R0 \, f+ m
        {# l& b3 q! t% v' ^* z
        }9 n% n# T4 M: @  J6 q; @1 P
1 f# A% F8 {7 B- g2 j6 A
        //-----------------------------------------------------------------
5 U: n, c! @/ o+ k/ o* r  _        // Method for testing that class has been reached# j# H( w7 ]- o6 X& x, F5 M4 @
        //-----------------------------------------------------------------       
, E+ ^, ?  Y9 m& z% o
, a  }6 N% r! n  H        public boolean ProgramCompareReached()         " i* n# F  P( o8 u! }# z+ E9 K
        {- @! _) R8 G2 |5 s; W  q
      try + o; g8 e- z$ M) P2 V' p
   {         9 i. N( D1 e& g. e4 B
                        ! O4 q! a# k" Q' ?
                //********************************************************************
+ E  L/ m- c3 C! t/ J6 W                // Try-Catch Statement is used to handle exceptions - such as file not found 1 k( D# i8 h, W6 o
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
7 q, |( \. T1 C& \5 \                // For more information see page 534 of the textbook
/ P+ X& z- e! v# @! @3 j. q! B                //********************************************************************
- P/ X* d' h5 U4 h. ]/ g* r                    
- X; S7 L, e0 A8 w        }) }4 @7 U6 h' v! U9 i
             catch (Exception ex) // Exception caught here and message displayed to the screen
; r4 \/ S2 l) y5 G          {
% N/ Q; i' N& W5 D* h- e/ j                    ex.printStackTrace (System.err);" {2 k- G* E$ M, Y0 [7 p' E; Z
           System.out.println ("Error message goes here"); // Replace this error message with your own          ) _$ @* Z+ m( Y
        }
8 Q* M/ \9 b6 {, e+ I                return true;& [, ~$ E* N! m% h
        }
( F" j8 t& J0 e3 J0 C- f  v8 X
/ v! @/ F) k' d! {6 n5 v/ _& {} // end of class ProgramCompare
) v: p7 U# Z; X
3 k% R! o* p# `9 L" A//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************, j4 i; v$ O5 X6 u
//  ProgramCompareMenu.java    Provided by: DRS
3 N4 M8 |: P0 z1 p2 d//
3 u9 j4 l+ w3 U9 y2 _//  Calls AuthorisedUsers.java and ProgramCompare.java  T* R7 s# g/ h+ |
//$ O! d. J; N$ ~
//  Driver shell for Assignment 2.) H$ j3 I& o: t  V8 |% [
//********************************************************************6 o% v* w; b' x: g
0 h! v, }9 y3 C9 Z- J. W7 Q
class ProgramCompareMenu
" Z( X& t$ t2 T; y% Y{
! d: z2 z& z% O4 `8 X3 M, b    public static void main (String[] args)
5 ~4 G2 W, Z9 `' n2 N            {9 P5 D$ s! u* e
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable8 L3 M( A  ~3 }
                ProgramCompare reached1 = new ProgramCompare(); ! R! H) @- f* _# D& F
                AuthorisedUsers reached2 = new AuthorisedUsers();       
! ~- t" D/ Q3 @9 H9 @# C" Z9 M3 u                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
% g. x5 c1 H; U9 J4 E- k$ x' `& y0 S                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
7 i$ n1 f# O# t& l        }9 P7 A& x/ O; f: i. f
}// end of class ProgramCompareMenu
& y  ?$ o0 W  B* D& j1 a5 j/ h: T9 y1 v4 Q* x, w6 v# b8 F; G3 G! z
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
, P, w' _( V1 S//          AuthorisedUsers.java          Provided by: DRS2 F( {/ D8 f1 Z% Z) J- W, q3 ^
//               
5 \  H8 g) [. h1 r; e) w5 i//         Program shell for Assignment 2  G% Q! ^9 T' R9 [, U: T
//
8 V, N+ Z( b# W  x  \; j//         Represents facts about an AuthorisedUser% |7 m0 Y3 p6 b0 r9 g
//********************************************************************
. {0 G6 y9 q; T, y+ C' c4 X9 |
public class AuthorisedUsers( t& C# U0 c5 [4 [( I% N
    {
: j5 a% z' U1 ]0 {5 _; e) A: x8 L" f7 ^; f
        //-----------------------------------------------------------------
! v7 g1 F: G( ]6 w        // Constructor- l3 T, Z  ~" X" Y" D' T
        //-----------------------------------------------------------------
7 \0 ]9 D  _2 m0 k  @; {3 t7 }+ u4 W9 g  ]/ I0 c; h
        public AuthorisedUsers()5 f* O" B" ?% E$ y- }( X7 Y
                {
5 {7 y9 x2 |# Z/ `4 p/ r, T                }% l7 ~- B3 \( ~4 z. y  J
" ^/ x* E( b3 z  {: V* J1 R5 Q. f
        //-----------------------------------------------------------------
3 o4 o0 h' g- k/ {        // Method for testing that class has been reached* ~+ C" ]1 V5 j
        //-----------------------------------------------------------------       
( P4 N1 P- y" N" v! x        public boolean AuthorisedUsersReached()
$ K: ~+ X  C3 X                {* u. m8 u. X& \. \
                        return true;                       
" c% p, ?( @& D4 p5 L) b% j! k                }/ D. O( a9 J: U8 A9 K% H
                3 a  }  X2 e0 s8 V
    } // end of class AuthorisedUsers+ `2 _% F! C4 R2 J2 z, G
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming1 _: N0 v  T# G, O. t: X
Shanghai - 20074 J( H7 x6 \, J5 d/ r8 j2 n+ d5 V
Assignment 2
" Z- ~' w/ ~5 S  uDeadline 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)! K1 W% ~7 k& ^" y% Q8 N0 N
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.
: i2 g; O6 o7 [The staff must be able to:9 L# ^! B: c. `2 s
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
3 u, j/ T3 M& o7 \+ @4 h1. 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.
8 h" `0 a8 n8 l4 v5 z8 K* v The interface should provide a menu so that the staff can:
' h8 S6 Z$ S' o' Z4 _; X5 fa) Enter the names of the two Java program files to be compared
! p) R' m) k7 E% }; |; C For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
( n' F# O2 ]$ a** 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).2 m  T- z% ?( f% F/ i
BSA104 Business Programming – 2007: Assignment 22 d( M' h7 r; p7 W8 t! {
Page 2 of 5
5 J0 q3 H( k: K+ r" Vb) Print out to the screen all the lines of code that are the same
7 i7 F& l0 L) j4 H' t6 W Include the name of the file and the line number of the code being printed for each of the two files
3 s5 b; \: D; T7 x  c2 ec) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
* M9 U+ i# ^' U/ ` the name, username and department of the user
) n5 o9 @; u! F% t0 W2 I the statistics of the comparison
- {& }2 H' m' R0 b. j) |, `5 e- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different5 y' L' h0 a# d3 q
 the recommendation for further checking
1 t& G8 G# W5 f; 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
$ M0 |  Y1 t- T8 _* _ the names of the two files compared" i0 W6 J( i4 g+ T, a+ l  V
d) Leave the program (exit)
! ^4 K- q) J  i$ X% n+ \: SThe ProgramCompare class: (Total maximum 20 marks available)
* f( f4 Y: u* N( r3 {7 h; n2. 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)1 {: M& t# T1 T% F2 a% r
a) provide an error message if the files are not found or there is a problem opening them2 A4 Y4 H4 b0 Q! O
b) compare each line of code
% P+ a" Z+ `+ t7 p  m- V: }! vc) print out the lines that are the same3 ?& v) ^* j& X# Y9 F
d) count the number of lines compared / lines the same
6 D4 V* V; p8 d' L% x1 zThe AuthorisedUsers class: (Total maximum 20 marks available)
, @  d+ x7 @2 t. f4 P, D; p$ 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)
4 f- N: o0 e/ v+ d8 j$ y4 u& g* j4. Provide methods to:5 ]/ s: D4 l. _6 F" n% r1 Z! i
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
7 ~# n! ], A( gb) return the name of the authorised user! \& M( P, Z4 p8 o4 n
c) return the name of the department of the authorised user
3 J4 r8 _$ W6 f0 H6 m$ D2 L" ~& NIndividual Data (Maximum 20 marks available)
6 H2 {. z- ?7 D, D/ Z$ o+ H, d5. 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.
0 T- J' t8 V4 Q0 ADocumentation (Maximum 10 marks available)
7 ^0 E# {2 i- K6. 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 m! q, x$ d/ y/ ~0 q# G+ f
BSA104 Business Programming – 2007: Assignment 2
1 t5 L. h3 g4 r- a# D( v3 a* P( |Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了: I  _. S# P; m$ T4 w8 n9 g0 V
不过你要翻JAVA的类库说明。你有下载没有?$ s* m) a" g8 k7 p5 Q
查询关于对比的函数。貌似关键字是contrast,还有compare
" c0 ^* Y" |7 m8 s  ]% T
4 _2 H) W; r8 B! p) L[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
" A) j* u2 f0 A& L3 W9 y痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。' k8 m3 X* R# m* X1 ?* W! H. D$ |
可以下载到的 是 jdk-1_X_0-doc4 n9 v8 u% B; r% ^& s; @% j" e. ^' ?3 c- I

; v+ t# V. Q. ?/ b) C- g[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-12 16:58

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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