找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1291|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ' z% p( p8 {" S& i8 p+ U. Q- [" O
回复

使用道具 举报

 楼主| 发表于 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 n# U1 ~1 B5 B: B0 {' G- h& D
//  ProgramCompare.java         Provided by: DRS9 Z  l/ w3 {0 {& a# r. u
//
* s/ \. t& q$ w! M0 n' d( |; M//  Program shell for Assignment 2
" H: y  E! A. R9 Q5 i5 b//9 O6 o1 ^5 V5 O2 z# R2 B* @; H
//  Compares two text files line by line3 w0 V! z7 E, w, {% G7 k. o' K
//*********************************************************************$ F; x2 L1 F5 N$ M
. l+ F4 q1 `* ]- k5 f2 V6 g& k
import java.io.*;5 t4 T. X* o* d( C" v: @
0 _- V- [+ f2 F; B7 R" G- Y2 L: {
public class ProgramCompare' O/ U# F# C- t1 O# l
{9 [1 ?+ I; b1 B% u4 K* n
        //-----------------------------------------------------------------8 V% B5 g1 z0 n
        // Constructor. G/ [9 ]8 j! w# U- h
        //-----------------------------------------------------------------! E- Q+ x8 r6 S  {: w1 d' j
        public ProgramCompare()+ C1 o- H* g* w( y5 F* C( J+ }( m2 _
        {& u! G9 M' j7 ?+ g( E
        }% w6 B' s  R2 w! ]
8 s6 l; z2 Q  a/ m/ _2 ]
        //-----------------------------------------------------------------& l( i$ w- @0 O4 Q
        // Method for testing that class has been reached
! v' d! A  G7 P$ U4 `. P* k( _        //-----------------------------------------------------------------        ( a9 I' J$ @! Y3 A
6 F7 }4 V, g5 N# W) ^
        public boolean ProgramCompareReached()         ( Q, A- t5 @! D) [# l, r; M0 p8 |
        {! Y+ }: R. L6 G) I- ~
      try
, B: H( w) O; o% l8 H! I/ A$ Y   {         ! ], U& d5 R+ d2 s7 H8 c, D  `
                        % o% ]+ N. Q4 l. X- U3 ^
                //********************************************************************! s, O4 P# `6 c5 q0 i5 [
                // Try-Catch Statement is used to handle exceptions - such as file not found
6 J: g0 w2 |" Y2 P" y) j                // Reading the files will need to be placed inside a Try-Catch - just like this one!
) y, ^, |. l' l                // For more information see page 534 of the textbook5 Z- }- S6 e! y+ z6 {$ d
                //********************************************************************4 G7 S- {$ @$ t: h: U- `, J5 J
                    
, I( S# U- p  p7 \: K% d* I! o        }2 W1 f- b( z& @
             catch (Exception ex) // Exception caught here and message displayed to the screen ( b4 e6 l- ^8 m. w- m
          {8 c! n* b/ h' C! V
                    ex.printStackTrace (System.err);" J: g4 ?/ w$ ~( U; P; {# {
           System.out.println ("Error message goes here"); // Replace this error message with your own          5 S( C; p. \- ~% S$ H2 ?/ E% O' [
        }/ J7 \  Z+ A  J2 ], O
                return true;
  }6 _% Y. U: {6 }: h        }/ {8 s1 h& N: [8 h
) [5 z" T/ E! `% f8 |- h; B; E
} // end of class ProgramCompare
$ ]7 F8 h4 q  p6 l5 ]" K$ @$ [( E2 C! z$ `# Z; I% D- ~  \
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************  o9 R) P# i5 J1 D6 x" a+ \
//  ProgramCompareMenu.java    Provided by: DRS
( s# w- D0 ?( e% p//
" L; }6 x, b, r* T//  Calls AuthorisedUsers.java and ProgramCompare.java
) z& K1 W% X9 U5 I% O4 D0 I! ]//: G2 l4 l# g! r1 l
//  Driver shell for Assignment 2.
% U' {; O3 N5 H" B" w1 p//********************************************************************
0 w+ L# A/ v3 s% h8 C3 h# T; _6 r4 l
. i/ V+ G. B7 nclass ProgramCompareMenu
* f9 j$ J0 `( h. m% o% q: g{
! J% P( `8 t. m7 M1 B2 X    public static void main (String[] args)5 U' u+ _# g' R# C% i( b, h! O
            {
2 Y- F- b* _5 U8 ]$ r1 O                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
5 m( Q9 R: Q+ _                ProgramCompare reached1 = new ProgramCompare(); ' d: ?& z0 s, A
                AuthorisedUsers reached2 = new AuthorisedUsers();       
2 j: D- l3 W1 [, S4 h' i* f                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());: R7 S# l& ^& m  t
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ( w! w- }  O& i' G4 _( \; _
        }
7 d3 f: s5 R% b/ {- j}// end of class ProgramCompareMenu
- @0 k) `( Y3 A2 s
! M& M# t* ]. E+ e//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************' Y2 L9 l' x8 b! V1 ~( H5 J6 _
//          AuthorisedUsers.java          Provided by: DRS/ F" H# x6 G6 u6 I! Z$ T! d
//                * t1 ~- r) D/ _1 g# n
//         Program shell for Assignment 2
8 n$ j' t8 `6 n//
, X$ O& W* e' U5 i( Z//         Represents facts about an AuthorisedUser( |3 B* s% k* u" H; q( ]  T3 D& \
//********************************************************************
$ b/ \, W. y- q3 @0 L9 X% R* q
; v5 Z( F. W% V* T6 Spublic class AuthorisedUsers( x6 ?, U3 l0 P. y# [7 S6 z# `
    {
+ y) |* S0 l3 ?* Q3 L' ^6 e/ H, O: ~; S$ V+ s3 j' g# h: X1 k
        //-----------------------------------------------------------------
7 V. V' G3 ]9 d" E- X# z        // Constructor
! N# [4 ?" T0 q% u2 q+ G5 u        //-----------------------------------------------------------------
4 j" Q7 m$ A# y. B$ M; D7 R2 b  i8 |
        public AuthorisedUsers()
/ o& k/ g( y0 t" |% V. N! M/ f                {
/ ^+ Z" O# q+ J. B0 |                }5 z0 _: I& B2 O8 p  ?  _+ ^# u% ~

7 h3 h! {' u  h; c, b( R        //-----------------------------------------------------------------
' A/ y, o9 `2 s+ v        // Method for testing that class has been reached; W8 \. W6 w/ y; Q7 S
        //-----------------------------------------------------------------       
% }0 `& z2 ]% V5 d        public boolean AuthorisedUsersReached()0 _! T  d$ n& K/ y
                {
/ L" P1 V" G% |7 n                        return true;                        0 {9 }  Q  R! O# @8 z
                }3 i+ W3 [% b. U" l. K4 |
               
4 n( Q3 n. L( f! O- E    } // end of class AuthorisedUsers: O" P" s* D* r/ f) {) Q& G& h
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming/ G; N9 A& m' @: x$ b7 I
Shanghai - 2007: ~* u) s: R1 z9 D: _4 A
Assignment 2% ~' K0 a. Q/ C' a/ V: @" I5 ], i9 \
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)
7 W+ }* o6 m2 n/ a* \! {' c) a1. 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.& o6 V2 w7 L; g. {* r
The staff must be able to:& B, p% @$ p4 B- a% k( p5 p( D1 G
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
, `7 I5 ?4 O+ L1. 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.+ {0 `" m: B; u2 Y- n3 e6 H
 The interface should provide a menu so that the staff can:
5 t( _- D9 R. B0 J/ }7 `$ N4 m+ k* ia) Enter the names of the two Java program files to be compared
5 x9 E- V1 W# d. ?- \1 |7 c9 V( l For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
5 V( y' e  j1 c3 E( Z4 j6 K** 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).8 `4 q: n  n# _6 q8 H/ y
BSA104 Business Programming – 2007: Assignment 26 e; N' t8 S# b3 y2 S! d# [
Page 2 of 5
. K: Z5 l( U1 B( a+ m# C! K+ vb) Print out to the screen all the lines of code that are the same# p+ w) ^0 F! v- n2 C
 Include the name of the file and the line number of the code being printed for each of the two files
9 }9 b9 L. ?# B% pc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
4 V- m+ |  H* m8 O) a9 D7 L0 ~ the name, username and department of the user6 q. S+ j6 B6 p2 z7 S0 A& I
 the statistics of the comparison$ \/ f& F+ D" v. L" m: U
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
9 v4 h1 c5 W& y: M9 Z0 J7 Y the recommendation for further checking, N, K+ q  u6 Q) P+ n+ n: L6 [+ N
- 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: [; |" w+ m" @; @8 {. _+ u
 the names of the two files compared
9 W' F  a! y( {: b' W( _d) Leave the program (exit)
/ A! Z8 C% `7 AThe ProgramCompare class: (Total maximum 20 marks available)
. i  ^* o* U, L3 Y2. 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)' ~  p2 O# L* R7 z
a) provide an error message if the files are not found or there is a problem opening them& W8 ~8 o9 U0 H, L8 I0 S, z3 C
b) compare each line of code
+ X  ]3 g2 g" ^, V) Ec) print out the lines that are the same5 U- z% J* V- {9 d: O) }
d) count the number of lines compared / lines the same
  j2 o' P. V2 f+ X+ \0 L6 QThe AuthorisedUsers class: (Total maximum 20 marks available)# Z+ X, Y* n7 _  g8 i
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 K: ^2 d& B' P6 a2 s2 G- N0 ]
4. Provide methods to:7 l( e& z0 ?. v& H4 F  e% [6 O+ n
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
  u5 H" H  B, s( Z5 Tb) return the name of the authorised user, [3 f: U7 \) n7 g' g8 a; b
c) return the name of the department of the authorised user/ |. D) z. y- w
Individual Data (Maximum 20 marks available)0 F8 X" `9 J8 `& A4 [! z+ S# 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.. f, f# y1 Q% ~$ m0 h4 P
Documentation (Maximum 10 marks available)
9 I) z( l; _6 z4 V8 m' g6. 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.7 m0 m7 X! X! G$ B" ]: B
BSA104 Business Programming – 2007: Assignment 2" p% @, ^( Y9 h! t' B8 h3 i  h
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了  I+ U% J+ |+ R; s
不过你要翻JAVA的类库说明。你有下载没有?; c; |  @1 S% S+ X4 C
查询关于对比的函数。貌似关键字是contrast,还有compare- R& A3 Q# U" P1 M

0 l& c: O# p; l[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
* H0 g3 A  c; t8 u) y+ U痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。) v. [) W2 n2 t2 D% y
可以下载到的 是 jdk-1_X_0-doc
6 l! P# U$ L* C2 {7 Z: K' }( |% C, }+ p/ D9 t( m& {8 o
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-17 11:51

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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