找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1715|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急9 B+ N& {9 `2 Y4 D * A* i% |0 W" G3 f
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************& v% _' _' n: t  y8 E( D
//  ProgramCompare.java         Provided by: DRS% \! K0 T# H& i; F
//  X; Y$ e1 S) p
//  Program shell for Assignment 2' b, q- o4 B: O
//
4 `/ z) f' t; P' {//  Compares two text files line by line
. ~. Q0 S. \1 L//*********************************************************************0 ~  `# }2 j- y9 _: K! D: |

0 z0 O/ }; I# X. Z9 d! himport java.io.*;( g. o% _, T8 L. z7 ^# Q/ l
  ^( }! v7 l+ l/ k2 q
public class ProgramCompare9 y% J- U4 y7 l' u9 v4 f
{+ N: \0 H) ?1 ^9 ^* w
        //-----------------------------------------------------------------
( _& l( P/ r$ d) e- M, M        // Constructor
- J* \, b5 m3 S' [$ }        //-----------------------------------------------------------------# v: Z; M, @- R* o$ l
        public ProgramCompare()% U: Z0 o% H, n) ]& H2 E
        {  \3 `/ N- k  |& U" ~/ K# O+ U& H4 r
        }
7 @; e* P, C& r% B. Z: Z9 G# ~4 n3 M* s/ q) e
        //-----------------------------------------------------------------: _" B& c/ D9 ^) v6 ~9 r
        // Method for testing that class has been reached/ k; \3 h2 N4 L
        //-----------------------------------------------------------------        * K: x; w$ G* U# f. O

/ h/ l- ]: u: d* K        public boolean ProgramCompareReached()        
. R8 x9 J% g7 C. u; l        {
- b! |0 [1 [, e9 m" f8 F# x      try
/ ?! c* \2 D. q- O  G' s   {           D/ ^% H4 h, x3 X2 X
                        # j# I( H; P) t( O* p  M9 E
                //********************************************************************  K: E5 R7 U# m0 z4 [
                // Try-Catch Statement is used to handle exceptions - such as file not found / {& x, [: l! B; ~$ l; [# b/ J
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
" p. }+ {5 r# Q                // For more information see page 534 of the textbook  ^0 a1 G  z+ z3 ?  f3 s+ F( U
                //********************************************************************
: b5 P  S1 H! F. u5 T- B                     . k4 ~% w. v9 `6 F4 B6 {
        }
; K1 c1 I* T- ]! H4 o             catch (Exception ex) // Exception caught here and message displayed to the screen
) B; `9 H( z! L6 X* ]          {; A, k  @" `+ q8 W6 s
                    ex.printStackTrace (System.err);, ]6 t  F  g5 X; c) d+ I7 _' G: q9 i
           System.out.println ("Error message goes here"); // Replace this error message with your own         
7 ]! n( w5 \; N% ^2 a1 u2 A        }3 O3 J: ~2 L5 j! V  T% m/ Y" U
                return true;# x" Q, \4 G( J. }7 j
        }  G7 w1 V4 C/ q$ p4 K
$ G3 R. P4 D7 Z, j
} // end of class ProgramCompare
3 |7 T, \( [2 Z+ P2 q, \' W+ [# ^* Q) g( H! Q
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
, S' b! j# t' b  |+ D. s' V//  ProgramCompareMenu.java    Provided by: DRS+ p6 x- D. {' M* N9 T. n
//
8 X- M. {" _6 V# W5 Q. {, i0 @+ q//  Calls AuthorisedUsers.java and ProgramCompare.java& ~, [! p2 N% u/ I  w
//
5 x& r) H+ u2 v//  Driver shell for Assignment 2., r2 ?' F, p- Y% r* R
//********************************************************************
3 D9 c5 \' [+ T/ ^* ]4 D1 m' u9 M2 k; e
class ProgramCompareMenu; q- t# W2 r  _9 ?/ R
{
# j# g  s) X/ e$ x' f    public static void main (String[] args)( {7 @; F2 `$ D- p5 J0 R+ {
            {$ ]4 Y# g/ F" q- e% f: c
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable! @& K6 Y/ @  G. e" k/ L
                ProgramCompare reached1 = new ProgramCompare(); ; z5 i1 O. f1 z5 P
                AuthorisedUsers reached2 = new AuthorisedUsers();        $ `- Q) g/ t- t, z. A
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
  a+ g% ?9 o) M/ ^* t( t5 A, [$ F- Y                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
5 a" s! a. l; A4 |        }
! g$ O" C! [2 {6 E# [% r8 a}// end of class ProgramCompareMenu( X# }2 e* H; H3 O. l
/ c6 {4 b& Z2 X( e& t' m
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************) S' ^8 r4 Z- |+ h  D
//          AuthorisedUsers.java          Provided by: DRS2 R7 a- [# c1 a) k4 U: s
//                ; K! Y, t, T) C4 w! q5 S
//         Program shell for Assignment 2
* S2 K: g" u5 z) r//
' u) M7 K0 L1 V; |//         Represents facts about an AuthorisedUser* S' v0 G0 m+ ~6 l
//********************************************************************+ m4 S  @! B1 w1 T

1 ?, X/ ~0 D( W" H5 z# Epublic class AuthorisedUsers( X: W3 D* y+ d. b
    {$ ^( O9 V# s) X( D6 ]% ]! B

: @) m3 w1 j3 i3 m        //------------------------------------------------------------------ ~' U/ G! w9 ?: ~* }4 _  H
        // Constructor
) Y5 }2 K5 b# M1 `, i        //-----------------------------------------------------------------2 r4 R1 m0 E( e% d* w
* a3 E2 H; V% R  t' ?
        public AuthorisedUsers()) X5 k& h+ z* ^* _
                {
8 a+ t; c/ n1 S  n( @                }6 Z$ @+ ~# g) `" o* }0 L6 ~

/ M! h* P. E8 L; B9 H8 I& r        //-----------------------------------------------------------------
" ?8 P, T+ H! _* g        // Method for testing that class has been reached- T6 ~3 F2 Y$ @
        //-----------------------------------------------------------------       
0 `  b! T4 S/ A2 ~" [4 L        public boolean AuthorisedUsersReached()
6 ]9 w$ D: j' z" A1 B$ U: Y                {: b* x2 c4 ]8 }8 D* b  X9 m
                        return true;                        5 a$ v7 M3 I) {" \# J
                }
/ p- o" W# j3 {: _8 q  q                / ?* t# d1 V( }: r8 b
    } // end of class AuthorisedUsers" z; p$ s2 [( R- ?4 h, n
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
- ^2 M' e6 y- Q3 m# j! ^  PShanghai - 2007
; R, a# H' ~) GAssignment 2* o8 O: [% M4 U) T& y- R
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)
: b" k) ]( L% C5 g& N3 L! e8 |: v1. 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.: k* `9 }- D; l) W2 G9 n
The staff must be able to:
5 \9 ^9 }- Z1 R) D  l Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
0 Z- P; R, u5 q6 f4 s1. 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, H- {) K( s6 N The interface should provide a menu so that the staff can:7 Q& x4 Z7 t& H& F
a) Enter the names of the two Java program files to be compared6 z6 o* O6 X- K$ o" ^
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.) e9 p) x1 @2 ]3 ^
** 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).
# `0 |  e0 }9 fBSA104 Business Programming – 2007: Assignment 2( ^! c: G  V4 Y
Page 2 of 5
7 B1 _4 o1 u- o8 A/ o- ^b) Print out to the screen all the lines of code that are the same  X0 V. ~1 L- K  M  t* s
 Include the name of the file and the line number of the code being printed for each of the two files' P9 Z* m3 j+ e
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
2 n7 c; f, P! C2 Z# Z the name, username and department of the user
( n9 c- [' X+ y- l* m0 q9 G the statistics of the comparison3 E. _' d  l  N1 r
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
& R; s* J" a& b# s. l) }) L3 T the recommendation for further checking$ p* D8 Y: Z' `% z2 z1 a% l( E* w
- 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 closely7 `" H. z/ I& c3 }, }
 the names of the two files compared
: `2 v2 |" u  G; i: {1 E& Ad) Leave the program (exit)
& {8 O, Y) n' XThe ProgramCompare class: (Total maximum 20 marks available)2 L7 O6 s6 i! d4 s% i3 A
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# q7 c1 ~' r# L/ n3 W& {
a) provide an error message if the files are not found or there is a problem opening them
* \3 |( s' N  ~b) compare each line of code
/ B1 {4 c& ]  z, g& i* X7 B" o  hc) print out the lines that are the same
' W% V% Z' s5 q: Y; |d) count the number of lines compared / lines the same9 f# h) C2 I/ z$ M: H$ i
The AuthorisedUsers class: (Total maximum 20 marks available)) P% z+ X( P* [# F# G
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)
! W8 F( X! [& D! w( n4. Provide methods to:$ ?5 A* t7 U; k, Q! n" v4 O
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
* b5 T% C5 v$ i7 D. d* b6 N1 xb) return the name of the authorised user
# S& m1 E# H/ @. x) A2 p0 b. S6 M% S# yc) return the name of the department of the authorised user- u' ^2 n3 {: a2 h$ O
Individual Data (Maximum 20 marks available)
+ G; [1 H7 B: m2 }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.
% u0 y. ?7 }+ Q! T0 U: aDocumentation (Maximum 10 marks available)
. R7 t1 e: y% ~; ~" \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.3 ]( {7 A8 |$ J, I; Z% |6 f
BSA104 Business Programming – 2007: Assignment 29 p' J3 x. y; S
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
% G3 ^4 c, ~5 i2 X  ?7 C不过你要翻JAVA的类库说明。你有下载没有?% R$ _( h1 y3 x5 W2 d- G
查询关于对比的函数。貌似关键字是contrast,还有compare
7 X$ a2 C! g1 k' w+ Q, V) P8 m* e6 Z9 f& G2 t
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -7 O2 K0 d# K( F5 c+ g
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
  L$ t) o7 S( W9 n可以下载到的 是 jdk-1_X_0-doc
( a, ?* n9 f8 j( z: D3 C2 l) F# u5 R; E  Z; S! R$ b: J* L! a
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-9 08:11

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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