找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1311|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急! [ v a J$ q' R : X( a$ k# x0 `0 t9 S1 D8 \! M
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
% J5 G3 X' q7 T! P9 F! d, B//  ProgramCompare.java         Provided by: DRS
4 A2 Q$ z2 W! b* V& [2 J//
. X9 x% ^. s! w. ~5 A9 G. s  o//  Program shell for Assignment 25 H/ y- \' t3 \* H
//7 u9 p6 F' U6 ?7 X5 C  p- N3 u
//  Compares two text files line by line
( z: e) |; z9 F//*********************************************************************
2 V$ v. P2 v' m: Z! \5 W
2 l) w* R; o) iimport java.io.*;  @4 i8 `9 R* Y$ J

8 z# W" ]+ c8 y7 Z- ^public class ProgramCompare
& l5 \7 d, a) t, X' c. {8 q6 M{: ~" ]) t  O, S; o+ `" R
        //-----------------------------------------------------------------
6 ?) U' H8 M* T5 k8 y: e$ B        // Constructor
0 s9 I6 l* x6 F        //-----------------------------------------------------------------
. c( m  h( `9 q2 j+ g  h        public ProgramCompare(); T, P* J3 F0 B5 ]9 j3 B
        {- E% W% u1 s5 }3 \
        }, L. ^% K- ?$ ]

5 t1 A4 F4 S, L( }4 D3 i        //-----------------------------------------------------------------6 c6 ?0 t) O* c8 [' Z; [3 R
        // Method for testing that class has been reached
# F$ a# s) i$ i+ f; e        //-----------------------------------------------------------------       
& c% o5 o' G+ M6 x/ L0 {9 j1 m5 x- x& D; l, a& {' B1 r# }' b
        public boolean ProgramCompareReached()         7 ]$ ^3 g) w" ~! }: B; b$ {" g
        {8 I3 z0 u6 i% H9 P
      try
2 V: E& z& J  [8 @' K  x   {         / J) o( I8 D& R' z: k4 I
                        ' o) F7 t2 U2 R! \8 b% p
                //********************************************************************% A" H9 e; P1 b# \
                // Try-Catch Statement is used to handle exceptions - such as file not found , e% I6 ~) X# V( F7 a
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
9 U& I( B' l0 `- W) g0 a  w# n                // For more information see page 534 of the textbook7 ~" R8 N5 X/ G& H+ o& }; B
                //********************************************************************/ i9 T+ c. Q+ j2 m8 V
                     ; d$ X6 z; M& D- {' |& e- g
        }
1 }3 l; u4 p7 Q             catch (Exception ex) // Exception caught here and message displayed to the screen 3 L6 t6 v) z3 d4 P
          {
" G1 k' @9 m2 m+ U2 h1 \/ b7 \                    ex.printStackTrace (System.err);) `* T# L8 [' i" l, p  h+ ?
           System.out.println ("Error message goes here"); // Replace this error message with your own         
# `* m1 `+ P0 J        }( y# {$ e$ g4 w; a1 R8 U$ }. T6 }. C0 m
                return true;* e3 V  c9 Q" z8 q3 I
        }3 V. h. A* L% u( h1 T
% E# `' a4 k% K* i; I3 x" g- K
} // end of class ProgramCompare$ j6 d9 O. o( F3 l2 f/ ~
" B+ @- b" C1 V! b# P6 ?% o
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
! s# Z/ C. D" u" T' M//  ProgramCompareMenu.java    Provided by: DRS
5 p$ p) V* U1 D$ F  }" q' ?# M) g& E/// ]: P2 i$ O$ [! s1 f* w5 X
//  Calls AuthorisedUsers.java and ProgramCompare.java
1 |1 x% q9 [! A7 q, J$ M//
) u4 `# Z0 D! ]//  Driver shell for Assignment 2.
2 ~4 X' W, n7 w; P//********************************************************************
) i) R& D6 j/ H6 h1 B+ G+ f' |' v7 ^: g, U
class ProgramCompareMenu6 d7 i1 d7 w/ H: ]" M% w- n9 A
{7 S# n7 |3 H2 O2 ?
    public static void main (String[] args)4 B( T: d( [" T% S$ E
            {
% R% i6 Q- z( {                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
! t( I8 Q. N9 Q0 I: b                ProgramCompare reached1 = new ProgramCompare();
* k- z  y* r: z7 k, n3 r: x                AuthorisedUsers reached2 = new AuthorisedUsers();        + l  b9 y- V* S6 Z) s
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());% H  [6 |# H2 F" Y# j% ?! H
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        # ]) J* [: q6 \  P8 f& n* a
        }
6 q( x- B! k! C9 I1 P" H) Z; H}// end of class ProgramCompareMenu
/ Z" i+ A: z1 k. K6 j* n; x, Y  c+ b, F! \: t
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************. X: ?* Q6 q  t
//          AuthorisedUsers.java          Provided by: DRS
- ^2 W, Z# s3 \8 Y6 A: H2 |8 X+ ]//                ) \! f$ Q$ ^# G( R8 c+ \2 G; L7 }
//         Program shell for Assignment 2  L/ a, c& f$ b1 i; Y7 b
//% j0 t5 w1 R4 r: _- O9 g& F
//         Represents facts about an AuthorisedUser
# u. v6 @( |4 y9 y//********************************************************************$ B+ m# j. @$ n+ t
% L+ g+ x9 a: @
public class AuthorisedUsers
% l0 C- H; N' W9 i# I( I    {
% Q0 f- f4 j$ \  P; U
! ~$ v- ]4 a. S/ b        //-----------------------------------------------------------------5 V$ z- V  U2 N" r7 l1 L7 u
        // Constructor
5 Q8 `( P* \2 ~; E2 M- U7 G" ^        //-----------------------------------------------------------------9 T' D" R0 ?3 R4 J. f" j7 ~$ ~
6 }$ p/ Y( u8 @* S* \
        public AuthorisedUsers()( P) l% Z& s" o
                {( P& p. _- J* }2 q8 `1 {( p- }! P$ D
                }2 ~4 _7 e0 T, d3 ]0 Y' ^/ H: ^4 [

7 H" ?# `: E1 V8 l6 n% b        //-----------------------------------------------------------------
/ X9 ^$ }0 @4 p: c+ Z+ Z9 v        // Method for testing that class has been reached
- w6 ]4 m& A8 J! J7 F        //-----------------------------------------------------------------       
$ T$ x3 ?0 {5 K& r4 O/ P        public boolean AuthorisedUsersReached()
0 y2 M7 O) p7 q$ n: M" x7 m                {
( T$ G- J- @. A& N3 o                        return true;                       
; E5 W' t- B7 m' ?+ F7 Z                }, D9 g4 F$ Y9 m6 L* u
                - X" U" R/ c9 r( Z. H* t5 o
    } // end of class AuthorisedUsers2 ], v3 q+ \+ Z, V' M
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming& w: @" u  p. N% }+ s; E
Shanghai - 20079 F$ `6 A& F2 b) T" n, s
Assignment 2( c9 f$ N# w& D4 `8 O  [3 |
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)
, a4 @4 h1 d  O& G" B! ~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./ a# I# g9 |! ?& Z5 f" B! L" Q
The staff must be able to:! G: s6 [" K# u0 J
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
" P: Y% G# G( |" k  Y$ B$ I9 g1. 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.
% U' w& I4 x. B3 L The interface should provide a menu so that the staff can:
3 e" x+ q& d7 ?- y( va) Enter the names of the two Java program files to be compared
4 L5 r& V" @* n6 U2 @, ]2 j3 Q+ m For this assignment, it will be assumed that the two Java program files are in the same folder as your program.' ]2 H2 R6 z+ J- {/ O, |; H
** 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% v. x5 E# f: @6 }$ f
BSA104 Business Programming – 2007: Assignment 2( b4 E! ?* D8 I  u, F
Page 2 of 5) R6 |$ ^8 F2 U  N) W; h; `
b) Print out to the screen all the lines of code that are the same, ]( D& I8 n3 a# Y7 v5 T3 g
 Include the name of the file and the line number of the code being printed for each of the two files( {. ^! U/ [1 |0 v/ y( J
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
( s( ?) @( R5 ~% E- l" u the name, username and department of the user  [8 E# B3 j9 o- k0 }+ h
 the statistics of the comparison! \) T: y3 y$ v" u
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
; y( s& d2 L$ O4 ?+ a the recommendation for further checking
8 Y# z0 x3 v8 G' x: m  a' E6 {6 R  x- 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
' g( Z& E! Q4 W8 ^2 j5 ~# j the names of the two files compared
# y( @5 v% \6 S0 {% f! E% }d) Leave the program (exit)) s7 _! \( t) \% h% Z1 R9 S! g
The ProgramCompare class: (Total maximum 20 marks available)
, _8 s6 d0 B1 W9 O: D2. 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)6 q! Q2 F) f& g0 O" i2 |
a) provide an error message if the files are not found or there is a problem opening them& d  R1 r9 Q2 w9 @8 |" l+ q* w5 H
b) compare each line of code( n4 ^, M1 l6 ]! W3 U
c) print out the lines that are the same& j# H/ _  Q( S0 v
d) count the number of lines compared / lines the same9 M6 V' D6 n7 ~  \0 @0 s
The AuthorisedUsers class: (Total maximum 20 marks available)% Y& Z; y' x$ L6 ~: L4 ~
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)
7 |3 m  R! C  ]4 z4 {4. Provide methods to:0 P4 L8 q5 c! H
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
0 U1 u6 D& I! r% Sb) return the name of the authorised user" L7 u9 U& g, T5 n/ L5 R
c) return the name of the department of the authorised user
& c$ p+ h8 `0 Z/ {Individual Data (Maximum 20 marks available)0 d& o& Y, [6 d% H
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.& C5 r6 I- p/ k" a7 _
Documentation (Maximum 10 marks available)
  |9 @* Q, w: O8 k0 i+ n6. 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.2 }+ t5 g8 I& P* B# W7 N* D
BSA104 Business Programming – 2007: Assignment 2
# u6 q. x2 f2 j0 Y3 ]! Z# C" {: Y: rPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
, M6 X" C% Y8 O" y5 m不过你要翻JAVA的类库说明。你有下载没有?' u( }' B/ z: [1 h2 R  A
查询关于对比的函数。貌似关键字是contrast,还有compare
) M- D3 G' s' v4 j0 X7 O; d
/ \+ h. T0 d+ r: z[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -' {% b+ [  u3 `1 C' t8 L, {
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。0 W6 @0 C! d, ^8 {( Z
可以下载到的 是 jdk-1_X_0-doc
+ v& i7 d" ~2 L% Z
1 P# ~# f$ X$ |1 s[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-24 21:33

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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