找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1526|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急" D9 x. L; u% r; T9 z7 g 4 G/ U# y% e# G( N: X* N) f0 I
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//********************************************************************** m' E7 E5 N" f: o& C1 Z
//  ProgramCompare.java         Provided by: DRS
4 S; F. ~, @5 Z9 w. \- u9 e: t//
, ?5 n; U: N& _//  Program shell for Assignment 2& G) F; |! s+ i. u: U# u" b3 Z& D8 Q: }
//
4 |" Y* T. j; Q, Q( P& p6 X7 r//  Compares two text files line by line
- w7 p, a4 \2 u; r7 K2 Y//*********************************************************************- [$ u$ x# L" x9 I
5 N9 B7 i3 |: @( D6 t6 G. u0 F
import java.io.*;
+ w4 q, _: [9 O$ I" l2 a
4 f3 p; c: Y3 L1 T  ~: qpublic class ProgramCompare% ^6 V5 S; y1 u! Z5 K
{
: ~/ r2 j! o3 x  Y. F- [        //-----------------------------------------------------------------) C9 k4 C4 W* d
        // Constructor$ w0 W+ Y# c  M. S. N: B5 f
        //-----------------------------------------------------------------, o( C7 l6 L! U  F8 F
        public ProgramCompare()8 J3 X$ v2 w  O  x  N
        {
3 s4 _% N2 j6 X9 m% l        }9 {8 r) e0 |& F* M- X0 ]* I
/ M' k3 I6 T+ V# z0 V* g
        //-----------------------------------------------------------------
+ w7 k6 M3 B. O% H        // Method for testing that class has been reached6 x5 N* r) Q8 _% }3 I% X; S7 p
        //-----------------------------------------------------------------       
- Q$ D7 E. E. e8 O3 S0 A9 e! j% S5 n/ c6 B/ G9 \  o* S
        public boolean ProgramCompareReached()        
# f( ]8 ?6 E' g' H" Z( k! Z        {7 O, H( E- V5 V$ S! V  h8 e, O
      try
) u1 H. }& v+ I1 Q( E  N% P   {        
- I2 e8 |3 k( l3 P& b4 |9 g                        ( P( |& F% ]4 |# h
                //********************************************************************
3 n# I  a/ D6 B+ n6 D' Y* F4 r- Z                // Try-Catch Statement is used to handle exceptions - such as file not found & T: c# v8 X% o2 h( l
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
% k: O7 z/ ^. x" D                // For more information see page 534 of the textbook3 h. n7 O  D/ ?/ d
                //********************************************************************
! g4 b; g# i% G+ Y% t                     : ~$ b" a* H4 s
        }
; A. z' z# F9 ?8 r* z  R" d* h             catch (Exception ex) // Exception caught here and message displayed to the screen
0 D  a$ I" ?+ i6 M8 R  s          {
! H1 a1 |1 p3 I0 R' A                    ex.printStackTrace (System.err);; p; e# a; B; R& T$ V6 P
           System.out.println ("Error message goes here"); // Replace this error message with your own         
; S, S# t" i3 o' L8 @        }% Q6 w. x4 J3 f. b
                return true;% j6 V9 _% g9 u4 @1 \
        }& d5 Q- f1 P6 Z) s- Y& |& J& j

# j; b0 S2 O5 F) \1 T} // end of class ProgramCompare
& G5 R# j% ]8 }& O/ {3 b9 ~' S4 a- }5 r( C( C; e
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
7 x1 H4 Y9 s% y1 r) H//  ProgramCompareMenu.java    Provided by: DRS( w- m5 M2 u1 r
//% j: `, {+ L1 T# P' {
//  Calls AuthorisedUsers.java and ProgramCompare.java
. H# ?  f7 d6 [- t# H* l//( |# o0 [! Y8 h1 W# @
//  Driver shell for Assignment 2.
2 l# a# E- C  k  P2 K( l+ V0 Z' y//********************************************************************
! E$ v5 W# D8 r  ~8 h) _
! m+ i( M: g' ^* s- c! rclass ProgramCompareMenu
8 c9 E- w9 k' [7 [{8 h0 \$ }! S# U/ k3 L) u! M/ Z$ i4 P
    public static void main (String[] args)% U( e6 i9 |* b  q3 T% v( ]  X
            {
8 p1 U! k, \) c! d' b1 r                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable2 H" V1 `6 j% P6 p" t! l2 w; P
                ProgramCompare reached1 = new ProgramCompare(); % P: P1 _: E+ G) [9 d
                AuthorisedUsers reached2 = new AuthorisedUsers();       
/ L& n4 r8 e6 i0 ]+ l4 t' V                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());' D% c1 ]" f7 }& _4 k
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        0 Z: J& X# K! v, j: v! `1 V
        }0 r; I/ q* a$ s7 p7 n, r: h
}// end of class ProgramCompareMenu3 `' [( t" g) K8 w- x7 w: {/ V) Y

: }. b0 I0 v' ~4 L//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
' |5 |. K3 e  T" @; `2 y: {//          AuthorisedUsers.java          Provided by: DRS5 ?  x- B$ v2 N3 M
//                3 a: |2 r8 E  r' Z* V: P( S/ G
//         Program shell for Assignment 2* v" j3 D9 ~& @- `+ K3 B
//
( S5 T) ~' V- L/ h' q" G8 l//         Represents facts about an AuthorisedUser& k+ d, y* H6 \8 a$ a. p7 ?
//********************************************************************' ?+ g5 i7 x# A4 Z$ G4 x; F" J
: r1 h! [; G2 Q4 k
public class AuthorisedUsers
& o" z% r9 U: `5 r& `/ s    {
3 {9 e( ~6 G& |
% J( o. G$ e' C        //-----------------------------------------------------------------+ [% z3 V( B- Y1 [# q# I$ P
        // Constructor  c0 ~7 ^" t3 ~" @* s5 M
        //-----------------------------------------------------------------
* W/ t; W  S/ p6 G9 n# d3 C6 K- A* G: {* w0 \& d
        public AuthorisedUsers()5 Q, l. T' \1 S  t7 j9 P9 ?
                {
- ^0 _' V7 g* i# }/ X1 l                }' \; {3 b4 W+ d) O- F8 V' n
- G; o: S/ Q1 {
        //-----------------------------------------------------------------
4 O; V2 m/ a: w$ E  v) @/ r        // Method for testing that class has been reached9 {% l: \/ i% `% D* b( }( i+ N/ g
        //-----------------------------------------------------------------       
5 ]2 @7 s' |% x# N, Y        public boolean AuthorisedUsersReached()+ M4 w3 @7 N& Q) B1 z6 A' {1 G& V
                {
! ^/ k8 |) |. J2 B                        return true;                        ' T. f& o2 s. f" o9 N
                }
3 x- ]7 d  h/ k4 g5 v0 T. h               
  R" \: [% t, j7 M6 O. i$ f5 p    } // end of class AuthorisedUsers
$ M6 i' i1 q0 J3 z9 |//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
3 h( A' d" [/ P! E6 v: T2 u- |# LShanghai - 2007
# A- C6 G+ |  z. LAssignment 29 C) r! h; \' P% X, ?3 b
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)5 e* S: f% S3 \* e' m
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.
% B7 w5 A; [1 eThe staff must be able to:/ e) |: b" ^4 i5 K8 @+ s! G' g5 O
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.  Q4 J0 w9 R. A8 `$ N0 d
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 m8 p. R2 S9 W- L
 The interface should provide a menu so that the staff can:! }9 S2 R. o: d9 u4 e
a) Enter the names of the two Java program files to be compared
+ m9 |3 j% o0 X4 K$ s: z8 U For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
) I: u; ], \4 ^4 B/ B0 b** 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).& O# m2 r6 i8 A, x- b* B2 w
BSA104 Business Programming – 2007: Assignment 2
# n) _3 X* v: L. b. _( I$ _Page 2 of 5
8 E0 r) v- G8 U+ A2 o( B" p- N  J5 {b) Print out to the screen all the lines of code that are the same  x5 @  O& a0 w  a/ @
 Include the name of the file and the line number of the code being printed for each of the two files9 l# B& O3 f* k# z6 H; Y9 Z
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared) C# s. Y. J7 l& d0 K: n" T
 the name, username and department of the user$ Q; k3 z6 |- l0 F( H
 the statistics of the comparison8 M* y% Z# X6 u" y* S; X
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different0 G! _- t( O4 @5 I2 c+ \
 the recommendation for further checking! T& n( a' c% g( R" B: I6 ^) Z
- 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
( w# M$ p: w6 m the names of the two files compared6 @( A* s* u0 [
d) Leave the program (exit)
& s' E7 j$ o/ D. G2 aThe ProgramCompare class: (Total maximum 20 marks available)
" }4 O" b0 H, C2. 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)
; |$ D- Q  X5 b! w% w9 Ka) provide an error message if the files are not found or there is a problem opening them
% a; L, a9 W3 ]4 }. l( O- Rb) compare each line of code3 ^. T9 Z' g* {' y9 y& N8 C
c) print out the lines that are the same: Q' z: K8 F/ o  j/ x
d) count the number of lines compared / lines the same. M% G& z5 s* b
The AuthorisedUsers class: (Total maximum 20 marks available)
3 V2 j/ R, G" G6 }" P( f' F! T+ a$ o3. 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)
9 J1 d( E7 m* }3 I% t$ z2 n7 N0 w" N4. Provide methods to:0 t- }' K- i& G7 I! D
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
3 \% Q- B+ Y, M) k4 N. ^! t$ Jb) return the name of the authorised user
4 b5 h- X9 a. w" l; E: X8 @c) return the name of the department of the authorised user5 S7 v0 ~7 w0 ~  b
Individual Data (Maximum 20 marks available)$ v* c* q7 a" {( P
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.+ K/ j6 Q; S% d: L
Documentation (Maximum 10 marks available)
! K, F" [* \* ?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./ D1 \# \) d. O3 [, w6 }
BSA104 Business Programming – 2007: Assignment 2! o% A/ Y1 N0 V3 p( L% z
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了: n+ O6 f2 K# H5 r4 J% y/ [
不过你要翻JAVA的类库说明。你有下载没有?& i$ k" P7 z. }6 ^: s# I1 |0 i& C, K
查询关于对比的函数。貌似关键字是contrast,还有compare4 a2 j- q! ^* m1 n% D  n

% J5 G; V: u# v. I7 n! Z- j7 f5 k5 C[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -, F- m( C1 T8 n' _0 i2 E
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。0 q, k0 [, J0 I/ c
可以下载到的 是 jdk-1_X_0-doc
- ^! d1 @, ]6 P7 T, Z/ m) @8 a1 w6 Q- M, b  R5 I$ O4 k6 e4 g
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-8 01:45

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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