找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1231|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急8 R! H" {, x- o4 s+ h& x; j % f; e6 K0 \0 l3 M) T# h6 E
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************3 [  ?" {. v; _, e- Q5 H, I" f9 e
//  ProgramCompare.java         Provided by: DRS
. A3 A3 W1 J6 b; Z4 L//" [; n4 v/ T' k6 s4 A+ [
//  Program shell for Assignment 2
$ S1 A. w7 r8 ^& L//2 H( A  y* @% ^: j8 d
//  Compares two text files line by line
% G6 s5 i& }: T0 E8 `; e//*********************************************************************
% _  ?. X9 U9 l6 g5 O8 v" K1 R" ?
1 _- t- u; Y+ \/ s- ?8 P/ x# limport java.io.*;
# h5 i4 w: K% ?! O9 \# W# ?$ Z4 H& f2 {" a5 M7 a
public class ProgramCompare9 H% @* a6 r6 Y$ R; S
{
& T/ k; N8 }( v+ c! U( a5 K, _" X+ N        //-----------------------------------------------------------------: _3 v; Y1 j) ~/ S% w# Y
        // Constructor! |. {, S! z1 \% k  V# c! y
        //-----------------------------------------------------------------
' A# x0 o8 s) B        public ProgramCompare()1 l0 A9 R6 L; Z- s) j# _1 \/ C
        {
  N7 i& g1 V; X7 u9 \, B: T! P        }. d: q$ U8 Z* G+ }' x

: [7 Z$ v% L* c8 s2 _7 B0 r        //-----------------------------------------------------------------
/ q+ S. ], a# y8 m, z( @: L; X        // Method for testing that class has been reached
" J! H! |& P# u( d        //-----------------------------------------------------------------        - A+ v7 K- ]0 E* G- l

* N* P. `  B8 |) K( m        public boolean ProgramCompareReached()        
# V5 W! E$ P" f8 ?* d0 E$ n        {
- Y( m& ^. x* O4 W      try ) Y! {1 m, n/ M
   {        
# ?  ~. }% y' p" {9 ~# i% z                        ( L4 U2 x  _7 a9 G0 k- N; R2 E. g# Q
                //********************************************************************
5 e* @! x3 B( `! C* G3 M                // Try-Catch Statement is used to handle exceptions - such as file not found
2 l: \. |0 Y1 n, m1 ?/ w/ K                // Reading the files will need to be placed inside a Try-Catch - just like this one!
$ ]; J6 `' M( y' Z; N* e                // For more information see page 534 of the textbook7 o/ c6 h8 ?1 c7 j. l
                //********************************************************************
( ]0 x7 Q2 |" ]" D) [" E  L' u                     4 E8 A/ y. n9 \
        }; e" v' I7 f7 x% D: k
             catch (Exception ex) // Exception caught here and message displayed to the screen
: ]7 |/ K- F" d# w/ _          {
( d8 D+ ~* G- w# P                    ex.printStackTrace (System.err);7 o& M8 o4 F: h* l/ r% P
           System.out.println ("Error message goes here"); // Replace this error message with your own         
7 A% ~3 u6 p/ k' @, F, p) L" a        }: l; G. h+ @# m# N& I$ N3 E
                return true;1 O' H+ f! h0 u) I1 k9 `
        }% k/ v) {. E" E8 G( c

. l$ j0 i$ P5 ~; L} // end of class ProgramCompare& l+ I5 _5 x% N' u, [' f" |

5 B5 z3 t0 x" X# v+ l, ~) J//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************3 u" L# {% i+ T3 \  l; o$ \
//  ProgramCompareMenu.java    Provided by: DRS
, G3 H. |7 m1 G$ r  `, F8 ?//
( \) {: H$ W$ o* o+ P$ I& J//  Calls AuthorisedUsers.java and ProgramCompare.java
" `- D; X  F+ w( q//
7 r7 u6 a' k& B9 S/ `//  Driver shell for Assignment 2.( d; i; [9 Q& C) ^1 v. z+ l
//********************************************************************
3 A$ G$ B' O: m! {! y8 I9 m; _8 j" G% S( _- Q  N
class ProgramCompareMenu
; P$ [. |8 Q) m; S6 Z2 q, n{' Q) @. m1 s( k: x6 V& p
    public static void main (String[] args)
0 Y: O  Q) E3 U3 t+ \, k% b6 v: _            {
7 x! \/ [8 `; k/ Q) O                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable0 {! S' Q! o: B8 A6 E
                ProgramCompare reached1 = new ProgramCompare();
5 {6 X) ~; L. Y7 d% |) M* g                AuthorisedUsers reached2 = new AuthorisedUsers();        # }, x9 H+ f9 t, p" T9 Z0 J& i
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
. R8 P, J4 Y: J2 M9 ]                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        , _+ R8 O  G! A  s5 N$ L4 t# e
        }
/ K+ F0 V6 m3 b}// end of class ProgramCompareMenu7 s+ y7 k) q/ S: k% w7 L" |- M

; {, W$ d& H! {9 P7 h1 X) W1 z//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
" w, l5 f( \4 b3 X! ?# S0 n: S, g//          AuthorisedUsers.java          Provided by: DRS1 g. }% D4 X1 j
//                + [4 H5 D: N* J  R& Q2 _. J: e
//         Program shell for Assignment 23 G# ~7 L+ m$ ^3 v
//4 I2 o* |, r: d! n3 l
//         Represents facts about an AuthorisedUser
8 n. p" B9 J- z' e//********************************************************************- \$ J8 h3 k& C& m
6 x7 C5 z+ ~* p: G, U1 u
public class AuthorisedUsers
* N; ?' m1 w% }3 d3 K    {
0 y7 P, b9 K$ v5 V
' y' P" h7 R# G, q        //-----------------------------------------------------------------
5 U8 c* T" K( h" G8 y        // Constructor
' P( f' T& q7 E% V5 L7 j        //-----------------------------------------------------------------
' q9 X' Y6 Y; c3 c
$ c3 w4 {0 G0 y/ h2 ]" s: K        public AuthorisedUsers()
  Q$ n) D. z/ y                {
& i( @, D! z) O                }! A3 p/ \; K% A2 ^+ m

6 h/ v' C! C. ?9 C4 z* J2 |8 M2 L        //-----------------------------------------------------------------
. R4 X4 P3 `6 Z3 P9 S        // Method for testing that class has been reached
: Z# `9 n; L: j0 e! m! @        //-----------------------------------------------------------------       
7 x; H8 m' O  v7 ?' h        public boolean AuthorisedUsersReached()
0 A6 U2 q# d1 {" W& a8 ~# `                {' Q6 M- F+ H9 r5 Q* e) ?/ H
                        return true;                        - V; K- E# }) j& e, p
                }
$ j: O7 \9 e1 x& l8 W               
+ |4 Y$ E& d. X5 V  v" N: @9 i    } // end of class AuthorisedUsers
  Q  V$ e$ a9 a9 z& {. A//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming2 B8 _4 T) j( R  x: c
Shanghai - 2007
. ^4 |+ u" W. T: \, d) W2 k: L5 oAssignment 2* i. l. [+ D* [, Q+ \" l
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)
. e* U2 F# N1 q0 V3 _2 \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.
$ S1 A. {* C) j- w6 r- B1 vThe staff must be able to:
5 L; P* m5 y( k2 g Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
, j" [, y$ v: D; y% }4 T4 e/ ~! r: ~9 D1. 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.
/ n- D1 X* d5 Q2 `0 ^ The interface should provide a menu so that the staff can:$ l+ F4 ^. l% `% d- W
a) Enter the names of the two Java program files to be compared4 B! \# c, {& [: |3 @1 s; J
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
6 ~" `0 S5 {- _4 r" `. S, N** 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).
; [; C8 o  k) F- `BSA104 Business Programming – 2007: Assignment 2, Y5 q" ?3 P9 \0 D  Q- T/ f1 }' |8 O
Page 2 of 5$ ^% Z( N5 g7 w$ Y+ j( z
b) Print out to the screen all the lines of code that are the same
- [* F8 y- N9 I* X' t$ T1 T Include the name of the file and the line number of the code being printed for each of the two files2 V* o) R6 I* |
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared" F% v9 {- M# U
 the name, username and department of the user2 e+ q% ~3 q/ b" E. @
 the statistics of the comparison
- A- n' H1 E+ I4 z! J* U  ^, d% K- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different: V% a1 u; A' i4 u
 the recommendation for further checking
7 U/ g0 V8 ?6 P5 |6 j- 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
- s# t. N! B. @* V0 V" A the names of the two files compared1 [1 Q( N& p# b8 J3 y, _
d) Leave the program (exit)
" u- D1 ?% Y7 v0 O1 {$ |The ProgramCompare class: (Total maximum 20 marks available)8 M% k6 ?4 C! c/ ]: S* j
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)- v, r0 p. q# U) K
a) provide an error message if the files are not found or there is a problem opening them
" O; [* a& i! N4 f* B3 ob) compare each line of code
* O1 O$ _2 i4 C( s  L  Z$ O. X! Rc) print out the lines that are the same, W: V# o* ]+ q9 O( X, s- `
d) count the number of lines compared / lines the same5 }! S# O* N8 D5 N) B& G0 y8 Y
The AuthorisedUsers class: (Total maximum 20 marks available)3 B1 l& U( Y- X
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)
+ U% c  t. b5 G1 ]8 U4. Provide methods to:2 \, @+ Z) h# j# X0 [% b+ U0 Y3 T7 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
+ P+ d$ a/ Z9 Y3 C* pb) return the name of the authorised user* P5 _7 ]( J* p8 C0 j! U, J8 [
c) return the name of the department of the authorised user
" e' P6 A5 @$ r1 e! ^1 P1 RIndividual Data (Maximum 20 marks available)
3 [( I" i: _, y* a1 B6 r1 b. X5. 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.
$ O2 V- G& p+ k. YDocumentation (Maximum 10 marks available)
3 p9 \: i8 u. @- x6. 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.# H% @( z) |9 d9 V) M2 M
BSA104 Business Programming – 2007: Assignment 2
. A! y8 c$ c1 _Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了  q# n: L0 |; d7 t; r% b4 {5 x6 V
不过你要翻JAVA的类库说明。你有下载没有?  c' z% o0 H# v  V) n
查询关于对比的函数。貌似关键字是contrast,还有compare
  z0 v( v0 \  T$ i% n* c. x' k0 t# {8 r" @4 V2 n5 f: m
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
( c, |0 o  x) L: o) U* H痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
+ a7 l; q% ]% Y1 `$ [可以下载到的 是 jdk-1_X_0-doc
+ p+ D3 y; Y/ x, q( d2 B9 x+ s9 c8 b4 D' J. \4 D
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-23 23:16

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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