找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1588|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急0 a" T7 a6 Q; U* y9 g. I; G1 ^. q9 g 3 i9 r4 R/ ^( E U; O; Y9 f4 h
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
) V' f7 Z( b8 [% Y6 l1 I//  ProgramCompare.java         Provided by: DRS, ]/ ]$ Q6 U- z2 U
//% [$ w$ c( S! y3 t( ~" x
//  Program shell for Assignment 2
% B7 C2 [$ a$ o, ?! Q8 W7 K8 ~//8 E9 y- f1 t  f$ o. L
//  Compares two text files line by line
2 k1 k  B0 }& ~# |+ M: Q//*********************************************************************$ P$ ?* i- ?7 D  ?, l+ }
& E5 V) n. Y+ f0 e) R
import java.io.*;
! d. Y5 X8 d1 Q$ Y
# K6 O; l8 d3 e# J8 wpublic class ProgramCompare
0 @& U3 Q; _% e3 W% d{
9 ^( A3 G6 M; s% V. C, m        //-----------------------------------------------------------------
: f5 e% z- `, f, u        // Constructor- G" t! H- E3 M8 ?
        //-----------------------------------------------------------------& b: a2 j1 \6 H4 h5 H9 E# o1 X
        public ProgramCompare()! [: w/ v& _$ h, r
        {
3 L: e: y1 _8 d& B* c1 S0 E: [        }; K# F' ~/ \) q. y0 M

$ _/ @! x* T; x4 g2 |) _        //-----------------------------------------------------------------" {( N( h% q! B7 U
        // Method for testing that class has been reached3 |. ~( `( {, F$ t, z$ h& n
        //-----------------------------------------------------------------       
( d# L) S. q3 t, S( V' D; t" V- H) P6 z
        public boolean ProgramCompareReached()         $ Q/ p5 H/ t, p5 y7 Q
        {
/ G' s: M, D$ M2 Q5 J5 z- u      try
9 L$ z6 N9 n# Q* B   {        
7 V; T' g! v/ @5 Q0 O  D                        " Z: |/ }/ `$ g+ [5 R, H
                //********************************************************************. `. C  T) n  s6 N/ F  M: \) Z' P
                // Try-Catch Statement is used to handle exceptions - such as file not found
5 b3 |$ C9 X% P4 e                // Reading the files will need to be placed inside a Try-Catch - just like this one!- ?; ^2 d0 k( t" F; O4 Z3 n: i
                // For more information see page 534 of the textbook
4 a2 \! N/ h- m5 T5 d                //********************************************************************
5 b7 T0 n. J$ o1 w0 l& I                     2 h# J0 x' A/ n: X5 e4 o2 \: ^! s& ^
        }
( S; |9 w4 @6 i7 l- g0 |             catch (Exception ex) // Exception caught here and message displayed to the screen 9 ^1 I. J: ]& E" q' f
          {
% c" A. m- O  b8 o- @% D3 z! @                    ex.printStackTrace (System.err);" H3 A/ v3 X! T
           System.out.println ("Error message goes here"); // Replace this error message with your own          & k- m; Z; d& I0 l, i# p% [
        }
3 I$ }9 }. u. Q0 K3 v0 o# S; N& q                return true;* k( ]1 F" Q% `7 q+ k1 [2 {8 x. c" D
        }
% Y; H  H! F- G: n0 x& t2 a  x3 j3 x( C! [, t
} // end of class ProgramCompare
; r" ~/ A# v, @: T" i5 r
( d' w5 n! g  t* r//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************/ b; ~* h6 P. n( x0 x; o
//  ProgramCompareMenu.java    Provided by: DRS
: f1 d  D+ R8 o% f//
3 v. a7 K- }0 s) q5 ^: E//  Calls AuthorisedUsers.java and ProgramCompare.java2 K/ j! A% _) d% Z# Y! \
//
9 }3 @% }+ B) ^9 y' U$ B//  Driver shell for Assignment 2.3 E1 G$ I+ N! d$ ^
//********************************************************************
' p9 o" u) f5 G3 f7 E6 R* G
& Y: S. a6 U: F) ]6 x' cclass ProgramCompareMenu" P# |3 t0 v( E$ }0 E6 |- f0 g5 A
{
2 `" y8 m! [- @; B, e    public static void main (String[] args)# {; X; \: ]" S9 M& m! K+ B$ ~
            {5 g5 ]4 k: F6 c  X3 C5 \
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable! \. `: t) O- m: P5 A
                ProgramCompare reached1 = new ProgramCompare();
- v# V; w' E: F3 ^' \                AuthorisedUsers reached2 = new AuthorisedUsers();       
6 U9 `2 w: u; o1 Q! n                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());: n0 W9 t/ M3 J+ C  U: z) d+ F
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ) e4 `8 v& y3 q; n
        }9 L; L' P6 i) ?0 L5 L% W
}// end of class ProgramCompareMenu
3 K% G( u. O8 l7 P6 g4 X/ Y7 r0 a  x: _
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
8 ~9 b! m  J6 g" ]9 k//          AuthorisedUsers.java          Provided by: DRS: J  ^! p9 k$ y' ~" n# ?  l
//                % D- \* m$ p; w
//         Program shell for Assignment 2  _7 V4 E' I/ H' s& W
//
% `( e5 L' W1 h//         Represents facts about an AuthorisedUser
- r9 L) J( j) ?- i//********************************************************************
8 M9 I4 @% W- i) u& M- E3 g- j) `) u8 }* h" V) r! N; E
public class AuthorisedUsers# S, G, G* J9 [; _1 B1 T/ b
    {4 R0 e, h5 i4 E$ w8 e4 K7 u% W1 X, }

' u) y" _  M9 d$ R1 p) O4 W  V. p; T        //-----------------------------------------------------------------3 O8 R( N, n7 B. [
        // Constructor
1 Q3 S, [" a: B" q( f        //-----------------------------------------------------------------' K0 L8 O" g" m' I3 P+ l( C; @; w1 y3 t

% i! U- b. H# T1 R        public AuthorisedUsers()
6 Q) j# F6 A& Y6 l% S( s" ?                {
- z0 a+ b% t1 z$ ]% w* x' H2 C                }7 z5 ~1 }1 t3 `9 @0 g: ]# C
6 V0 Y" U4 n  z3 r% A3 ?1 e5 b) |* T
        //-----------------------------------------------------------------6 P0 b$ s& I# k: ~/ B: J, I( r- g
        // Method for testing that class has been reached/ e# S, ?2 @+ T2 J" w0 L
        //-----------------------------------------------------------------       
# I4 ]$ J% M# V5 j3 y, X        public boolean AuthorisedUsersReached()
. T  n) ?% J/ S" |: n  d* A$ c                {5 w1 o6 I. _9 X. G1 o1 _% X
                        return true;                        # n8 J1 C/ A2 l4 x  F! U+ ?: t
                }! S* }% J0 \! N. v6 W( P7 m" n
               
) N9 @, v2 o8 P+ F    } // end of class AuthorisedUsers
/ G7 x  [8 B2 `. q- q" T1 i//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
9 A3 d6 m$ M3 j* wShanghai - 20076 a$ e& }8 a+ v
Assignment 2
% x+ l4 N8 U- `0 [1 }% e% DDeadline 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+ C4 A: p6 i. y1. 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.
6 E: Z: d' A3 w' y! W" aThe staff must be able to:
2 Y" k) o# Y. [* g/ ] Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
+ S# @$ N, W3 M, q+ x) F; H1. 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.* c# u+ K( x4 A$ q, m
 The interface should provide a menu so that the staff can:6 d& [6 G/ s/ Z6 O4 O
a) Enter the names of the two Java program files to be compared
: B8 _4 b6 [& Y7 x. `! F0 ^! L For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
# j, ^/ L" h# ~) 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).
, k! Q4 I1 }: J: c# JBSA104 Business Programming – 2007: Assignment 2/ [( O' m' g5 U' J+ i0 o* r/ [& E
Page 2 of 53 O! ~6 l! l2 G, j: F9 ^/ x
b) Print out to the screen all the lines of code that are the same
( J4 E  n# S+ {- u8 U Include the name of the file and the line number of the code being printed for each of the two files
1 W2 f2 g" G) Z4 Uc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared3 Q# ^( i/ S/ m! O# W( c# `6 D2 l
 the name, username and department of the user
" C! z7 X# m$ ]; k6 W9 B2 k" B the statistics of the comparison& O- ]7 V/ g; i
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different+ K, U! m: s: F# d; @
 the recommendation for further checking3 B- A! G6 w6 S5 [
- 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 closely2 m) @. t7 a1 k: Z: p) R) w3 B- N7 x
 the names of the two files compared' L( U5 C, o& Q4 O- [
d) Leave the program (exit)# r) s+ R) T/ _5 E0 O# R
The ProgramCompare class: (Total maximum 20 marks available)# E2 ?  L  T- U4 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)% K" N7 ?( ?$ u
a) provide an error message if the files are not found or there is a problem opening them
, `; S$ ^0 M9 C, }b) compare each line of code
% K6 }8 m+ L9 j3 @c) print out the lines that are the same& i. ?' f( P8 g* e) n) A" ^- [8 F5 y
d) count the number of lines compared / lines the same/ y+ J8 Y% N, n; A2 y- i: u* A% ^! d
The AuthorisedUsers class: (Total maximum 20 marks available)
1 R: B: g0 S& Z# R; m3. 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)
3 j: F3 y: ]# A3 t0 {. d4. Provide methods to:
+ f2 u+ h( L6 o1 j. h& B' p" ta) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match4 B; o0 F' Y# H: {  N$ i
b) return the name of the authorised user! l3 U3 E7 M! V0 m/ Y3 T: k
c) return the name of the department of the authorised user
& \& N6 d( a# p+ |Individual Data (Maximum 20 marks available)* m' D9 ^1 e6 Y8 |  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.. L' e8 ^8 N# l3 G" O
Documentation (Maximum 10 marks available)
4 s. P' A8 ?3 R0 k# K6. 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.
+ x) ^, H% G* b1 NBSA104 Business Programming – 2007: Assignment 2. u4 g1 \/ e5 f" _; X4 p
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
& c6 ?0 s$ ?$ w0 p3 T+ A4 F  ^不过你要翻JAVA的类库说明。你有下载没有?
$ h  ]1 w1 K6 i7 X1 x查询关于对比的函数。貌似关键字是contrast,还有compare
# c9 v0 Y" j6 c9 O" e- B" z& [' B, H' q4 z9 G; e
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -' @# e9 r7 p: o, b! l
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。6 `) F7 E: Y( l7 T1 d
可以下载到的 是 jdk-1_X_0-doc2 T/ T- X; b6 D. o+ P: E1 P

- }0 x: m$ i) Q; }[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-29 08:15

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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