找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1789|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 9 R9 u a- v: e# ?/ p% H, D. J+ u7 v0 C
回复

使用道具 举报

 楼主| 发表于 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 b# x  s0 T1 j# M//  ProgramCompare.java         Provided by: DRS9 S6 G8 r: [  X/ y2 a9 {
//
- y3 e5 b# O+ x3 u- X//  Program shell for Assignment 2* ^" ~$ c: {4 @
//7 F" c5 ?( Q9 `" ~( m
//  Compares two text files line by line  X" [0 P: q# Y* C/ i
//*********************************************************************
! l3 l6 A0 a  T5 n$ x# L: ]1 h- r6 \# N* w; Z( q" `( a* W
import java.io.*;: T6 [4 a7 @0 U" e4 m

9 f, w1 \% b& o2 B9 T2 d* n, [) H6 ^public class ProgramCompare4 K3 F5 V8 P$ E4 p+ C
{) ?$ K9 o8 ]8 R& y4 s
        //-----------------------------------------------------------------) k3 ?& t" s- v' y* I- i4 ~" D  z
        // Constructor
2 p* }. v  ]% H( J        //-----------------------------------------------------------------3 H& _1 ^" O0 d) _6 \
        public ProgramCompare()
# S8 s0 m( x. H3 l$ K* Z        {. _. r7 _. {5 @
        }
# u0 S2 i/ D6 w/ J
! k! {7 E& X( D- B* U" ]! N        //-----------------------------------------------------------------
1 t- r7 f+ S0 ]        // Method for testing that class has been reached! y+ O& {& E2 K# i4 S
        //-----------------------------------------------------------------        + G' c" d! w2 H8 S

2 ?9 C# O' [! O8 o8 a        public boolean ProgramCompareReached()         ) q# m- q& h- [5 [7 G. P# ^
        {! S( E- _9 \3 L# h
      try
. y5 M  w% f( j& p) T" _1 U! K8 c   {         5 x! _, h  z2 r2 b( h& N, G
                        ! G8 v4 _; h% T3 E; k
                //********************************************************************2 Y8 S3 _3 x% M+ Q* g: _* h) o
                // Try-Catch Statement is used to handle exceptions - such as file not found
  K* E9 k( {3 {' W' U1 [4 i                // Reading the files will need to be placed inside a Try-Catch - just like this one!
5 I# _1 K" c; _# @                // For more information see page 534 of the textbook
3 W- i0 S* w9 S( g                //********************************************************************: V0 c7 ]8 ?% }
                     " A% {- I- ]8 P
        }7 F8 s. c$ R: u3 T+ L6 L
             catch (Exception ex) // Exception caught here and message displayed to the screen
1 R  v3 |" U9 u  V) D% y" |          {3 m' z8 ~/ _# ]# u- G/ f! \1 q8 B; h
                    ex.printStackTrace (System.err);. C: d5 ?' ?8 e" g: e$ P5 g
           System.out.println ("Error message goes here"); // Replace this error message with your own          * A7 F4 i0 \! N/ G7 G5 K
        }: H! _5 _5 y( h+ p9 n; a. T
                return true;
3 d/ g+ t& v: M& T. ?        }% A2 [) V2 _$ q7 j4 M% S% f! R

# z) D* H8 {& K} // end of class ProgramCompare9 m$ R: V# M1 w1 B6 F5 e

* c" F; @% X: u1 r$ |- r+ L, A//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************; Z" s( K- Y* `$ T6 o: _& n1 L9 v3 ]
//  ProgramCompareMenu.java    Provided by: DRS2 D: g1 I; C- ^/ Y
//6 d4 y& D( A7 L2 w3 g% D9 W
//  Calls AuthorisedUsers.java and ProgramCompare.java$ }( a$ K: q+ R$ Z
//+ p+ o# K6 }4 E
//  Driver shell for Assignment 2.
7 v# a7 [. _, y8 S2 c" J. L//********************************************************************8 a0 {  g0 m: C4 \, m. ]$ v
( O3 d; D( T+ F$ [/ Y/ x& p
class ProgramCompareMenu
' A# Q6 Z7 S* Z& h$ N+ D) {{
2 T7 e% q! z6 a8 A    public static void main (String[] args)
! F# e5 q1 T, ~5 T$ K1 s            {
: S5 e) R* V* v$ a8 G                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable" e1 b' z2 J0 C% v* d
                ProgramCompare reached1 = new ProgramCompare(); ) y6 z2 ]+ O# A' s+ F
                AuthorisedUsers reached2 = new AuthorisedUsers();        2 E4 I; H5 [5 E" A
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());7 X2 L- O3 @& s" T$ K# H; K/ L
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
& J' k6 j( ]! l* C  Y5 g5 V        }
7 M+ v- O$ H0 m3 y5 j}// end of class ProgramCompareMenu
" p, i. \9 s. c, q2 f1 I' W3 E- Q5 H
( A3 ]* b2 _# b4 O//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
1 a* G) l( U6 y& I! Q- l/ y//          AuthorisedUsers.java          Provided by: DRS; A  h# L9 z* \5 C- z" _
//                - `( G. z! ?) M8 ^
//         Program shell for Assignment 2
! h6 G% p0 ^; e" D! ~//
  C9 ~3 H" E" j. c6 ]0 ]2 q//         Represents facts about an AuthorisedUser+ G, i! e: L- h
//********************************************************************
) p0 |* s& ]! c) k2 s1 h! |3 ]9 h9 e
public class AuthorisedUsers
5 z/ S, D$ a' @! P    {" \) P( h) q3 B6 y. p
4 q. H, f! D# Q& z, f- w4 \) K/ ^$ Z* v
        //-----------------------------------------------------------------
& @* {7 n" i# X5 U$ |: q: ^        // Constructor* S! q% V% Z8 J8 ^0 p5 D
        //-----------------------------------------------------------------& f! V' |( I6 b) x0 `
# u8 W# g% F& c! v- t$ C+ z
        public AuthorisedUsers()0 u/ e0 }+ N  C/ Y
                {
% Z5 M# B+ Y3 g$ D% C" ^                }
7 ?! o9 _- `% h& J" h, v( j: k& J4 g9 C5 }7 a
        //-----------------------------------------------------------------9 D! o! r* V) h1 L" |
        // Method for testing that class has been reached- ?2 E' h7 D. x0 s
        //-----------------------------------------------------------------       
& @9 ^& Q1 y' ?, v4 G        public boolean AuthorisedUsersReached()
. a% f. e5 T: L" k! T, ?                {9 J" q5 e, u4 A2 w9 l7 y# n2 G! `2 e1 t
                        return true;                        4 d" c8 n2 e2 g  i5 t* n  i
                }
) [6 t, e4 G4 ~0 ?" \$ d               
* `4 e9 r6 D! J( N4 {7 S" g$ x, |9 I    } // end of class AuthorisedUsers
2 B; e! b4 D- L//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
; n5 n4 e+ v1 r3 m) w& _5 Z' `Shanghai - 2007
0 {/ d9 @  d: bAssignment 2" Y8 t3 q! Z5 R  R$ {
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)) O% n& C& H! Y% R0 d
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.
6 X6 F0 Q6 K1 c, xThe staff must be able to:: [1 l) h2 h. C) h
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
% w$ [9 f$ Q5 o4 a4 _) n1. 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.8 S4 V% e7 V/ J& ?
 The interface should provide a menu so that the staff can:
/ \' K$ \- r4 [5 Ea) Enter the names of the two Java program files to be compared
2 L/ X! p6 N8 J9 U6 {: @% x For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
1 f; A5 x) [- S0 f, w( D** 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).
- m1 @7 C7 {9 [4 S" ZBSA104 Business Programming – 2007: Assignment 2, L% [3 H3 P8 ]- l1 m1 w' i
Page 2 of 5; k4 h0 Q. G# S2 |& y
b) Print out to the screen all the lines of code that are the same. q% P1 C7 Q8 d* W% u% R1 k
 Include the name of the file and the line number of the code being printed for each of the two files' m& T/ `( ~- }) j3 @$ p
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared5 S" L! ?* M. @# ]: l1 ~
 the name, username and department of the user, }* j- ]3 g# R1 R
 the statistics of the comparison! g* {6 K  V: g! j, Q
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
+ |3 e' ?8 j: H1 n the recommendation for further checking
( U  O# [7 W# _+ Z( C; w- 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
, ]3 D$ W" {& F0 @1 b/ ?. C the names of the two files compared
& H! ]9 X* u; U+ ld) Leave the program (exit)# a/ }% h+ I8 t: r# p+ E
The ProgramCompare class: (Total maximum 20 marks available)
. L# _# k9 Q" a9 R2. 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)
; Q: s, |5 Q1 P6 k- Ta) provide an error message if the files are not found or there is a problem opening them5 G+ j( `% b3 s/ q" u: o
b) compare each line of code8 N" [3 z4 K! L% ?+ f9 R
c) print out the lines that are the same
! P2 X0 m! E4 Q6 T9 d6 Bd) count the number of lines compared / lines the same( F$ ~7 x% |5 |
The AuthorisedUsers class: (Total maximum 20 marks available)
& Y' h+ W, r1 j: s0 u4 y, q" h3. 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)) M/ F! r4 \5 j) y: A& _5 t2 {: s
4. Provide methods to:
6 c" c, V  c8 S# B) F  Ra) 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. I* h3 }% E0 K" t
b) return the name of the authorised user
* I* \  C$ G, N9 {' b# d( w4 Yc) return the name of the department of the authorised user
4 s9 U4 W4 c7 E: T4 I" f( {Individual Data (Maximum 20 marks available)
# Z8 q+ _4 A. l4 u5. 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 h( g4 {# A7 r3 G/ dDocumentation (Maximum 10 marks available)
) z! t- C- w6 M  U2 P) k9 V6. 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.
- Z  q6 d( l: |) [0 KBSA104 Business Programming – 2007: Assignment 2
9 g: V2 _! {+ l& H( _- ]Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
3 x: O5 p& _2 q) x, r不过你要翻JAVA的类库说明。你有下载没有?
: F  G9 s) V! z( n查询关于对比的函数。貌似关键字是contrast,还有compare
; c8 u1 f! e9 a  \5 }% a$ f7 C4 \9 G5 w5 v4 N
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -% ]7 X! N) q* C$ }3 n) t6 D
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
& w6 k0 k/ i, O& r$ Q可以下载到的 是 jdk-1_X_0-doc0 M! a/ j' ~/ ], }) L  m5 s
1 f+ W- Q* G: J# t. a
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-31 17:23

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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