找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1834|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 6 F( y& Q& Y6 R2 h" l6 e ; @+ n* E. S% d2 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 | 显示全部楼层
//*********************************************************************) G: A( f% J5 z+ F. g3 e( j
//  ProgramCompare.java         Provided by: DRS, h% Y. F  @7 [0 T
//4 u0 D& ?2 S% `7 n" \& ^* j
//  Program shell for Assignment 29 h1 }1 @1 A: D3 i0 _
//
, F% {) K+ M1 y9 e: b  y//  Compares two text files line by line
% ~- g& |! o* E4 L: s1 M//*********************************************************************
  M/ B- B) V* b2 x' {+ q, G  ?! ]* h
: D) h' \8 y8 @& g9 Ximport java.io.*;
, n$ m! g  f. D& T1 p% y; \& r9 o3 U4 H9 d& n6 D# z4 X
public class ProgramCompare! r: {( R+ q% v( ?! t+ J8 K
{/ ?  I1 U* s9 W# D  ~
        //------------------------------------------------------------------ T& i3 o$ @) N5 p4 G
        // Constructor! g9 N  I, A1 m" Z3 m8 T! O
        //-----------------------------------------------------------------; h% |* I- c$ s3 k
        public ProgramCompare()& J- U' B* p  g. m
        {
: C  g0 x- U4 p/ j        }
3 V4 L" T" `0 f3 Q' i& M8 y
! h. m& n/ y8 l' }0 C) a5 P        //-----------------------------------------------------------------' \% N3 w2 q" q& t" s! y* z) B& z
        // Method for testing that class has been reached
. I! C3 _+ A* U' o        //-----------------------------------------------------------------        : i( ~( F$ N" a
( w5 D0 S4 b/ q0 p  _# Z7 S
        public boolean ProgramCompareReached()        
. p6 l- C- y: y" c, ]. h7 u0 t, U5 R        {
: r, g2 c5 v5 D9 Y, j      try . c) e, l, H8 F
   {        
& c+ T* @, F, V, [" P. J0 c                        7 N# u& B! }, _" \. \& b: g
                //********************************************************************
% ]* h) Z, [  O2 c                // Try-Catch Statement is used to handle exceptions - such as file not found & ~, a* o  T# `! k; b$ ?9 _
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
) Y& k4 X% z& b" [; F                // For more information see page 534 of the textbook
* P- g& `1 U: a1 ]$ W. C3 T7 T4 D4 i                //********************************************************************
3 `; @9 r- E( B                    
2 C+ ]9 ]  q# x! M8 w/ U        }% Q" Q. N9 V. W. G+ R
             catch (Exception ex) // Exception caught here and message displayed to the screen
3 ]* U" Z* e* n# p7 r+ i          {
9 Z: @# g( Y" x2 d2 |) [9 V                    ex.printStackTrace (System.err);) P& T& R! k9 v9 K
           System.out.println ("Error message goes here"); // Replace this error message with your own         
. X: }) D, O4 d8 b' H        }
* {$ [* G, S+ b9 V& r) Y                return true;
+ e4 b  O: ^" j; m6 I$ n  D        }
8 m7 ?5 d# E0 t( x' J2 d; v: k; e
  V. B4 O! J3 v/ T/ t! c. c} // end of class ProgramCompare. L) G" B1 u* R  T
8 U6 y. K$ Q7 W
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************  \/ T& b9 u9 ^9 g. A& g
//  ProgramCompareMenu.java    Provided by: DRS
5 ]4 x( P  ^) N  e6 o7 }//
7 O. p, ~  p. S" }) f: }. H8 T//  Calls AuthorisedUsers.java and ProgramCompare.java; L, H" Z: \1 `7 o5 G, G  |
//. U+ c  t& ]/ r  Z7 j. x$ h
//  Driver shell for Assignment 2.! k$ g' _6 n1 `7 N0 ^( [
//********************************************************************
. K, F9 R) N. Y( ?8 m2 i$ L3 E1 ]
. n5 E" F; q+ _. T, n1 {& aclass ProgramCompareMenu4 E" q% z/ t6 u0 o
{
7 o$ d" v3 m* K& p; Y1 s; _- }0 `( z    public static void main (String[] args)
3 q; V+ |& K4 i) R1 H" l4 X$ }% h            {
5 ?# v& o3 B! q$ e' j                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable1 q6 P1 n* P, f# g7 O
                ProgramCompare reached1 = new ProgramCompare();
# N6 q0 N3 t/ R9 Y9 s1 h9 z                AuthorisedUsers reached2 = new AuthorisedUsers();       
* v0 |/ H6 f' ]$ M+ I                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());1 ^, ]' X8 \9 ]0 n
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
" _/ k/ K  k9 [- _        }
8 z+ U4 M: b2 R# w+ F/ ?# E0 t}// end of class ProgramCompareMenu0 ]0 a/ ~) z3 Z7 J, E$ [
2 V( |% s; H. E( r$ d" d0 u
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************" r. C9 Z; \+ K* @
//          AuthorisedUsers.java          Provided by: DRS
  F" B0 j1 L  n. I; P//                9 t  T: Q* l, u5 E
//         Program shell for Assignment 2# _6 G/ j3 B1 ]: ^8 Y) S; a
//
  w) D! D+ W* _  E6 J3 I//         Represents facts about an AuthorisedUser- M# O. V. `5 E, }8 f, n  ?: g5 z
//********************************************************************' |1 L  d6 C4 k
0 G# W0 N  Z+ n  M" E7 J( h! a
public class AuthorisedUsers5 N2 [; {6 j. N" t/ f
    {
  E$ @" w, ^( {$ b" [
% m" H1 r/ X- s% f: s3 O1 _0 L) G8 @        //-----------------------------------------------------------------0 l& P8 C/ L+ ^, H; ?4 R$ A
        // Constructor" Y& L6 c7 k- e8 |) ^! T
        //-----------------------------------------------------------------2 m0 }1 |: D+ `; D

' Y& c  C# O1 L9 h; \2 |        public AuthorisedUsers()5 R% \* h& K) N' L4 W# t) n
                {
7 o% ]; m" M% \& v& J: P                }3 q. y7 }/ X9 ]+ A6 @" u

5 v3 k) W2 [4 k$ V" ]        //-----------------------------------------------------------------
& r2 u! K/ W5 O        // Method for testing that class has been reached
1 a6 X* b3 [! U5 @  d        //-----------------------------------------------------------------          ]1 @! T& J( z' i
        public boolean AuthorisedUsersReached()
- t- v( R) Q3 C* \                {- ^/ ^/ E! A! C% f' }6 B2 _
                        return true;                        3 ^( G) q1 T5 r3 g9 {8 g
                }
7 F: x) F. n* U               
) v2 @9 H; A& U! {" r- C3 d9 z( f    } // end of class AuthorisedUsers
( P$ F+ i  F, \4 @6 A5 [4 c: V* m; x3 Z//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
; u8 j% m4 I" Y' [Shanghai - 20079 v8 T/ ^! d" y2 @8 |
Assignment 2
1 p  b' f9 `( ~. U; EDeadline 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)
1 n" I- y$ T: \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.
! o5 _8 h/ W: I% k& }' MThe staff must be able to:
, ?: J. {/ W1 n  ]7 p9 T' C7 l2 V Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.$ o# U8 X. M$ T( Y) Y9 O6 }$ M
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.
9 m) ^. u  }- R The interface should provide a menu so that the staff can:7 J! G/ V' m& W- U. R$ `  C/ N
a) Enter the names of the two Java program files to be compared, e' g/ q8 {7 w( ]+ b% u1 i$ Q/ y: T
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.% i2 n6 x- w. S: z0 n: `$ A6 o
** 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).
5 s- d9 M7 L2 M. ~0 XBSA104 Business Programming – 2007: Assignment 2% j; Z. W$ l6 M1 h1 A" ]
Page 2 of 5
7 {3 _/ N' d1 R; u9 b# vb) Print out to the screen all the lines of code that are the same4 G, g# R8 A- S( W/ E8 Z3 c( B3 }: w
 Include the name of the file and the line number of the code being printed for each of the two files
9 K' F3 ?* x1 u9 F: R, `# kc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
7 D( t$ B+ q8 X the name, username and department of the user' L7 z( o' X9 a0 l  r; F# X
 the statistics of the comparison4 r2 s8 Y/ S$ m7 {! `! G" I5 }
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different, h) n5 n. q; n7 m
 the recommendation for further checking
5 y4 |- ]; ^, }7 I- 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( Q6 `: e3 G* [/ a. ], L' q
 the names of the two files compared
& l+ O2 ]8 _4 S% E7 ?+ Gd) Leave the program (exit)
5 O1 H4 B# D/ a& d9 |The ProgramCompare class: (Total maximum 20 marks available)
, N" e2 E1 M: v! b9 W2. 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)
/ b. p* ~7 `) ~6 U" Ca) provide an error message if the files are not found or there is a problem opening them
1 ?+ _3 ]+ H+ A, r$ P9 lb) compare each line of code8 T# M1 `" e; C0 ?5 W9 e4 g6 C% y
c) print out the lines that are the same: \" @* u' J# b4 Z' R1 z
d) count the number of lines compared / lines the same
; C+ n# h8 }# W5 gThe AuthorisedUsers class: (Total maximum 20 marks available)+ Q  B/ Q1 X& _+ @* X! r' B% ~
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)
1 j8 U( U; ^0 A" H4 d8 B" u! E4. Provide methods to:
7 a/ y  ~0 |; T& x6 da) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match7 J6 w$ B; y# D. _
b) return the name of the authorised user* g3 a; Y' {% }5 m4 z1 J6 Y4 b
c) return the name of the department of the authorised user1 ^. }7 ]7 G: w
Individual Data (Maximum 20 marks available)3 a- J2 _$ {# {& W6 o
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." A5 L- X" m& y7 q$ O0 d
Documentation (Maximum 10 marks available)
4 i+ q3 y- `) b2 Q6. 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.; f2 g7 w3 ~0 m2 U7 ?- \
BSA104 Business Programming – 2007: Assignment 27 }; G9 S2 P. n1 `2 j
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
/ O/ X7 m; X# T5 \( ^不过你要翻JAVA的类库说明。你有下载没有?
4 {4 r( C/ v0 G3 j% Q0 G" N5 D) `查询关于对比的函数。貌似关键字是contrast,还有compare# K2 z% {6 K, f$ i1 }

- e$ O! v) r' m4 B- |: z4 ?) e[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
; O$ j8 [* l- e7 t- S) d痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
8 t3 C, S! W" [% \3 U4 |5 r可以下载到的 是 jdk-1_X_0-doc0 v1 T7 m- u8 E2 A

! X5 w/ |+ p3 x! t" ~5 u2 I[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-16 20:15

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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