找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1243|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 V$ _& w3 `4 V8 } _! I% e+ s) A0 b0 ?) s8 e
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
/ ~0 [& Z/ U1 q* S0 U//  ProgramCompare.java         Provided by: DRS
0 r% a( i7 u- ~; }: [6 f/ o' H//: P' D( X$ W) ^5 e. t. Y' ^
//  Program shell for Assignment 2! G' a6 R8 S4 t; o  U8 _4 X
//  y8 z3 R# [2 s  A. D: C4 m
//  Compares two text files line by line# Z6 w) y3 S3 {; K6 a
//*********************************************************************9 s" Q  I) O% q" h

7 _: {" H3 t  R* x; I1 \9 j# rimport java.io.*;& x7 ]& }! Y+ J/ p/ @
" e) d% o+ a' T
public class ProgramCompare5 X6 @$ C7 c- t/ l
{
2 Y# b7 P) [- D, @! X5 B' }        //-----------------------------------------------------------------" J% g! \' G$ N( m
        // Constructor
/ w9 @' `& o( P, s% f        //-----------------------------------------------------------------
% p  H! L- E! B2 ?; w        public ProgramCompare()
( F- [9 b+ I# S5 q$ |7 r( u        {" L0 l2 v3 e) d0 g( D
        }
( ~) |* o  M# V+ w1 J: U# ?& H5 n0 \7 E( _2 r1 j+ ~# \9 |
        //-----------------------------------------------------------------9 V" L& `7 Q8 y- U+ a' p
        // Method for testing that class has been reached
5 Z" A7 N/ _* u2 m        //-----------------------------------------------------------------       
- a4 P, U1 Z. Y, y% X% @" O) z2 l0 h" g4 H
        public boolean ProgramCompareReached()        
; i% [) ~* {, W        {8 h1 n% [# Y5 ?
      try
) A* {) I* C9 S   {        
4 M7 q8 ^2 j- z& z$ E5 N( U( w2 Q                       
" m1 b/ l8 |8 f                //********************************************************************  v6 N; Y+ [5 U/ p; s0 H) X. q3 O$ c
                // Try-Catch Statement is used to handle exceptions - such as file not found 0 B( Q; [0 Y4 B7 |0 ?+ o
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
  h% O+ J2 k. m# i& |2 C                // For more information see page 534 of the textbook
. d' T/ e4 v; i7 o/ t' e                //********************************************************************) D$ H+ k" Z! j& r5 A& E! x  Q
                     1 b8 J2 C* P/ W2 ~2 [/ M
        }; o2 X  P: n: m. H+ V
             catch (Exception ex) // Exception caught here and message displayed to the screen
+ K- M3 i) @8 G! f          {
2 C. s3 u' V* ~% e                    ex.printStackTrace (System.err);
, i( d" @" C1 U           System.out.println ("Error message goes here"); // Replace this error message with your own          + K" L1 j1 q! E2 @! q
        }
3 ~  [" A& p6 _) z                return true;
) A9 @2 D1 d* a& E. F' T1 R        }
5 A+ I* D7 A! E/ p+ g: [% O+ T( X
, \' K2 ]# C8 T9 b+ z) B} // end of class ProgramCompare* f. U2 c! G. B0 h1 Z, i, G
7 e* N2 x+ t/ ?/ D: L
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
2 q* b( g8 T/ p# i6 E//  ProgramCompareMenu.java    Provided by: DRS
  R0 F: h$ X8 x//
5 @: {3 Q( s' I8 W# d//  Calls AuthorisedUsers.java and ProgramCompare.java
0 Z$ @; g5 @  e; a. [1 x+ I5 q//
1 P( j% ~) X2 H+ H//  Driver shell for Assignment 2.3 Q& ]& t+ G) I' G/ g" v8 v" \" T
//********************************************************************
! d! z1 n& I' ^; [) R+ n
' H( i0 }7 G: t. @& `class ProgramCompareMenu$ a, |" X3 A6 j$ P
{) _  @# ]4 F( X4 w6 w5 C
    public static void main (String[] args)4 D. M- j1 [' o/ y0 S- D
            {
" N2 t# Z  \0 v$ z                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
8 S8 O. ]# z% O% u6 B* ?                ProgramCompare reached1 = new ProgramCompare(); 5 ]# F  n4 g& ?
                AuthorisedUsers reached2 = new AuthorisedUsers();        . n% R. r- p, W6 G
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
. L' v0 N, E" g  B                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
3 J% O# t- L0 d* U' g        }: V* t3 D4 h& I  B
}// end of class ProgramCompareMenu) H1 x1 g3 |4 y5 H- d

# k- ?5 {$ p$ k6 i+ t//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
' S* z* }3 X# }( d+ B//          AuthorisedUsers.java          Provided by: DRS
0 @/ V& J5 o" [- `( S: Q+ M1 \//               
6 w# Q# {8 m# C! R* b  @# e//         Program shell for Assignment 2: k5 u/ n8 p: A4 a! Y# g3 }  J
//
# M9 R' i6 e3 B, q5 `$ Z" q. ~//         Represents facts about an AuthorisedUser  H, o! W2 Y: c, s
//********************************************************************
% g( i* z' y; O) r. d9 S; q2 W- S8 _
, w! p. I8 ~% U) e7 Hpublic class AuthorisedUsers
* D3 v8 z. a0 R) y$ f+ H' o    {0 v7 t' @+ C0 \3 I+ a+ `
0 q+ C& R( C2 {: B. [9 X8 ]; A
        //-----------------------------------------------------------------
3 \4 F; e/ Y! c8 A6 B4 |        // Constructor( h& V& T: E( \8 h; F) c! C
        //-----------------------------------------------------------------
0 ?% K0 v. q, T7 ~( e# I! X
. ]. Z4 q/ x/ J9 ]& }        public AuthorisedUsers()$ u6 }6 ], h3 z* L0 W4 F9 ?' A
                {
5 ]9 b1 B( N+ F; v1 D. B                }
4 S9 M- E2 V. Q, u) s& C0 _4 D, z
3 M$ i1 b2 f% U  E) p        //-----------------------------------------------------------------" O' w  r* _0 M6 g0 _
        // Method for testing that class has been reached& O  d, u! `" N( N% Q8 F2 N: d
        //-----------------------------------------------------------------       
8 l- D& l' f1 R% I9 \* C, M2 D        public boolean AuthorisedUsersReached()' r+ w5 y- i7 Q9 E' F2 k& S( R
                {  S# Z2 t- a+ P6 H0 o7 i8 @
                        return true;                       
0 R! S, k9 ^! h" l1 W; b                }. N4 }2 B% ^( }6 q, h+ \
                " ]' F: s( }5 }# ?
    } // end of class AuthorisedUsers7 x6 a& b/ C2 z" _" Y' H$ b0 k
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
+ u% F: T: m0 ~) h7 M) _9 ~Shanghai - 20074 M' v6 |5 x# L9 q' D8 q8 ^
Assignment 2# S- z, i( x) ^! c& A/ w3 H9 ~1 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)- g; q6 w% Y4 B2 K, Y- u
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.: W9 f, L/ i- \) H7 v4 e
The staff must be able to:* J+ ^# f' r  D9 P. T; k
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
9 I5 }& w2 \; `+ @, r1. 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.
2 n( h8 h6 d5 s, z6 P* l3 O) x The interface should provide a menu so that the staff can:
# S+ I/ J' K# ]0 {a) Enter the names of the two Java program files to be compared% T2 X( S1 p1 E9 L+ `
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.0 K' ], r2 @3 g8 X3 ~) D2 ]+ ]
** 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).' a  I9 N( a# O8 C6 U- W% Z# k
BSA104 Business Programming – 2007: Assignment 26 Y. }1 w' U& l) j
Page 2 of 53 @- S  z( V1 w$ E3 p
b) Print out to the screen all the lines of code that are the same
  r% b5 c) \  ]0 t( O$ j, M Include the name of the file and the line number of the code being printed for each of the two files
1 j. V' }- q) j( F' H# }: ]1 g0 ?- vc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
0 o, Z  }) m( H2 i) u% H% d5 f0 i the name, username and department of the user# |2 L+ ?. a1 @, G- n* p) H) d
 the statistics of the comparison  e: i4 X# A2 W0 i: U
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different# S0 \# G5 g2 X* f- G2 T
 the recommendation for further checking; [0 Z: t& z# [- Y
- 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
. W; d6 ~& H2 e( q& L9 A7 g% ~ the names of the two files compared. x1 g  R2 C, Z6 G- {3 K
d) Leave the program (exit)) D1 y$ U  A" L0 E' d# Y0 b) K: x% a- `
The ProgramCompare class: (Total maximum 20 marks available)! b. u. o5 P7 d- p/ S* Z# P! R; F, A
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)
* v+ a* Q" f4 oa) provide an error message if the files are not found or there is a problem opening them) _: K2 D; I. b+ w$ U- H
b) compare each line of code
) P/ E; }8 |* V/ i% O- s5 {3 H" Zc) print out the lines that are the same8 O, t* W3 }. z" H% e
d) count the number of lines compared / lines the same
; [0 O( U0 K* l: MThe AuthorisedUsers class: (Total maximum 20 marks available). R+ j" H6 q! C  {2 ^$ H: N
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)
' A+ O) b) s4 B  Q3 P* {" c4. Provide methods to:
9 t' a4 j) Z6 G  @0 Ha) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match1 q7 i( M& R3 V
b) return the name of the authorised user
. X' W" L* o, ~c) return the name of the department of the authorised user
" D: N! b% ~) a4 n& |Individual Data (Maximum 20 marks available)
+ W1 n0 C2 N2 b, {8 G& n  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.
/ x7 X" l0 I+ n( p: GDocumentation (Maximum 10 marks available)+ p9 n8 Q2 [0 H2 o; g6 U; W
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.; v# U: W5 o2 ?! d# J
BSA104 Business Programming – 2007: Assignment 2% x1 }! J8 B. K4 C. C9 L
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
1 z& ?3 Q/ _7 G) z& w7 [" U% u不过你要翻JAVA的类库说明。你有下载没有?
5 F# n: x5 z( j: [7 `! k. d查询关于对比的函数。貌似关键字是contrast,还有compare
, R/ u6 w) r3 e+ {' _3 [9 z9 Y2 F5 [1 G+ r
4 a7 a& d8 Q- ]5 B/ E) w[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -, @. @( r) ~: q4 K4 D
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
& T- Y& _. O! A# b% X. o可以下载到的 是 jdk-1_X_0-doc
5 V: g9 U5 {' k0 X% z; Q# u, y2 u/ V. A' {( R. A) ]
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-1 01:15

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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