找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1391|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ( J: j: @% w, ~ # D1 b" q1 X ?0 A' 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 | 显示全部楼层
//*********************************************************************& W% E! J) h% K9 Y3 m6 _9 `
//  ProgramCompare.java         Provided by: DRS
" a" g3 c* v8 P7 r/ a8 g& S& s//' d9 p: a* m6 a% X" ]" X0 {
//  Program shell for Assignment 27 O& V; O; b& M' z9 j
//
+ M- D: n! M1 I- b//  Compares two text files line by line
6 T% `7 @) n. t, a" t% @/ p# U0 X//*********************************************************************
/ Y' N4 U: _* ?- g' x' y
" W9 R$ z; V5 n: Z$ t) r% {( wimport java.io.*;, I) _" G: r* G+ O$ X

& L7 i" a/ w  Npublic class ProgramCompare
+ B) s8 K2 t2 N0 P* e{" s: x0 l8 z% L" `6 i6 H4 |
        //-----------------------------------------------------------------, M/ b" I  b% B+ g0 L+ j2 `
        // Constructor
! }% W- G5 a/ J8 ?! J4 O        //-----------------------------------------------------------------6 \6 u1 Q  c) E( F, [, I) I
        public ProgramCompare()
$ Q7 k; d+ M) e! N( Y        {
: B4 d/ T6 C3 Q: R        }
7 T$ U1 n* {) S" `% N0 `
8 C2 m; M: u8 _7 t        //-----------------------------------------------------------------
: i5 `2 I* M6 r3 n( I: ?. z        // Method for testing that class has been reached
+ D' C8 E+ y& J% r" ^        //-----------------------------------------------------------------        * m7 a- `- H5 `; d3 @

( G  y& a: J; d- j5 S: d0 u        public boolean ProgramCompareReached()         + w; _9 I3 m2 F
        {
2 Q8 Z. Z6 q! e/ a. L: c7 n      try , Z7 L) x& b, Z$ W* ?9 }  b+ V  ^
   {         & v; m0 T6 i/ }1 q9 T
                        / T% H) ~2 }2 r
                //********************************************************************
! a. F0 G7 R7 }  [) b- W. H                // Try-Catch Statement is used to handle exceptions - such as file not found
, |8 T" r3 V9 {: f# X3 C8 V% Y                // Reading the files will need to be placed inside a Try-Catch - just like this one!
* ^( I4 \/ J. O" u$ G. K) J5 l; ^                // For more information see page 534 of the textbook# h  ]1 N9 y5 R# q- ]! V
                //********************************************************************1 [; @- d% _. M; Q1 j9 Z9 j* ?
                    
; ?# L9 I* N0 d. y5 N( J( [+ m        }& I8 r5 `# b/ ]" E" m) x
             catch (Exception ex) // Exception caught here and message displayed to the screen
/ P0 l6 ]7 f0 \3 ^2 F. t          {
% N% N4 r' |# S4 G$ H8 E* u, [                    ex.printStackTrace (System.err);
2 ~) O' F3 y4 w# \           System.out.println ("Error message goes here"); // Replace this error message with your own         
; T. _. k4 a6 X; I) H        }
4 C8 g$ E- s; i! \/ K1 F0 Z                return true;- \7 z& H& E; k! c
        }
6 i; s# O2 V0 u) ]0 J( B- M; Z$ I. T2 c+ [7 f
} // end of class ProgramCompare
1 }7 M' J1 j/ y0 h9 v) {9 i. |+ z& N3 k
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************4 o, a$ o; `: c
//  ProgramCompareMenu.java    Provided by: DRS
  r, U9 _+ e6 T$ M6 q//7 m3 ?7 X; }( a4 B. E* y7 E! G: p9 V
//  Calls AuthorisedUsers.java and ProgramCompare.java
& i+ L1 g+ n4 a6 \) I4 J' W) q$ b" u//
# x! _( l) l7 ~7 ?. b" x6 F8 E//  Driver shell for Assignment 2.8 A* ^) w" `3 D: j! D( f
//********************************************************************
9 ~5 c7 O4 q6 ~( G9 K/ ~0 A5 k
! s* @; R/ P7 |+ H5 V- Cclass ProgramCompareMenu
5 o' ]$ A+ N) \) i0 ^{! ^! k  P% N: g. v4 Y
    public static void main (String[] args)0 h  x5 _- t. K/ r* ^) }8 @1 O
            {7 m6 I" I( p6 f2 K1 W: p8 `) p' R
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
, v. ^8 E: G4 K! _  W& l  T& [                ProgramCompare reached1 = new ProgramCompare();
/ P1 B- V6 h! C1 B                AuthorisedUsers reached2 = new AuthorisedUsers();        ' U# c0 P( \  g- V% ~, t4 v" g. m
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());1 t9 t( I6 V0 \" J+ U( C
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());          A: u% i! s, V) j# k! R) S9 J- b
        }
3 J) g5 b8 _7 o7 [  R. T) _}// end of class ProgramCompareMenu8 B5 U( i6 @6 G& A$ a8 a2 A1 U

. W% a$ i) @8 O, e5 B! D0 ~//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
: o! @3 c6 S1 X6 s; }0 S2 l7 i3 C//          AuthorisedUsers.java          Provided by: DRS
2 ?0 v- G- h% o4 Q- r+ r* |//               
/ P% C0 ^1 ?% ], x, Y1 U# B4 a  {//         Program shell for Assignment 2+ C$ J- |2 k. ~. ?( f
//
- M0 ]7 x" {# c- `- O//         Represents facts about an AuthorisedUser
# [8 ]* p7 S# I5 ^0 o8 W, F; f//********************************************************************8 N) n- I# T% X+ y( ]' `
) T$ g: r. L" a  r, z, z' o
public class AuthorisedUsers
+ c7 N% S5 T/ H# W! w    {
5 H+ z6 K0 M4 a
6 S, n' f! Z+ o; d; _6 H        //-----------------------------------------------------------------* X" }* B6 S8 F/ g2 K+ y
        // Constructor% O3 i5 z. n5 e: Y$ T. H! a
        //-----------------------------------------------------------------
0 y+ t7 Y. G" \4 p8 m- Q2 E8 N0 c: l* k$ a
        public AuthorisedUsers()/ d, l) x' Q- L& x9 M
                {* m% T9 h! y7 L! ~+ K% J
                }
0 h2 D! ~+ k8 q- C. G7 Y  f2 T" r& @- U5 r0 S# N
        //-----------------------------------------------------------------+ S; P# t0 V2 E  f- q( f4 J9 L
        // Method for testing that class has been reached. R- D# J9 I/ L" X7 W
        //-----------------------------------------------------------------        : X% o! y1 f# r3 o5 M
        public boolean AuthorisedUsersReached()
2 l& u$ e# _0 u5 j                {7 Y' Y! ~2 ^3 Q# a# R
                        return true;                        / V8 [% k0 A& `* {5 \; Z1 V. u
                }
: A  u4 r9 R" b7 z6 E  G- J7 V! k                $ d1 z( {0 V3 q8 s
    } // end of class AuthorisedUsers0 g" q, ], w* U
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
! m! B* m, p+ C$ j& ], D0 LShanghai - 2007
9 L/ \& `8 }! I) [, [  c8 KAssignment 2" \$ h2 Z. S9 O1 _7 _
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)
  }: N/ f6 d+ E4 W1. 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.
; j; K* S& Z; C- D$ i( ]The staff must be able to:
9 K6 h! l, N/ K6 ]5 V- F Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.5 s' X( h$ x4 v
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 r$ C8 S( X4 i5 A) s
 The interface should provide a menu so that the staff can:2 h- N: N: D- C' e. w
a) Enter the names of the two Java program files to be compared* i8 K' d# Y- D7 G0 Z( b; p
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.) y6 W: }# O3 Y, a0 x- [( a+ F
** 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).1 ~, C, l4 E: q' @* @* ]- D, ^
BSA104 Business Programming – 2007: Assignment 21 y! \: x* z- ~0 l( S8 w
Page 2 of 5! S' t% G  u) N5 W
b) Print out to the screen all the lines of code that are the same
" F2 m& M; N$ d1 p# w& r4 {3 e Include the name of the file and the line number of the code being printed for each of the two files3 {" n  B  b4 R% E
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
9 l6 o8 G; W) @! e. o7 ]' A: p the name, username and department of the user* G/ ^8 g4 t6 g
 the statistics of the comparison
3 V# p" A* C; a) ~9 Y- R) t- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
/ \" T& C5 R/ ?% X' `1 q4 q the recommendation for further checking4 H8 D' Y' s/ U
- 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) I, ~- L# x4 {8 a) Y; W" u
 the names of the two files compared( Q3 w( G5 p) M  {  L2 _+ s& p
d) Leave the program (exit)% a) U3 r% X9 n$ i. b
The ProgramCompare class: (Total maximum 20 marks available): Z' k! {& K# S
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)
; R$ u- X0 L7 N$ E& o! \- Wa) provide an error message if the files are not found or there is a problem opening them7 i% k' o0 w& }% E! E8 T5 H+ k: v
b) compare each line of code. ~' m% ^, \1 w
c) print out the lines that are the same" n8 T; `/ P% G7 Z
d) count the number of lines compared / lines the same
& L0 R1 w3 r! l- Q- e1 GThe AuthorisedUsers class: (Total maximum 20 marks available)
- c! y/ G  f0 L/ Y* V9 P3. 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 g! t  W% f; r# j: c! q5 o
4. Provide methods to:
! |$ @" W- C( }0 s2 }4 e+ [  K- ]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
% }- T/ z# Z! r  S: @) u/ Zb) return the name of the authorised user
( h8 f0 V9 a3 i7 [' t4 r/ Rc) return the name of the department of the authorised user8 l& O  r; P% O% j/ M& l  H1 H
Individual Data (Maximum 20 marks available), Y4 T5 A7 n: \2 _; B% b1 {/ \3 o2 `8 I
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.
& }  j4 t0 p5 |3 dDocumentation (Maximum 10 marks available)! m9 I$ p2 A1 G
6. 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.
- j5 t/ {2 \- d2 HBSA104 Business Programming – 2007: Assignment 2
/ I  {. Y" n8 R  `: z# @Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
2 s/ E% M: W+ c# n! l0 x不过你要翻JAVA的类库说明。你有下载没有?/ r  i! |" m2 h5 p: ^
查询关于对比的函数。貌似关键字是contrast,还有compare# Z, J* u6 V8 a  ^

# \6 T# @; j6 o+ m[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
5 j8 i1 c, f. \痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。5 ]: {* X( _8 \( ^4 S
可以下载到的 是 jdk-1_X_0-doc" R% K. ]' Q5 v" z9 Q
% S, Q. u) \) m% I4 S# Q
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-18 16:22

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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