找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1137|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 * ~3 p1 @# W. S2 T. E2 N3 C8 q% i x$ ]3 U' t
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************. H  E9 e& v; K0 E" ^& l1 x' p
//  ProgramCompare.java         Provided by: DRS9 Y- b" ?6 `% F
//( L& X' c& J! Z& Z
//  Program shell for Assignment 20 q. j* q$ N- Z. [" w
//9 m" O: @7 B. o6 {9 v; ]
//  Compares two text files line by line3 [% s# X) b: T: @8 y
//*********************************************************************
' @6 [' W) S# M! n* Y( D" \" y+ T- Q, }
import java.io.*;; h$ _# ]4 B, D9 e# w

% i7 a; A; Q$ y; a; X  wpublic class ProgramCompare( I' |, i0 q) e' {  I- J4 O
{; q, Z, P- t; w
        //-----------------------------------------------------------------. [: n) \0 l6 h! b6 b2 `, X3 v
        // Constructor$ E& i- I' h) f7 c
        //-----------------------------------------------------------------
/ v& L' K' P1 I7 \        public ProgramCompare(), R' C, E, v' x& P: K" C: X( R
        {* c8 t0 D2 o+ s5 W, v$ Z7 Z
        }
) h) S/ n) S* p' h. A( ^* }
' B* N- F" A9 j+ v& [        //-----------------------------------------------------------------3 o. C. C. `) v8 t9 q
        // Method for testing that class has been reached/ ~- J& y6 b$ u5 S1 n. X( G/ V
        //-----------------------------------------------------------------       
0 ~+ \9 }- n" [9 O
5 ^( s/ ?) q) T1 r; k        public boolean ProgramCompareReached()         ( u6 V( O' U+ q4 Z  b, R
        {! r9 o, A! [/ T/ w8 V% m& E7 h
      try , O; D  X. [' f
   {         3 l1 @8 I8 H: n3 B; N+ ^
                       
6 I, j& G, W0 n) `" K$ V                //********************************************************************4 Q3 Y1 t" C  v- h5 P/ V& h
                // Try-Catch Statement is used to handle exceptions - such as file not found
. l& Z! g: q+ H! z4 b- P' b                // Reading the files will need to be placed inside a Try-Catch - just like this one!
8 \6 ^+ J3 j, E! i1 R. V                // For more information see page 534 of the textbook0 B1 |! f; z; \/ v. p2 F& k' V
                //********************************************************************0 U: p7 @, l, O: V' @
                    
7 _/ G/ v4 C5 D: h4 K' u        }: k7 Q: f- I( q4 v" k: g6 ?
             catch (Exception ex) // Exception caught here and message displayed to the screen ! R. g  R* @  u# u5 E! x
          {/ k" T2 {0 e. g: r0 K$ R1 F
                    ex.printStackTrace (System.err);
. @( F% i7 _5 i5 N5 ^) D           System.out.println ("Error message goes here"); // Replace this error message with your own         
6 B1 V- y  r0 l! r+ |" J8 U( X        }& ~+ x; @! {: {  Z
                return true;8 Z1 Y7 z5 e9 p% r) g
        }
; @6 L- N* U/ S; u" Y6 a$ }. d
} // end of class ProgramCompare
% U% z9 B1 f0 }7 y& [( {8 g$ P0 v, [) B7 P
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
% B. W  G, _8 f. W- C9 g$ T! v//  ProgramCompareMenu.java    Provided by: DRS
4 P' R, H- A" M//. u% v& c$ |5 D% A- `7 u9 ^
//  Calls AuthorisedUsers.java and ProgramCompare.java/ @. B. Z) D7 t+ a: A
//
0 T) U9 s% v& ?//  Driver shell for Assignment 2.
. F) @. W3 C0 T% Z/ c3 A+ M1 ]2 ^//********************************************************************
4 e. J7 E$ O6 d7 @$ U
) o" f" O+ ^* V+ H2 e4 q% aclass ProgramCompareMenu( V! o9 n: s1 S: {$ a
{
. t  [6 m5 t7 q  d- o" E  z    public static void main (String[] args)
/ _' q! e  H) V  S; T# C4 R' l' D# `. `            {' F4 l4 V8 M6 H% s
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
/ f4 k! S; {. s5 l6 J) V: R                ProgramCompare reached1 = new ProgramCompare(); 2 o$ Q% `( u; E8 U9 N5 O
                AuthorisedUsers reached2 = new AuthorisedUsers();       
( ?! c  g5 a. K* U                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());* f% ^2 @# `$ Y. r5 y
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        , i8 L: X1 {! [; z2 ?
        }2 f" V  s7 w5 j" ?* g; ?
}// end of class ProgramCompareMenu
/ z3 u9 \0 U1 {+ r: t9 _# x4 `0 `( }- C6 j
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
( R# K+ W1 A- x; |8 ~: p//          AuthorisedUsers.java          Provided by: DRS% G' M; U! [4 o6 l) Y3 @# M
//               
, ]1 ]6 u( ?2 X7 v3 n3 z" Q//         Program shell for Assignment 2. |) K7 i0 w( v
//
+ Y- L& w0 Z% s5 r) L//         Represents facts about an AuthorisedUser0 v# S+ x& L4 A$ J* H9 o. h) A
//********************************************************************
' [; E. M( `( G9 A& _; S$ l( U# S+ M/ J, {
public class AuthorisedUsers0 D) ^/ i# j: ~; Q) e/ q
    {3 T4 v) `- w4 a. }. \  c) Y
" R4 q+ ?9 r6 u4 n. T# A& `; c  E
        //------------------------------------------------------------------ X% v+ o) C; r( l& E
        // Constructor/ O0 K* b. M* V) l/ {
        //-----------------------------------------------------------------+ `( O6 N$ i7 `& E+ `: w1 ?

( c- G- p4 L( j- ?% w$ _        public AuthorisedUsers(). M4 @5 |# _5 _! d* |1 q( ^9 n
                {
3 i1 j: o0 K* S* ]5 E; \8 O5 w- t2 Z                }
2 T! e; L7 A! |9 F0 p
* ~' K* Z" E% s; I: q+ o5 {- t7 H        //-----------------------------------------------------------------
2 c" H% _+ [/ d! d3 u% i% d* i( n        // Method for testing that class has been reached
: f; j) R$ _8 R/ x( I        //-----------------------------------------------------------------        $ V% M- }5 r! i" ]' P+ ^2 Y
        public boolean AuthorisedUsersReached(), O0 y! J4 l; ~
                {
5 `: k* }; u0 v8 i6 Z                        return true;                       
* ]+ i. _: _6 x& h1 C9 e                }/ s4 R- v' ~/ U) C4 w) N, K
                ! {% T3 c& _( o! o
    } // end of class AuthorisedUsers
! o% m% s' h; ^//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
+ D- @7 T4 D& I  I; w  V% |0 @6 h0 LShanghai - 2007# j* g# k- ?! p* g, L' Y0 [% {. K
Assignment 23 I$ X! f/ _; s. O* E5 K) S
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)- d# d) y$ w$ Y! m  v! w5 j+ @! R
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 y6 O2 E: q" Y% U; i0 O8 g# N; V5 PThe staff must be able to:# `, A" N" k1 T# |9 W; i4 Y
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
! v7 ~/ V6 W/ x+ }/ {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.
2 r& k) y- k) U! I; Q3 }) q+ L The interface should provide a menu so that the staff can:4 N# U- A% f7 R8 y+ ~
a) Enter the names of the two Java program files to be compared" l3 B; O1 }( G: ?' ]
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
/ ]! y1 C' W* L** 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).
6 x0 s: Q8 _% G. YBSA104 Business Programming – 2007: Assignment 2
9 u: r" N4 V% C, hPage 2 of 5) L/ V% L2 ?" D+ }, j" }) g6 P
b) Print out to the screen all the lines of code that are the same
  Q' p" q$ j) t& D2 u Include the name of the file and the line number of the code being printed for each of the two files' y) _+ g. B4 q; x
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared) `/ D) G" g9 I3 f" k# R2 L
 the name, username and department of the user5 Q0 f1 c7 v% d5 X
 the statistics of the comparison
1 U( {3 i# w9 W9 o- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different6 M' }6 d) s: q7 ^
 the recommendation for further checking
& U5 R" a: P, D+ b' \0 g; N% m8 [6 w/ k- 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
6 ?4 P, z$ I2 v1 x% ~) t the names of the two files compared
' G7 l  K* g7 M; C: q: d& Qd) Leave the program (exit)0 O: d9 Y# k" s& Y2 K" R; w
The ProgramCompare class: (Total maximum 20 marks available)* ?; }0 p: w1 `, Q
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)( W  c5 h) n3 w
a) provide an error message if the files are not found or there is a problem opening them, I" m3 z8 }1 t0 b- Y! J% l. ]
b) compare each line of code+ u, m5 w! ]8 g8 P1 o
c) print out the lines that are the same4 A/ m( x' i8 `  V8 ]& u
d) count the number of lines compared / lines the same1 @% D) T0 `! R2 C6 l% [1 _* S
The AuthorisedUsers class: (Total maximum 20 marks available)
9 C0 G9 y0 F9 X  {$ R3. 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)
" I8 d# S: H2 |: ]4. Provide methods to:0 U$ h: w$ E& ]# `
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
, w' s5 G7 f# I5 X, fb) return the name of the authorised user
- d5 b. D9 m# e! }( m) V. `; p) yc) return the name of the department of the authorised user
8 r* Y$ p; C4 W9 T) uIndividual Data (Maximum 20 marks available)- n$ x( l/ K; R3 ^
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.
2 s0 g# I$ C3 `" u$ ~7 H9 r6 p3 iDocumentation (Maximum 10 marks available)
! U# v' v  T2 {: @3 f* a6. 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.
. d. u  q1 ~* J  ]7 P) i4 BBSA104 Business Programming – 2007: Assignment 2+ a4 T$ Q/ ~3 S% r
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了" r2 N- q8 _# H, w# e' U! I
不过你要翻JAVA的类库说明。你有下载没有?
. j/ n' H& n2 X查询关于对比的函数。貌似关键字是contrast,还有compare
8 @* C5 @: K" Z% O' ~9 q5 {. e/ k; h- Q+ W5 G8 M! P7 }4 y7 A: V
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -4 Z% v7 u* b; w1 Y  U9 ~
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
" }( V& C8 _' a可以下载到的 是 jdk-1_X_0-doc( x/ N9 I* ^; J. ^2 j# ]

2 @4 p( U7 w1 [4 D( m[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-3-23 18:02

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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