找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1732|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急+ A' B' g) u: R( V) G* [4 ]! H : }6 w) }% d9 V- y# L
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************! N9 s9 d) r+ [# G
//  ProgramCompare.java         Provided by: DRS1 P6 }+ o8 d2 k6 d; t; S, j9 V, U
//
, {# q6 d/ N0 i* ?# a8 G# r//  Program shell for Assignment 2
$ _- W& K9 @% e: ^3 g: E//8 o  Y7 {7 `  x) y- ^
//  Compares two text files line by line* [1 G3 o; c' l7 j+ g
//*********************************************************************
9 r" x: r% X8 r, {% U3 ~2 W& t) w% s% B0 I2 _% y5 `" G3 j" s( H
import java.io.*;
) L- |3 o6 v# }+ ^
6 l7 e5 t- ?7 q# ]" |2 d1 Qpublic class ProgramCompare2 ^2 z3 r! m7 G. r/ A' X% Z* U
{8 s4 b) R( v; Y, i2 j
        //-----------------------------------------------------------------! z' y- n7 H. Y4 T% R
        // Constructor7 E8 ~7 t* J& w+ q5 |9 S: f$ ^
        //-----------------------------------------------------------------# j: `* x: y/ L8 {0 U
        public ProgramCompare()
" _- j  Y9 o# \" p( f/ k, b7 f        {: i  _2 {5 g8 U9 n! F6 |
        }
. ]! b9 p  Y- I  [; E, E
/ l' Y1 c$ T9 Y: w, C4 ?9 m( y4 c% I" ^* H3 U        //-----------------------------------------------------------------
( P5 Z, Q; P* J        // Method for testing that class has been reached4 l* V0 m0 O- ~+ o6 P. t8 \
        //-----------------------------------------------------------------        ; f% k9 E: \: b" J0 [2 V
9 @7 R  ]9 r8 T0 l) f
        public boolean ProgramCompareReached()         8 O( U) T# s# H$ J: K# t7 W6 C
        {
8 U: r; f+ H7 E! e6 a, v! B      try
+ C9 u$ k: w) W# p) S4 I# b   {         ! O2 m9 O* L# Z4 l
                       
& @4 h6 y8 Z: |0 E" [                //********************************************************************
& E. ~5 [7 q5 x1 i, Z                // Try-Catch Statement is used to handle exceptions - such as file not found
$ @+ e- N" u' V6 v% H. u; y" x- R* h                // Reading the files will need to be placed inside a Try-Catch - just like this one!. Y+ u; H, O% t6 r8 M
                // For more information see page 534 of the textbook7 |- h$ r2 }% ^/ w4 N, z9 v* a
                //********************************************************************
( `2 u# ?& k4 Z: K% a: s) q8 z4 N                    
+ Y! }. r7 p" B! a  ?/ h        }$ [0 T* ^1 ^$ h5 Q
             catch (Exception ex) // Exception caught here and message displayed to the screen 0 n0 t( u- s4 j, m& Z
          {
, \7 C) c! {* V, v- a                    ex.printStackTrace (System.err);
# ]1 ]: L1 Y! b# C8 T% b; L1 W           System.out.println ("Error message goes here"); // Replace this error message with your own         
; o( h! x: U" P& N        }  o$ E6 G  R  J) m9 J
                return true;
$ u1 j; s; x+ r( O  s: r7 w; B        }6 ^7 a. d5 O+ s  Z
- Z* E# I$ }# G: s+ {
} // end of class ProgramCompare
& l' Z" v/ N8 M7 [
; p/ |( G* E. f1 Q- Q/ e; ]//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
: w/ f8 z4 s, d* y/ H//  ProgramCompareMenu.java    Provided by: DRS
, z' O5 b0 K# j& o9 y* P. o0 r//! @- c" V. m2 s4 u
//  Calls AuthorisedUsers.java and ProgramCompare.java
! ^2 J* d/ F: s//
& `* [& z1 w7 J+ D/ O- U5 W$ t//  Driver shell for Assignment 2.( M+ V6 y2 ?% g- E
//********************************************************************  E: l# a: _% h7 ?" S1 U
- R# m8 G0 v* n' \8 g
class ProgramCompareMenu
: O/ u/ v0 x* {% x9 _{, q4 v/ N( J" j7 q
    public static void main (String[] args)9 l7 R2 o$ ^; P& o: A, w
            {
. n5 p. z! f* J3 |. ?7 `                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
! Q# r9 C8 P, D) s% F- H2 Q0 g                ProgramCompare reached1 = new ProgramCompare(); 5 X& [5 f/ [9 E/ F
                AuthorisedUsers reached2 = new AuthorisedUsers();        . @2 C: S/ @" v7 n* @( X
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
" Y) I6 T& Y4 T, S                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
) z5 V0 J2 a2 _; g: d        }  o/ v8 r- z3 X& Q% h+ r, C* m
}// end of class ProgramCompareMenu
3 y9 `; {# k5 }' `5 E; V% U# ?/ o0 B% A  f/ I
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
. Z+ X6 p( ?2 ^0 g" i# [//          AuthorisedUsers.java          Provided by: DRS
/ A+ i& x# [+ ?; X" o% y6 x//                / E' K6 M4 `+ |( D, v
//         Program shell for Assignment 22 B6 O# J; O# j2 W8 x7 [
//
" }( o0 h( X  v4 k+ Y  e//         Represents facts about an AuthorisedUser
/ ~7 Q' D. g! g+ R//********************************************************************
$ k* h) s& ]# E( U0 v; Y) n. _( {
* [; J% s9 i3 A7 {public class AuthorisedUsers
, {3 _' H' A, G    {
  G) U6 u* ?( t1 G2 Q- k
+ @# M8 B5 ~1 U# b+ m& [$ o        //-----------------------------------------------------------------  b; r' w% b. q+ T, O% w3 d/ g
        // Constructor) a' |, Y6 \$ ?/ R" C/ y
        //-----------------------------------------------------------------
! U& G; [. {2 C) v
8 n6 S9 z  j1 j7 o% B        public AuthorisedUsers()) V3 c+ Y; t6 e2 X; Z* P4 O6 a  V
                {' D/ F* N" E# r+ K) Q0 W8 ~$ n! z
                }
0 N0 l; q: ^& P3 o
. o) {: b; X" `, [' P; U) X9 b7 |4 r        //-----------------------------------------------------------------2 }. o5 h- B- O* E" b1 T3 e
        // Method for testing that class has been reached5 S; I. n& t# }9 m% e
        //-----------------------------------------------------------------       
# v, e7 t1 T& D$ H: s& u0 i" f        public boolean AuthorisedUsersReached()4 M- B% v5 `3 w. b1 h  k* l
                {
* p1 o; V( e# _* i' d                        return true;                        6 o4 w: g6 b) I- Z/ z
                }
% S8 M5 P6 \) Z+ ?; z                0 I6 Y/ h; Q" I0 j, a
    } // end of class AuthorisedUsers3 }9 M+ v1 V  z1 P6 \2 z% Z
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming8 Q9 _) ^/ J' L- @; b
Shanghai - 20076 t7 z- i: w( \8 c' c" E
Assignment 24 f5 h- e% ?3 o& P0 c/ F
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)
3 ~* o6 A" l! y! f* F1. 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.
" K3 x; o5 _8 M# sThe staff must be able to:
% Z7 r8 k/ g% B Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.% L. R$ P) |! J" @3 ?
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.
" ^1 Y: d8 k! `8 s The interface should provide a menu so that the staff can:1 K$ E% v4 y8 ~9 Z
a) Enter the names of the two Java program files to be compared; V) x3 ]9 n) K( M: \
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.7 ~% ~  ?% V5 O, u" a4 g* R4 j" j
** 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).
! \! v0 z. l) b/ o: i4 ], BBSA104 Business Programming – 2007: Assignment 2  Y9 E- [) H: a1 j  s
Page 2 of 5
1 f8 ~9 x$ }: x% w0 I  H: v6 lb) Print out to the screen all the lines of code that are the same4 ]4 z: A8 [7 ^2 U
 Include the name of the file and the line number of the code being printed for each of the two files# N! O3 Z8 \7 V$ h
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
; B# W% m% [( U2 n9 u  k  n/ j' G the name, username and department of the user
! b# U. O$ ]# e4 W6 t7 _ the statistics of the comparison
+ T7 F5 d# G2 y* Q- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
5 w6 l* G) a0 e: g) p  b: { the recommendation for further checking
  V' G6 `! q& V& ?# D2 }- 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
" a2 f9 X" f4 @9 `# B the names of the two files compared
2 O5 W, e) t4 t! P  nd) Leave the program (exit)
7 A) T" J' `) c5 DThe ProgramCompare class: (Total maximum 20 marks available)
- P# ~' D& ], ^7 c/ a7 a1 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)
! p/ c- o' l+ u! S: g. x3 fa) provide an error message if the files are not found or there is a problem opening them. _3 C  f( n9 s7 }1 l
b) compare each line of code
4 ~2 G% s. D0 K+ F/ b' d1 ?$ wc) print out the lines that are the same
7 _" K, Y6 M6 |; R! e# h. A( Kd) count the number of lines compared / lines the same
" `+ ?% K* j$ k6 P, `0 C/ aThe AuthorisedUsers class: (Total maximum 20 marks available)
3 r0 X: S3 Q! ]' {# p; t3. 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)) y! g$ ?6 u% h4 D" g1 [1 P+ t: e
4. Provide methods to:! F# h( U( d2 I: J
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% Y% c' u4 s( J3 p8 Q; O( Z
b) return the name of the authorised user! s. ~$ r+ ?  R
c) return the name of the department of the authorised user
5 R+ Q4 n& N$ ^& a9 W! OIndividual Data (Maximum 20 marks available)( L0 Q) B- x" d% ^" Z; ?
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.. Q! e3 Q' ~' j
Documentation (Maximum 10 marks available)
# N1 @+ S0 H( I8 _! n: U6. 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.! F( b. Z+ E6 o" d
BSA104 Business Programming – 2007: Assignment 21 T& B" u% G/ j" S5 L8 E6 O3 U' d
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
* g% _6 Z! W( h5 F不过你要翻JAVA的类库说明。你有下载没有?  X1 S& P8 |4 _5 S+ C4 N
查询关于对比的函数。貌似关键字是contrast,还有compare; F; r# m, R# m
7 B$ ~/ @. E$ |
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
8 ?$ R1 r  [1 @/ l6 \痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。9 l% ?% v9 O, x$ G
可以下载到的 是 jdk-1_X_0-doc
; A* C4 ?3 r$ b5 b- ^$ C  l" s* d
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-18 08:33

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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