找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1837|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 # x+ j3 C1 @: ?8 n; o+ X9 R' U; j0 N+ k# I; e0 O
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
4 X" A  v3 S- ]9 V1 {, W//  ProgramCompare.java         Provided by: DRS
% X6 u' L$ @9 f3 X5 O0 N6 j9 _//" x$ W: j9 _: r0 a5 s- Y
//  Program shell for Assignment 2
) |  k" t2 O5 q, T/ f0 e3 G//
, Z8 O/ C5 ~8 P2 `//  Compares two text files line by line5 O9 x2 j. ~) T# M) v# o2 R) K  L
//*********************************************************************% U. K- d- }; K8 h

6 H- n' n+ H, b+ Gimport java.io.*;' R+ ~* T4 i5 t' Z
& R5 i% _2 Z: y& Y% p* K0 \
public class ProgramCompare
" N9 p" W6 X! G{& L3 p2 M: g9 r! j& [
        //-----------------------------------------------------------------* S4 Y: {( P2 c* ~* W
        // Constructor
  H2 Z' x* g; K. y1 |% a* f        //-----------------------------------------------------------------
+ ~4 Y2 ?& T5 t. H        public ProgramCompare()/ R9 Q7 R5 k/ h3 A
        {
0 l' P9 |# w3 L: m- I; _        }
6 a: e# B$ n- `( r5 l. K4 S' k) M; [4 C; Q$ b) q  c' a3 }8 w
        //-----------------------------------------------------------------
: \2 \9 J! r) K* A        // Method for testing that class has been reached$ E$ J4 N2 w/ G$ v
        //-----------------------------------------------------------------       
# X: N6 X0 T& |# F8 w+ C& r; O+ Y% g; M, \
        public boolean ProgramCompareReached()        
# l0 c, a  ~7 |9 R& Y        {
4 ^6 x5 p5 Y- `& @* f2 m      try 7 H% k2 d0 g. R
   {         % C; E3 I9 U; L
                       
7 `$ [6 r3 m& p; K& a                //********************************************************************! }: v+ t" R( N" `+ ^, k8 D
                // Try-Catch Statement is used to handle exceptions - such as file not found / L* R! J* H# P8 w# }  M
                // Reading the files will need to be placed inside a Try-Catch - just like this one!! W1 Z; {1 I* f: S) j' t
                // For more information see page 534 of the textbook$ Y9 J# @3 ?3 M# K# J- s6 A
                //********************************************************************
! y4 H0 U, ?- x) e: b                     2 q8 C2 f# j7 @; [* m, p7 k  u% z; V
        }# n8 |& R# R+ L5 E9 T$ M7 @! e
             catch (Exception ex) // Exception caught here and message displayed to the screen 5 i' g9 F: X+ |) r  N- @
          {; o5 k( O  |: J3 [  E! X) w
                    ex.printStackTrace (System.err);: i" v  C! K0 X: m8 O
           System.out.println ("Error message goes here"); // Replace this error message with your own          - T$ \! N. T; f
        }
. i  O6 H3 s& j* J  o5 k                return true;, V3 {; w) x0 `! I! u
        }
  R5 T" U- A, v8 s8 W/ n+ U% e, u' H; X( [2 g4 o1 g
} // end of class ProgramCompare
2 L2 l- b( ?% }" I
: e2 |! \; N8 L0 M2 {5 f//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
. ^+ j3 o& Z4 b//  ProgramCompareMenu.java    Provided by: DRS
; C3 [6 h2 T0 `) Y4 X+ W//8 |6 G! Y: d/ e+ @4 `
//  Calls AuthorisedUsers.java and ProgramCompare.java: i7 z' V6 o; m3 y
//
9 }% e( g! T. o8 L9 h) ]6 v5 E2 c//  Driver shell for Assignment 2.
% ]! A5 o5 s1 b//********************************************************************
; c# |# y% U/ l8 H  k  Z3 c4 C+ {6 C7 P+ T. e
class ProgramCompareMenu
3 ]2 ^1 U8 A; t* R  K) ^+ X& d2 U{
: N8 W9 Y# a6 c, r. L0 ^$ q    public static void main (String[] args)
3 u* z6 E, ^* @; |! W            {8 r$ @# u8 K6 F7 L$ F
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable5 e7 h# [2 L8 P, F" ?
                ProgramCompare reached1 = new ProgramCompare(); , i) Y  _, Y/ K) v( g9 O
                AuthorisedUsers reached2 = new AuthorisedUsers();       
8 _5 U0 j# a1 P                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());! L1 Q5 T0 r, y
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
& i; K! |! t2 L2 {' F2 g9 G        }4 O+ Y# ^6 b" b0 L6 G
}// end of class ProgramCompareMenu
+ y2 T$ Y5 b/ z  `, b' A! s7 R9 d2 K, H$ [- |; G5 \% b: N) L9 G
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************+ v5 d6 W# c( E" @( B
//          AuthorisedUsers.java          Provided by: DRS4 E8 p: }1 [6 i/ R; a3 s- t
//                & b  F+ w2 H% D5 r0 j0 t9 @0 t5 V0 C, w
//         Program shell for Assignment 2
7 }$ r0 A( N- L$ D; b8 ^//
: }" }7 j5 I- O) E4 Z//         Represents facts about an AuthorisedUser
; [& g# Q' k  S2 H. c7 s4 ]//********************************************************************; V' c' L" t+ _9 M" O* {, @

7 V* e/ |3 s  o: y4 `* r- |public class AuthorisedUsers
$ X' Y& e; r' O- Y* v2 [; f    {
, ^8 u1 h- P+ \# _2 Z$ w$ P7 X$ Z' i% Y) i" f* n2 j9 y
        //-----------------------------------------------------------------
( h) R5 I1 U; z8 |, u        // Constructor
1 x- X* Q0 J7 a8 W        //-----------------------------------------------------------------
7 v4 j4 k7 h: ^8 c' B! r/ d2 C' u3 I0 u& `% b
        public AuthorisedUsers()
! e. T7 v; k$ c                {0 i. K5 y2 ^+ a" K. D9 ?% Y; B
                }
9 m8 f0 D. |5 F9 J
6 o% O6 N- }$ _! l        //-----------------------------------------------------------------+ V; e7 w! ~; Y. g" r
        // Method for testing that class has been reached
. T7 n+ g9 t/ c! @  s7 G2 ?        //-----------------------------------------------------------------        : X" e# H, [6 i- n! o& H! U1 ]! ^
        public boolean AuthorisedUsersReached()
3 d4 K* }+ U  t" {" E                {
7 h# F9 s$ X+ T8 E$ d7 D                        return true;                       
4 m, `# b3 O' {" G+ O                }
2 Q& m1 G- E% w6 Q3 @( ?/ W               
" q$ z" K! d' V! m( [" }; K# ]7 g2 N    } // end of class AuthorisedUsers& J4 a  {% y7 O2 Y
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming5 u8 K# U# m- P: t$ ], J: Q
Shanghai - 2007
; ^1 y: B2 F4 J; o! [Assignment 2, n3 u) X9 _7 ?7 i2 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)
/ e5 q1 a7 c/ @4 H% |4 O& W1. 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." ~  c! J! _' r) d+ ^+ ^* E
The staff must be able to:" `. v' E5 ^  \1 B8 d8 v
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.2 X2 Z/ A' I6 N& G" i6 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.+ G, q0 g* A  [: B
 The interface should provide a menu so that the staff can:6 ?4 ^) V$ u# y; m
a) Enter the names of the two Java program files to be compared# M! Q  ~1 X0 }. j! @5 H
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
$ m, e" n: S& u8 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).
$ M* [- P  c# l& I$ {4 H, N  Q/ LBSA104 Business Programming – 2007: Assignment 2( g8 p; t* w* N4 N
Page 2 of 52 u6 Z0 E" P7 _! Q
b) Print out to the screen all the lines of code that are the same
. ~" A) C; T3 T( G Include the name of the file and the line number of the code being printed for each of the two files
9 Z( v5 k# ^& r* `! T1 c& a! nc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared" Y3 ?# g" U3 l, ]4 x' }6 P5 h* C
 the name, username and department of the user
! G& R8 v( |; z" I) @ the statistics of the comparison
  u5 d, D) o0 I# \+ L$ |$ I- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
" a* \/ |/ O- J* v& D the recommendation for further checking6 |  Q6 @, v  o6 \& X, w4 e5 t
- 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 closely1 K; x7 x2 [, v- v
 the names of the two files compared
# X5 f: L& W& J+ R5 Qd) Leave the program (exit)
( z  v* U' v1 A# l) f% N: hThe ProgramCompare class: (Total maximum 20 marks available)) l6 h  B) R7 G2 x0 I
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 ~, \" s8 \2 W3 ]. {/ A
a) provide an error message if the files are not found or there is a problem opening them
7 g9 ^5 E4 d+ N8 B  rb) compare each line of code  Y% X, {1 n7 k7 q! J7 B" x! ]9 Z. b
c) print out the lines that are the same3 w7 C; d1 d) r5 R1 c0 W
d) count the number of lines compared / lines the same
! v# s9 e7 {$ `. L% n$ z# {: @. [The AuthorisedUsers class: (Total maximum 20 marks available)# Q3 w; B; X/ P! ^
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)7 r- h2 e$ J' Y  b% v
4. Provide methods to:
) i2 I/ h: k: y3 K4 Xa) 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
9 S. Z. g- J+ c6 w. y% Ab) return the name of the authorised user# {. E$ k9 o# Y5 u, h# [
c) return the name of the department of the authorised user7 v. J4 {8 w! D+ l# A8 U
Individual Data (Maximum 20 marks available)
$ r0 l1 s0 r: D" Z- I5. 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.
& {+ a) E: Z) K0 \& K! Z2 YDocumentation (Maximum 10 marks available)1 K* [( x9 \' U2 N  t, v) i
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.) t6 }. R/ Z1 M2 u
BSA104 Business Programming – 2007: Assignment 29 Z* Y1 o/ w" i3 y( ~
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
3 B- g8 m4 R, z/ D9 Q不过你要翻JAVA的类库说明。你有下载没有?% X' e- Q3 Q6 }) W# v: P3 U- _6 n
查询关于对比的函数。貌似关键字是contrast,还有compare9 q0 U- Y0 I9 \$ |, o! w0 x: Z7 ]/ k
- g7 @6 w  t- m: d
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -  o$ i6 J* a7 K' G9 C
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
* o6 Z8 h4 z% ~& k5 z可以下载到的 是 jdk-1_X_0-doc7 ^' R6 }5 }- Z4 ?' }/ l* \
/ B8 K9 |" X. w" X1 R' x3 K
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-17 12:16

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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