找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1857|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急3 o) a3 x! h& `* G 0 ~- b3 a/ G. J! `' C- d8 x9 z, _7 a
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************7 q  `: t5 {5 d9 I% f$ w) C
//  ProgramCompare.java         Provided by: DRS, @3 c: ?2 }- S- |3 _: L
//
$ J7 x3 v& v! u* x//  Program shell for Assignment 2
: E' a3 v4 K  e- s) t. j//& C+ ?2 b& n" E6 q' X* b# X
//  Compares two text files line by line; C+ l7 Z' l8 l) X. M
//*********************************************************************
+ v" j; r+ S0 R0 a# ~8 }" v; a' j! E5 |2 G/ ?/ N& P
import java.io.*;
' s" e1 \3 M4 g& O
0 I: c! w& l$ L+ W! X3 bpublic class ProgramCompare
4 \; f" V, Z  B/ _{
  \( P( T  p7 E! z: w8 D        //-----------------------------------------------------------------. U% q" y! z* s: ]1 l3 P1 H
        // Constructor2 [: A1 W1 k+ W7 w2 Y
        //-----------------------------------------------------------------
8 z3 \' G1 L3 L+ E0 ]/ {+ q2 L# l        public ProgramCompare()
% t( m. V# u& Y: \0 @        {
) Q1 q3 L8 i) U        }5 k  z$ h3 x( W/ K6 y8 J4 ?, \6 U' d

% W0 P' z5 G9 _9 n/ K2 v        //-----------------------------------------------------------------" Q9 B4 w( d* n
        // Method for testing that class has been reached
8 ~* Q( j, c: h3 _* x( _" ^        //-----------------------------------------------------------------        ! X  T' S; ?- L$ f

3 G4 d" g/ L2 z! F: L        public boolean ProgramCompareReached()         / u  j* P* @! T9 W( P5 S( W- T
        {1 K) y% _: P! n# t
      try + M, ]; i# {( k2 n) l$ y% ]1 J
   {        
3 M1 Q; j  n/ ?8 {2 S, D  R                          L! e8 \' L9 I
                //********************************************************************
( ]8 W( ^" \& c& O5 u! {4 D7 o                // Try-Catch Statement is used to handle exceptions - such as file not found ! ]2 S: W0 Q  @" I1 K4 L" `. ?. N0 Z$ g
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
, S1 ], i+ U) {; }5 {' @                // For more information see page 534 of the textbook! j' q1 V9 D5 h, e. I$ \  G; o
                //********************************************************************/ F1 u& |/ H! Z" K! T6 B& O
                     , ]( g: d3 Y* y+ a
        }. |4 V) _  y1 t. e4 \
             catch (Exception ex) // Exception caught here and message displayed to the screen
: G, A1 F( @* ?  T& N          {1 w$ M* G7 U: V
                    ex.printStackTrace (System.err);
. t" T' H+ m1 B' f* O& d7 Y$ D* S           System.out.println ("Error message goes here"); // Replace this error message with your own          ( \0 H! s" ~1 X, r) M( Q, H
        }, q$ w! ~! j6 {' q/ n) f
                return true;
6 p7 Y* K( }  i  s; Y4 P$ D1 W2 Y, L        }
' w7 S) k/ {$ C0 Q7 d7 T, Y
3 x1 Z/ X! Z- ?4 W} // end of class ProgramCompare
; h# r6 w, D3 J: t, P! G* Q- d# Z- A- ~0 H9 a. w) w" K3 q
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************, C' l% y0 w/ ~* g1 G3 S/ W2 l$ r+ g
//  ProgramCompareMenu.java    Provided by: DRS
6 P' o$ l2 u# t7 \//
9 x, n4 Y2 ^2 P) L//  Calls AuthorisedUsers.java and ProgramCompare.java) i+ o: i" ~  ]. ^5 x
//- B) @' D3 f2 x% W) P8 ~
//  Driver shell for Assignment 2.
. j% _8 B& s" `7 H4 O//********************************************************************3 f. m+ w4 Y9 ~
2 l4 @) ^: W$ D& |  L, r
class ProgramCompareMenu. O/ P8 K9 |( p( G  T+ @
{
7 g9 j8 X( d8 F2 A1 }    public static void main (String[] args)
( t# h( {* L% w! r* X7 G! T+ t            {1 c& j1 S- |( \! e
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable2 {% J8 Q" B1 d7 Q2 ^5 _
                ProgramCompare reached1 = new ProgramCompare();
. l& h, z- P# B! w1 Q: G1 c                AuthorisedUsers reached2 = new AuthorisedUsers();       
5 a; [5 h. c* N0 \( v9 x+ v6 I                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
; |1 r& Z9 c) D, F4 ~                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
! ~: x- F% R6 D& j+ v  G# _        }" Z' q& Z" Z# h5 }
}// end of class ProgramCompareMenu
9 Z: E0 q0 E, U' j2 H. D+ a, A1 T+ J0 m  D7 |& t7 ]% L: Y
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
4 f1 h+ Y3 s/ u/ s' `% L0 m7 H//          AuthorisedUsers.java          Provided by: DRS4 p( i! }  A. K8 Y
//               
, e7 ^& W) z  S- T: v* q//         Program shell for Assignment 28 Y6 T! }1 V1 z0 z! k1 B
//. Z% G$ c, a4 d7 o" m
//         Represents facts about an AuthorisedUser9 K. P% t% `! e3 b
//********************************************************************
8 ^* D# k6 U  E5 a: j( }
2 f% B+ Z9 j0 {$ c! ]public class AuthorisedUsers. k' d3 w% L" r: ^$ E1 }- t
    {  I9 q: d6 ^# A9 K! H' I4 g* W# s

& g9 p0 E' ~3 v7 x( b" U        //-----------------------------------------------------------------
% C. ]4 {( `8 ?7 S  z  {        // Constructor
/ r3 ~1 n, ]8 o  |        //-----------------------------------------------------------------3 j& P! _7 z" Q8 E

$ o& s% g4 d8 Z        public AuthorisedUsers()( _  G' N. Q+ L. B6 s
                {5 F( r/ Y9 _% l3 Z* W3 {' s: i+ q
                }
# t) H; t, J  a( h! e
3 O6 d& v% H( K! U        //-----------------------------------------------------------------
( d, a! Y* F5 s. `+ |        // Method for testing that class has been reached
3 w! t" u  g9 ~; ?: e        //-----------------------------------------------------------------       
( F# _0 [8 Y0 M9 i$ m0 Q! a        public boolean AuthorisedUsersReached()1 @2 v% c+ I6 U5 ^" V: B! a
                {
1 J' G; f! I" n# T                        return true;                        ' @" q" W- R! r8 H% J7 {) Z5 x
                }* |5 z7 n9 u, f
                ' v* R( b  A3 u  ~  O, ~
    } // end of class AuthorisedUsers$ l9 f  [5 U9 X
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
" L4 G4 z7 ?& pShanghai - 20076 G) m1 p8 r" J& r9 c; q5 z
Assignment 2
! w" }2 }0 Q* {9 A& m/ PDeadline 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)
: z: u' a7 J4 W% [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.
' [1 f1 J9 y  E8 e) Q. LThe staff must be able to:4 Y1 B. p5 o: t" ?9 v
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.5 e2 y- C+ s* B  U6 w; t7 S3 o2 V
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.
7 M# J) K( l1 Q" L# G1 S! u The interface should provide a menu so that the staff can:  c& [  v" C+ Z) w
a) Enter the names of the two Java program files to be compared
& a8 d7 L4 J  B" b For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
8 ]9 f% d' v" J* ^7 R# V** 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 ^( }+ a: T/ T* i- y1 kBSA104 Business Programming – 2007: Assignment 2- J, V) _" x5 \" \# v5 g3 z. D9 h
Page 2 of 5
, ?. X8 T& r% Mb) Print out to the screen all the lines of code that are the same
6 C1 p$ i, s  @8 a5 m+ I" w( { Include the name of the file and the line number of the code being printed for each of the two files
3 T' q) X( M. s( C" Q. u! mc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
' W6 h! r) q5 R3 e1 A3 v' Z the name, username and department of the user
' O; T& ?7 G7 Z the statistics of the comparison6 o% k" U. T) ]9 D& W8 n2 y
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
' H" c& l3 \$ v* ^* u! [2 s/ o# A the recommendation for further checking
9 N$ p- ~$ k' ?1 V- 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 closely8 B1 t8 Q! c3 N- \( `) B
 the names of the two files compared
  ?8 ]! y/ N+ s/ Nd) Leave the program (exit)
6 M" d  Y; W& ^3 Q# t8 CThe ProgramCompare class: (Total maximum 20 marks available)
( A% e; C7 G$ P0 O% s2. 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)
8 ~0 i' E5 _. Q7 ra) provide an error message if the files are not found or there is a problem opening them# i2 W/ a; w3 L# B2 M: [
b) compare each line of code
% N6 o, r( i8 \6 C$ ^% l" d8 tc) print out the lines that are the same
) E* T% E/ c- ?  I9 md) count the number of lines compared / lines the same' w) R: u! a; Y* ^9 t0 r
The AuthorisedUsers class: (Total maximum 20 marks available)8 p6 b1 J( l* q. T: p# f
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)5 k1 ^8 P" a! S2 D8 W
4. Provide methods to:1 s5 }0 ?+ ^/ c& a2 K
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  o8 R7 U* T* l$ y2 L+ V# G( g
b) return the name of the authorised user
# p5 b! n5 `! n& D: sc) return the name of the department of the authorised user
" y% S8 g- M# }" w# ~' U& IIndividual Data (Maximum 20 marks available)- ?7 l$ ]& b$ ^
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.
- O6 h2 K3 [6 S5 E, PDocumentation (Maximum 10 marks available)9 ~# ~0 T3 V& F5 }  f3 w3 u
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.
& r6 x* m& G* L) NBSA104 Business Programming – 2007: Assignment 2
5 R  h/ V: c6 U8 O0 W) l  o* _Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了. R5 @& o  K# Z: J
不过你要翻JAVA的类库说明。你有下载没有?
$ D7 V- n# e" t查询关于对比的函数。貌似关键字是contrast,还有compare
; g9 m- F/ q; x' l6 R( s$ }
% E( N/ ^, N$ r& i; m, B+ z( a[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -6 l, t8 T' g  p0 ?# [( }# g: `
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。( D6 C- K# m) f' ~7 ]
可以下载到的 是 jdk-1_X_0-doc& x) [$ S' a0 x9 T$ h8 V* F$ d

) n$ o; C: t7 i7 W+ e. X) G[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-26 04:25

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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