找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1298|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ( Q0 H' M$ A* N. u8 K" z+ X % j2 A& ^% Y6 u. D! M2 u
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************8 @5 a) F7 B, e: t- t; Q
//  ProgramCompare.java         Provided by: DRS
, v5 Q" I7 L: K3 [, ]/ [8 K//
) [' g! B  W! E: Z//  Program shell for Assignment 29 m: l6 B* V8 i2 ?6 W1 }. d/ i# y
//! m. `: k7 n* X
//  Compares two text files line by line
$ Y4 ^/ d1 `5 @" c% W1 \6 F//*********************************************************************
! ~; a( k8 [5 B- c* R; A1 h
+ F# F" w3 s! u% jimport java.io.*;
2 d. G! u! g* G/ i3 @- L8 E
" t, ]& H# [4 D* S6 f8 X/ D  o# k4 tpublic class ProgramCompare0 P& O6 d- t/ S* K2 C$ M; y8 P. ~
{9 E( k- X* p0 y. @
        //-----------------------------------------------------------------
4 Z2 q. Q! j2 q3 g: R        // Constructor
- ?9 [5 @+ W/ F6 L3 U/ b        //-----------------------------------------------------------------$ Z) F: Q7 x3 V2 V8 H! s
        public ProgramCompare(), p; ]; i& A! l! V+ T* s
        {4 c* b  N/ P" f
        }
* T1 W! m+ V8 K- d9 ?7 Q2 E5 s
# X( O7 _1 A+ z& v" X, l        //-----------------------------------------------------------------
7 i$ p9 }0 u, B        // Method for testing that class has been reached
1 x/ d3 ?) @3 U5 A        //-----------------------------------------------------------------        4 Y- _8 a) X! k" J$ h& l
& K& r  b8 ^; C' _: v8 `& u8 E# o3 d9 ^
        public boolean ProgramCompareReached()         # z7 T8 n$ A1 y( F" C
        {
6 w+ j6 l9 H+ W3 A, V      try " ?: K) }' s  D& V4 v
   {         2 O: l8 \6 x8 u, v! C
                       
2 I8 D  f1 I: H+ A( k" A, S                //********************************************************************" i7 b3 i( s9 U6 n2 V
                // Try-Catch Statement is used to handle exceptions - such as file not found
$ T( e& G  U' y                // Reading the files will need to be placed inside a Try-Catch - just like this one!
, B" I6 U+ S: F; u                // For more information see page 534 of the textbook& V5 L" F, f# [
                //********************************************************************, y$ n/ l9 w8 s  H3 F7 Z1 {
                    
! o: Y6 J' g3 a  ]4 T. i        }$ A$ Q, n1 C+ s( g8 ?
             catch (Exception ex) // Exception caught here and message displayed to the screen
2 K" ?, l5 U  G          {, v2 r  Y# N' L8 [
                    ex.printStackTrace (System.err);+ B; W7 B2 |/ o# {
           System.out.println ("Error message goes here"); // Replace this error message with your own          ) M0 \$ E5 s; Y! d
        }* g. K3 f+ v. q4 E" W
                return true;
5 [  ~$ y7 R5 M, @) M        }- H: B2 }, U  X: N, R4 D& P" N" ?
% O$ p& }0 k8 I* Q$ ]/ I0 r9 b
} // end of class ProgramCompare5 n9 c8 E% u7 R+ g6 \" T0 n0 q5 h
3 y  n; t; V& L, [
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
' T, E+ B+ a/ ~" o, L//  ProgramCompareMenu.java    Provided by: DRS; {) J5 D% N$ M/ \/ M
//" `5 ?' Z) F  G; v# u- H
//  Calls AuthorisedUsers.java and ProgramCompare.java
- `, a3 T4 Y, g! i7 V3 K//- \  R8 ^5 g# F$ g
//  Driver shell for Assignment 2.! z1 n! d! W8 f8 h( v
//********************************************************************
$ {. K) N" x8 T8 {* }. o/ I1 O, {. b0 N9 y4 E4 U
class ProgramCompareMenu  L$ @6 N: z5 i& n9 L" |, P% N
{
5 j. s  y* ?9 o" h2 N    public static void main (String[] args): g- l% Y) U* p8 C4 g. e
            {
( E& I- y0 W: p3 [                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
! z6 k* C) [4 B1 k/ B- T1 H4 m                ProgramCompare reached1 = new ProgramCompare();
" f6 g! Y- `8 G4 g% H4 p) [5 A. \                AuthorisedUsers reached2 = new AuthorisedUsers();       
6 A& @! m$ C$ r% D  g                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
3 s: C$ J0 r+ D- A* ~6 z: o                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        5 A% q- M6 k3 U9 t5 [) M' l
        }
. \1 t) }# C6 l. v: t0 \}// end of class ProgramCompareMenu
% f* d4 E$ J& }3 x
; A' L/ n! Z  |! _//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
" ^; c3 q5 p7 `! W- k! i/ q7 p//          AuthorisedUsers.java          Provided by: DRS& Z" h; l3 l8 P/ W2 D" y
//               
5 E7 ^/ M2 x9 t% S. N' ^7 o//         Program shell for Assignment 2
4 }# W9 }  H) z/ e//, t0 d5 m* N6 ^. T0 C
//         Represents facts about an AuthorisedUser
2 i1 s5 q' E1 G0 w, j" Q//********************************************************************
+ F( N% y* {1 B  c( W8 M
  A2 G3 e2 P/ h! N$ Jpublic class AuthorisedUsers
$ h5 c+ R- n0 Q5 x% C8 k1 _    {) X% v8 [* ~8 w: Y; Y
6 w7 M- q$ f8 Q. {1 k1 W# G/ r
        //-----------------------------------------------------------------! J8 {+ B. N' ?7 |0 Q/ j
        // Constructor& n; o8 T6 a5 B
        //-----------------------------------------------------------------6 g! D' T5 \4 r5 ?* y$ c) j* c5 H

0 v& P0 [# Z$ A2 u9 N1 i        public AuthorisedUsers()
/ T& W5 @# H: j5 s6 o# w6 k                {' P' Q  F& \* H* `$ V
                }9 j3 k6 g/ f6 C2 L3 S, U0 P
: X5 B! r* u$ ?( H$ e
        //-----------------------------------------------------------------) [9 P2 d  l) c
        // Method for testing that class has been reached# a" S( [5 d6 u# p5 E! u
        //-----------------------------------------------------------------       
6 P' P( ?8 d, ]( C# X        public boolean AuthorisedUsersReached()+ r: t/ L, T; T/ W
                {
2 V, \0 `0 i( k2 q' R. D5 J                        return true;                       
/ \* x) h# {* L' E                }
, }- a! h2 {) }' G                , w2 Z6 e' [8 M$ d& j
    } // end of class AuthorisedUsers
& [- g/ j: E4 c' G1 ~' N//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
3 x% N* g! u! r3 }4 J* o1 hShanghai - 2007; }0 Q, t6 Q7 p! r
Assignment 2) I5 M9 @* H" M# C. ]( P
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)
; ^- w4 Z6 E' w) V$ S1. 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.; Q) S5 t5 C# N2 D1 o- Q) O/ _/ J
The staff must be able to:
3 g9 q; E  n( Y4 k5 y- ]2 R Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
& b# P) z/ h& j# h. e$ w1. 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.. ?* P. E, ^) _$ k& V2 r2 D
 The interface should provide a menu so that the staff can:
1 K) g5 G" h, s/ s+ P5 O7 ea) Enter the names of the two Java program files to be compared
! K* I! |; Z2 P6 _" u" ?; c For this assignment, it will be assumed that the two Java program files are in the same folder as your program.8 P( L! ~1 }: V! d4 i! y
** 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 N5 H" k: c2 _( S, R
BSA104 Business Programming – 2007: Assignment 2* v9 z; p, j; ?/ a. G1 `" Z
Page 2 of 55 x0 h, S* w% }: [9 a& H( m5 G/ y2 ~6 z
b) Print out to the screen all the lines of code that are the same+ S6 E) y; @0 U8 `9 s& ]% q
 Include the name of the file and the line number of the code being printed for each of the two files
  m  x: S' a/ q0 d4 o5 b5 ^& N6 rc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
) T& L! A2 H! B/ g/ g the name, username and department of the user  w3 F. F/ [" \3 _3 }
 the statistics of the comparison
- Q/ @' V9 ~2 D3 X- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
5 t4 w' @3 R( A/ z; R the recommendation for further checking
* M+ v* Z8 }' S( D- 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 r6 b& `& |6 B7 s
 the names of the two files compared
2 ^! Z- ~) _1 K; j7 X# {d) Leave the program (exit)! D7 J/ c; M3 T+ l
The ProgramCompare class: (Total maximum 20 marks available)* Y, ~& x, {4 ]; c
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)5 r6 [; M7 G3 G) a& _8 K+ g! h
a) provide an error message if the files are not found or there is a problem opening them( x% N, B9 N' s) e9 q
b) compare each line of code
& k# N8 l  z# I4 i( Qc) print out the lines that are the same
% N2 X$ T, ~3 Y, K( \d) count the number of lines compared / lines the same! @# v& i" [- Q" {, O
The AuthorisedUsers class: (Total maximum 20 marks available)6 c; C3 L5 N& I& u* R6 }
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)
/ g. a, c9 e9 y3 c- y* T1 ^0 z% b4. Provide methods to:* d7 F1 \- v% J
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
% C: `1 ~+ O: T7 Mb) return the name of the authorised user- z: v4 V/ G5 l- u' \+ m
c) return the name of the department of the authorised user, t2 x2 @4 \4 i* @
Individual Data (Maximum 20 marks available)
4 [( f$ R4 ~4 V: g9 d2 c5. 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.
, }8 }- w: a" ?0 TDocumentation (Maximum 10 marks available)( D$ s, V( R3 O' ^
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.
  s9 {4 s7 p' `, nBSA104 Business Programming – 2007: Assignment 2
- o1 n, G* k- U0 L: KPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
( j7 W3 w+ Z; s0 y! {+ m不过你要翻JAVA的类库说明。你有下载没有?4 J+ {. _( h: x' e) G8 q
查询关于对比的函数。貌似关键字是contrast,还有compare( J1 ^; E7 X3 q: ~

- T3 b$ R" \& C" a: j9 ?3 A: Q  I" _[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
  `( a1 {# h3 _5 ?5 c7 d痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
- _8 k( X& f9 Y! p5 Y1 @1 Y* |7 V: C/ ]可以下载到的 是 jdk-1_X_0-doc
# D2 ]+ e% |2 {- z6 b
: f7 f. h: p7 U1 X2 f[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-20 03:55

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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