找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1835|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急% W% a: m! A; `$ U* e 2 h% A. h3 k" N
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************, R, |% I# @2 [4 u5 i7 T3 [; Z
//  ProgramCompare.java         Provided by: DRS, O9 _3 ^; G% {5 ~
//
( \7 Z  B+ |6 R7 ^//  Program shell for Assignment 2
7 {+ O3 h* K( g# N//
( Q$ {( Z4 s. D% k3 w$ G//  Compares two text files line by line
' A, I' X7 V5 _: E//*********************************************************************
- j7 v8 N  n/ N1 ^) j3 L. q* T
$ J  o$ t6 e! P7 ^: v: ^import java.io.*;' a) R2 T+ c  b. `( R8 U& [9 @# E3 T

- X( T5 L- B" l0 C; P; O& ^public class ProgramCompare& R, N. P$ {- C
{
# }& S7 O5 o3 ~* z( Y3 ^& v        //-----------------------------------------------------------------
( T2 C/ d4 Z& U* m        // Constructor/ z! u1 V4 ^& _. r5 i  ^7 K
        //-----------------------------------------------------------------
' z& ^4 u" M6 w  I$ @4 b2 [  A        public ProgramCompare()
! ]# H2 y. ~, Q- j( l: ?        {* [- v+ x# z/ f/ U
        }& X- H9 C8 E, e9 P# S/ D3 U

6 j8 o5 n' Z' v( ~! C' t2 S# Y; g        //-----------------------------------------------------------------
$ j4 V3 i& H) P/ R+ V$ o        // Method for testing that class has been reached' o! D5 K1 [3 V# }
        //-----------------------------------------------------------------       
" p7 P' l1 O# D7 r& L4 k" w8 ^* V1 S, b9 q% ]
        public boolean ProgramCompareReached()         1 c# f7 g' i  K# U2 X; C
        {
( f$ R: d1 T: j- U      try
! i6 Y. D' p* c# d4 }8 v6 _   {         " Z4 k. q# `. X
                        & M- K+ p( C& c, s- U  I
                //********************************************************************5 V4 S+ b$ g' O& W! a
                // Try-Catch Statement is used to handle exceptions - such as file not found
. P4 V+ Q; l9 }0 x0 V+ j* Q                // Reading the files will need to be placed inside a Try-Catch - just like this one!
0 {& o/ f( D: \9 D$ I1 e                // For more information see page 534 of the textbook! S) P" p0 T9 k. H  t% g. n3 C3 w
                //********************************************************************' v8 R  a" M& I
                    
% @+ h5 q+ u+ P$ S# w* ]        }
' s2 N9 h8 b7 e% h9 D             catch (Exception ex) // Exception caught here and message displayed to the screen ( y; K* R: g8 `
          {
/ S4 \% H) f0 T; Y, Z1 N: R                    ex.printStackTrace (System.err);
; {& C: B% ]1 }           System.out.println ("Error message goes here"); // Replace this error message with your own         
: G7 k+ y/ C1 V9 H/ w        }
1 R4 S8 ~. c% `/ A6 T. u                return true;
/ {6 k8 R8 l0 ~3 X. ^        }; F0 m" T9 I) O. n1 x4 k
% p, O# ^. f: A) Z
} // end of class ProgramCompare
! b3 D* _  v6 |4 o2 _! R9 H3 V6 {+ N$ z
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
+ F  g- i. C+ M! A" K* \& Z$ y//  ProgramCompareMenu.java    Provided by: DRS
6 ]/ A9 O- d2 k+ A$ g//
9 k, ]3 Z3 f8 Q( D; _& }7 k" t//  Calls AuthorisedUsers.java and ProgramCompare.java
9 {. _3 c# s6 F* N5 L//
% m+ K0 d5 H$ p+ X8 Z6 _3 _: {( g2 k0 V//  Driver shell for Assignment 2.
5 _$ D: l1 A; S" b//********************************************************************
& T  a+ u$ P  o8 z1 S; j- l4 ]! g/ K7 \. E- }7 Q* d4 {7 l  V5 k
class ProgramCompareMenu4 U& s2 j( V: p5 e( I
{
2 B' B& ~9 G) G7 G    public static void main (String[] args)0 V! ~9 t$ x, j: [' Z+ r! b6 T
            {( p2 w+ c0 _# e+ U3 Z& W, D
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
& N, H$ Y. t1 ?8 m9 t- ?4 p  R7 o                ProgramCompare reached1 = new ProgramCompare(); * h; E! k5 }8 I7 {! f* x) R
                AuthorisedUsers reached2 = new AuthorisedUsers();       
# H: P( t. I3 \* ?                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
3 D% K: R+ s% e9 f% ]                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        # R' @3 p9 M+ ^" _1 C* X2 Z- O$ W6 W
        }
% i: S3 F: ^; Z  R' z; O}// end of class ProgramCompareMenu7 c0 C; t" `' X. C; j4 K4 G
/ D9 X! P+ [$ I; U$ C9 {
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************0 \) f" q! P6 k1 K) e% k4 d
//          AuthorisedUsers.java          Provided by: DRS
# S, d/ f/ S, ~) f2 A0 e+ A' f//               
% c7 Y" T5 k1 \//         Program shell for Assignment 2
1 _4 ~: y& \( F//
1 g( f. `; ~; P2 Y. a% q//         Represents facts about an AuthorisedUser
$ q2 f  _1 z+ l//********************************************************************0 T- c% W) l: A0 ]

# q6 ]' r) c2 G# K/ @public class AuthorisedUsers3 m. A& L/ g  I
    {# g3 k; J- g- y% H8 B. X9 L$ B
: g, L& z+ T" \5 C+ U3 a/ {
        //-----------------------------------------------------------------( k( e+ h) S- Z
        // Constructor
; R" y" ]7 P" [3 H" K# V        //-----------------------------------------------------------------$ a% V. n$ w- e  D, j* @/ U2 p: I& g9 f+ O
9 U" c, |5 ]- j( f% k: y
        public AuthorisedUsers()9 |: j1 K; Y1 H& a: k2 j; C1 n* M
                {/ ]* y. f2 C( Q5 N8 U
                }0 Z$ K# X* g7 V- t4 I7 C
8 @4 u8 d/ }5 I$ b4 a
        //-----------------------------------------------------------------$ e' }7 u) x" i6 M+ W$ [
        // Method for testing that class has been reached
6 l2 E. o* j2 e4 X& B& Q- c- y        //-----------------------------------------------------------------        8 m; N. O  f& ~  w7 e9 c
        public boolean AuthorisedUsersReached(). B7 D# c) Y' X3 R
                {
  L: N1 [& L% ~" `; [4 i                        return true;                       
3 W) K# I7 `9 B% Z  c                }7 P  t; O0 N$ j" q2 M+ O* ~
               
$ {0 x0 N) h* m( T# J* R7 ^    } // end of class AuthorisedUsers1 G. Y8 {5 r1 h( P4 Q% z: K' [
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
- w* O0 {! h) x$ U* V" ]5 E7 }8 PShanghai - 2007
# o0 L! M* O) {( SAssignment 2" N) Q/ x& h+ ~1 C0 q! X, D, H2 j
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)* Y  E8 q4 r8 K
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.5 k& O8 d  G, }4 m* k3 |
The staff must be able to:7 P" j! ?  w0 q1 W" O+ F2 `
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
" t' I' D& y/ z4 L$ m1. 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.: y# ~8 t5 z- I
 The interface should provide a menu so that the staff can:5 I8 K+ L7 b8 ~8 Z9 c/ }
a) Enter the names of the two Java program files to be compared
; J8 K- X3 g  U: w# q: O For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
+ w9 Z" e6 `* S( q* ~** 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 D  ~; |# s% k- IBSA104 Business Programming – 2007: Assignment 2
" K# S2 H4 {( m6 \* ~0 {+ ], M) o9 Q8 qPage 2 of 59 S; {0 x" u7 V' |3 y& W5 @7 B
b) Print out to the screen all the lines of code that are the same4 a, _! H3 o/ A& e/ n& }
 Include the name of the file and the line number of the code being printed for each of the two files/ W- P  d3 l1 E2 b6 X9 B3 }
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
# s8 f! Y4 h# E; u( i$ y the name, username and department of the user/ f! Y& s2 J0 b( F
 the statistics of the comparison- N: v# z# W! O7 y+ ]) H
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
% {  m1 m- @5 t) Q+ E the recommendation for further checking0 k" a# D0 h; n( O$ S! p! x
- 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, x! [0 p, t4 j* D( `6 v# }
 the names of the two files compared8 W) ?( B( |9 @' Z* W" U
d) Leave the program (exit)
% h3 p/ @* W1 ^/ W0 CThe ProgramCompare class: (Total maximum 20 marks available)
! G0 e; q' U  [0 J' ~( b7 `2. 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+ Q& j( C+ W2 Y) [a) provide an error message if the files are not found or there is a problem opening them
! i8 ?; ^) x: p5 l& Q2 @b) compare each line of code6 U8 U" w8 s" Z' R" z
c) print out the lines that are the same: ]- l( N' H6 @" r6 i
d) count the number of lines compared / lines the same
: t# j1 B* C3 d5 oThe AuthorisedUsers class: (Total maximum 20 marks available)
4 |) z6 t1 v/ B4 J, |1 o% K3. 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)
: N# E, l5 O9 V5 a5 ]3 w, A4. Provide methods to:
0 |, o( c' u, \" D2 l9 f$ Y  O, Ya) 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
+ G9 s7 _5 ?9 ~7 K6 o: t; ub) return the name of the authorised user
& _7 o: J: g% x; d  F# Hc) return the name of the department of the authorised user7 D% j) i* O) {2 \5 h* \4 m
Individual Data (Maximum 20 marks available)
- |9 ^! X3 r$ R7 b6 ^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." t" c# w9 m% l6 g
Documentation (Maximum 10 marks available). f& M8 f; V% G* u4 z; G; z
6. 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.
; I; {: ^3 O1 m8 H" u/ x7 I, B  ]! BBSA104 Business Programming – 2007: Assignment 2# s3 ^' V* i1 m4 k
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
+ ?+ x' _8 @5 ]不过你要翻JAVA的类库说明。你有下载没有?3 y* c. T/ V6 O8 k% k, J& s
查询关于对比的函数。貌似关键字是contrast,还有compare. Q4 ?; v$ ^% [3 I; B
; G* C$ [6 E5 y; _" `: x
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
: y4 Q) H) y' n4 x9 l8 f痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。# _; D* ^+ G, X/ s: c8 N
可以下载到的 是 jdk-1_X_0-doc$ L% u) }9 i$ i0 K  _+ C9 v. W
- Y5 E  B0 P* P3 _) P* E
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-16 23:52

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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