找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1505|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 5 L0 M% k1 u) B8 n* H$ i/ d7 {7 }3 H% B, Z
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************3 M4 E( e2 n0 ]5 i
//  ProgramCompare.java         Provided by: DRS5 z/ P0 i" e  i
//
4 b! {5 K4 h  x6 Z% N$ U: O6 O+ ^//  Program shell for Assignment 26 p* L; V: |5 {* }4 x
//. c9 ]8 y- U4 N4 T) G
//  Compares two text files line by line5 N/ v0 q. d& {' a$ X% W
//*********************************************************************+ e  w7 U8 A2 q' K' Y

" P! R. Z9 [6 N! Oimport java.io.*;
* @( k' u( j  i' {# X$ b, V: W( y
; Q( J2 y: K, R. fpublic class ProgramCompare  n. z1 _/ O$ k9 Q1 s% I
{+ o9 O+ i! j) O  Q0 J! |% y8 Q
        //-----------------------------------------------------------------# M+ \/ M  M5 [' h; Q" t( O4 M* k+ M
        // Constructor
) s! e/ x9 J: W5 k  o3 Z        //-----------------------------------------------------------------8 `8 B0 J6 D) x9 J4 t( W' @; J
        public ProgramCompare()
1 m- `$ C1 B0 a9 h8 n8 X  q        {9 J3 M) _1 L* a; z( }8 K" y( f
        }, X3 p/ @/ E. w. E+ @, G, T

8 }* e8 |5 `7 |        //-----------------------------------------------------------------
0 i! j4 x4 k/ D9 e6 j/ I% d; D% [        // Method for testing that class has been reached
& I6 L4 q8 B7 ^6 k! P        //-----------------------------------------------------------------       
4 W4 t, h" V( c: X( @- j9 R- n/ q. j0 S5 N$ m2 a% i! U; Y
        public boolean ProgramCompareReached()        
3 V0 X5 }0 W( N$ o9 w( @        {
$ u* E9 @: V8 R( W      try
$ A% R# L2 K: K2 `8 W   {         . o7 h; h2 [7 z# N
                       
5 x8 m, O9 R$ c) u* n/ v  }! i                //********************************************************************
) P: G  i0 }/ x6 I/ J' h' Z) v                // Try-Catch Statement is used to handle exceptions - such as file not found
3 c+ z+ z8 j0 m" Q$ f0 D- Z                // Reading the files will need to be placed inside a Try-Catch - just like this one!+ h% k8 U& N8 e. g9 z
                // For more information see page 534 of the textbook7 E* y7 S! {$ _
                //********************************************************************
: i6 u- F. B8 W  G5 C                    
, b/ P0 s' Z' W0 K  Q        }9 q' b" N9 b( @* ?
             catch (Exception ex) // Exception caught here and message displayed to the screen ' @' e$ j$ m* Q2 c3 i2 T
          {7 W; }. N9 i1 X, G
                    ex.printStackTrace (System.err);
% _8 y6 u- O. K9 R2 ^           System.out.println ("Error message goes here"); // Replace this error message with your own         
. ~1 M8 o/ ], u- `6 b: t' a( G        }8 [# k2 [+ W, U
                return true;3 Z8 _" u6 q7 [
        }
6 O) y4 z" ?# w, z7 Q1 ^: ?4 V. w- S+ G; B8 z( E7 M
} // end of class ProgramCompare
) ]% }9 {0 W1 S
# {+ S) Q+ o6 I4 |. r//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************; a' Y4 y, h8 ]7 \5 t8 y
//  ProgramCompareMenu.java    Provided by: DRS
! [  |; I& h& }8 v) \* \//: j% [( p7 |. a) W0 U( j& t
//  Calls AuthorisedUsers.java and ProgramCompare.java9 ?: y( I) |# l$ Z& ]1 h  L
//
$ N5 x) |! f9 i//  Driver shell for Assignment 2.& G. v. J' A) o0 z, m% c% M3 \" c
//********************************************************************
2 k* S0 h" J) q0 U4 s- u6 S/ `3 ^# K  O' L8 [9 |$ c4 y
class ProgramCompareMenu
6 X0 x/ J& s, H1 q" _{8 v: T( Q9 y# |7 `' H; l9 V9 Z2 X
    public static void main (String[] args)
% a6 m. o6 T3 N" Z            {3 _4 x0 I" g( c" Z, n0 F
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
+ j3 S( b) a7 C9 w" g                ProgramCompare reached1 = new ProgramCompare(); 8 W# l/ o/ f/ o$ f' b+ b9 K' N
                AuthorisedUsers reached2 = new AuthorisedUsers();       
" m+ k. X9 h, u* q) d- A                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());) V2 V0 Z( `4 X  K" z
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
' Y  m+ E1 O1 i$ M        }! ~1 [$ ]% T. V3 @8 ]& d, ?) j
}// end of class ProgramCompareMenu0 q4 @* |  E0 n% @
! J1 ?- X6 X  R  ~" x# F$ \- w
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
' p0 P; Q$ X' L& ?//          AuthorisedUsers.java          Provided by: DRS$ |* t: D( o' e6 i8 W
//               
$ i2 R& W2 g$ c( S% \8 s//         Program shell for Assignment 2. E% N+ w6 {7 b* V
//
# p( O' g) J8 _* d7 k$ ?6 z" t; x//         Represents facts about an AuthorisedUser
, {, ?. z; f/ H; h* g' z6 \% Z. A2 F//********************************************************************
: M+ S2 g! v3 Z; R9 a6 e( x; t) [0 `7 O% q3 g! t4 a
public class AuthorisedUsers
( M4 r7 k5 O8 A, O6 b% g    {# o' X7 B5 D# N* @) t* c
: z/ D5 N+ `9 n3 M. W1 v
        //-----------------------------------------------------------------
* u( g9 ?- e5 m( h$ ?7 l  U        // Constructor6 M, a3 G- r4 {
        //-----------------------------------------------------------------6 q8 z$ }; B# o+ v4 F
# y4 n8 j7 p# \* \8 d" v
        public AuthorisedUsers()
* q' F$ f0 a/ ^& o                {+ q6 T& d( P# D& ~
                }
0 S  A  K% a9 i1 {
/ g* r% f$ q2 K6 ~& i        //-----------------------------------------------------------------2 U: v# @3 s: a- n  o" [* I
        // Method for testing that class has been reached
0 @' l& T* `6 f3 W/ R" G8 N        //-----------------------------------------------------------------        ) ?" K7 T4 a2 A* G$ M9 p
        public boolean AuthorisedUsersReached()6 o8 k7 e3 Y+ o1 e' W; I/ h
                {
) C7 |. t& d1 |& r! T! z                        return true;                        5 @8 t* V1 [. A+ X  Z6 [
                }
, l- ~  v; a7 A) \: c8 J                9 M$ r# W3 j( o9 x2 O
    } // end of class AuthorisedUsers
' z" T# Q6 t7 Y% c. w6 J//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming, n' O. G' e6 x, z9 ]: b; y" B
Shanghai - 2007
# g4 f; j; I5 a2 ]% h: i) \Assignment 29 z# s& y5 n& _1 ~: y8 d
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)
! c! O/ P0 @7 X$ h$ n# L5 V5 @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.
, T6 R' j' [/ {% S) h) l6 iThe staff must be able to:5 F- R0 x8 u- a* |2 X
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.8 Y+ ^9 ~6 z' |  O. u/ Q
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.
, u: W- ~" ~8 k. l$ N$ l! l The interface should provide a menu so that the staff can:! d- M: o2 Y; n6 J3 |  G; ]1 _) @
a) Enter the names of the two Java program files to be compared" Y; k; N1 Z  j$ D# S' h
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.8 F" N! U4 C$ x8 }/ i
** 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).
* }" o3 Z2 S  O6 @, \BSA104 Business Programming – 2007: Assignment 2
) g7 n/ x% X- L! F: nPage 2 of 51 L+ R: [& u1 o% C! \
b) Print out to the screen all the lines of code that are the same
. P4 o: a, `0 j Include the name of the file and the line number of the code being printed for each of the two files, h% |8 G; Q- _- L1 S$ B3 {
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
5 @+ ~+ c( t: @, U0 D* {# u the name, username and department of the user
6 M* K$ E- a% Q4 ~ the statistics of the comparison* _' }) j- f! t5 g7 F) x
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different0 M! Z) f8 f+ `! {3 B
 the recommendation for further checking7 K8 }' i$ F  k& 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 closely7 V) m. `0 a& ^5 S. j
 the names of the two files compared2 j. l$ F4 I/ \2 y3 K  ]2 Q
d) Leave the program (exit)
% {8 F* ]' @3 e8 k- J1 {, g) KThe ProgramCompare class: (Total maximum 20 marks available)1 j! f- D+ o# ~8 v, `6 J
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)
& S5 N8 k- P# Z/ Z( D# `a) provide an error message if the files are not found or there is a problem opening them2 C7 }6 Y% A1 n. C$ ]
b) compare each line of code
0 ^' @2 z; @7 M9 j/ U: |7 ~c) print out the lines that are the same4 E7 y- D; i8 |) i- m
d) count the number of lines compared / lines the same
$ o: H" {. x& d  EThe AuthorisedUsers class: (Total maximum 20 marks available)
. X# P7 w9 z4 r( w3. 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 N& S% f/ g4 B1 ]: U, p8 v- q
4. Provide methods to:
' m0 Q0 t. o+ Za) 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
" l- z, O% T( w1 V7 Q! B: nb) return the name of the authorised user
. `2 c- [( o8 `# @0 Qc) return the name of the department of the authorised user
9 e2 J  X; L) E8 `9 _Individual Data (Maximum 20 marks available)* g- V6 }) a" I7 A' o& y
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 Z2 O4 K6 M+ Y3 P( ]' lDocumentation (Maximum 10 marks available)
4 b2 E* T7 s  z5 L' a! ?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.
% l# y! t) v- ?: W% v! q% p# f% CBSA104 Business Programming – 2007: Assignment 2
2 c4 E9 l# h( y6 H- pPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了( Y0 P8 r1 K6 R
不过你要翻JAVA的类库说明。你有下载没有?
+ q5 ^1 j  x& i# ~: M查询关于对比的函数。貌似关键字是contrast,还有compare1 E3 v0 x2 Z9 Z" L+ v! m3 ?* X
' X* `( T3 N$ D+ \# ^
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -. H& M1 D/ I, p; n0 ?
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
- j. A$ X9 @9 ~. R2 ~可以下载到的 是 jdk-1_X_0-doc, S' E; p- Q" Q7 b% Y

$ k; j! J4 k( C- j: J) o% d* C[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-29 19:49

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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