找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1347|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急: V- O5 u; H H6 h/ n7 Q W 2 e: B3 e q2 Y* c3 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 | 显示全部楼层
//*********************************************************************+ w( A* W* S8 I: N- b( @% }. M0 V
//  ProgramCompare.java         Provided by: DRS3 W, a1 [8 |% z$ ^% ]  x" Q
//
8 A4 v6 o8 T1 C( w8 u//  Program shell for Assignment 2
7 d1 b: W, Q; U* a; L3 U' i//' p8 f$ z* Q4 q8 c+ Z7 r: ^
//  Compares two text files line by line- c0 M/ s% Y" @" s2 F! Z
//*********************************************************************5 x, l0 S  e2 ~; u3 b+ ]9 E

: D: i; c1 e# H( @/ K0 mimport java.io.*;
+ C- ~$ n$ V8 P9 O+ R7 v1 z: d2 s* x: Z5 H# O+ k
public class ProgramCompare8 ?5 [! i( ^$ q7 N3 B1 J
{7 x" Q4 K8 c. N9 e' v6 }
        //-----------------------------------------------------------------
7 W4 l5 R6 ~' l4 g. o) c, B3 n1 P4 Q        // Constructor
3 d1 a% M5 G# ]2 J! A+ m        //-----------------------------------------------------------------
# O# Z  ~3 d) o4 F        public ProgramCompare()2 B- q  |4 Q. Z( F
        {
# Y( G/ v3 O2 |1 ^7 D        }% G' C( n; v( Y; u8 g
& G' u2 P: Q! ~; K, f" x
        //-----------------------------------------------------------------' u8 P# R7 B7 y
        // Method for testing that class has been reached2 K3 ]' e3 l2 Z* u" E( c
        //-----------------------------------------------------------------       
- Z# }2 ^2 q0 a+ G3 {3 K) u" F$ R* q8 \8 s% S$ d  _3 ^, v" J
        public boolean ProgramCompareReached()         / n- E/ ^; P7 Z# T4 B9 V2 F4 D
        {5 `! {5 K' j0 n
      try 9 \! U7 N9 a' e0 g2 h" H0 Z
   {        
0 D) F3 p8 M" ?/ g- Z- i7 Y                        ( E! t+ M/ }2 Y5 l. d0 q
                //********************************************************************5 q/ W! X5 |( r
                // Try-Catch Statement is used to handle exceptions - such as file not found
( l$ C0 [" f0 j0 [2 g2 r" E6 q& Y0 x2 Q                // Reading the files will need to be placed inside a Try-Catch - just like this one!/ ^& }7 e! x, _
                // For more information see page 534 of the textbook
2 S+ e7 Y1 y# |/ H- T3 b' B2 S                //********************************************************************9 s$ o! P6 s( {" h
                     $ k  r. i0 q- c) m
        }
7 ?- ]; U9 k( W# Y             catch (Exception ex) // Exception caught here and message displayed to the screen
9 {* q" t2 M2 y; q) y0 x4 @& \          {2 @7 ]" n  ~- S# d
                    ex.printStackTrace (System.err);, S+ A3 y+ j! r
           System.out.println ("Error message goes here"); // Replace this error message with your own         
  x( i& J( c" c) j, U8 F$ ^2 F: ?# {2 ?        }! I6 q$ ?- Q; S5 L& ?
                return true;
/ B3 t" q4 G' `* M$ R0 U        }- H2 J0 E- V% j  b

) B" A0 i) H7 L3 s6 v2 a} // end of class ProgramCompare* V( m4 U  L; X  j9 T! E
5 ~3 U/ o8 q  j( B0 G
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************/ i+ _0 J/ `* p3 @9 j( s4 C
//  ProgramCompareMenu.java    Provided by: DRS
2 f' g2 i1 t. o, g7 A/ J4 I& O//) v6 F/ K9 O  Y$ h- P4 K
//  Calls AuthorisedUsers.java and ProgramCompare.java1 B+ J/ \: b+ e( B. S
//
  P; D# y& H/ H0 f1 T( N6 b//  Driver shell for Assignment 2.
- K2 g* b1 Z) i/ W//********************************************************************1 @/ `" D/ K: J' e3 U1 x
" w* ?; ^- j" S- Z
class ProgramCompareMenu. c! L2 X& R' d9 n  ?) F1 g
{
6 Q: e' g; Q# G+ a  q    public static void main (String[] args)6 m9 e2 Y  o' A8 i4 b0 g% E  l
            {# W- @& M* y8 j" K( A
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
0 m4 I4 n& p- c                ProgramCompare reached1 = new ProgramCompare();
- A3 @  {) g. l2 T& T% B. w) B: T                AuthorisedUsers reached2 = new AuthorisedUsers();        ( o8 s  V. k8 s- v
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
2 i- \( S" h6 b$ s* c                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
! ?, ^- S" I" P- @) l        }
* g$ W% p% U/ o' g( _" f8 n2 W}// end of class ProgramCompareMenu
) w! \# U3 `: n8 }3 i: x$ m, \, Q9 R
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************! M0 L% j0 G: k, v8 a/ L
//          AuthorisedUsers.java          Provided by: DRS
2 C! B2 P3 V/ V* B* Y) p//                ) u+ Q# T. F3 O! u
//         Program shell for Assignment 2
- q' w: G! U+ G! ~4 z: I//1 `4 H  Z  ~) }) M& n* p
//         Represents facts about an AuthorisedUser
( c( R+ H: E" `% r; m" ~//********************************************************************
. k+ Q/ C- H  ^- B$ b) L( f+ b8 M, h
6 ^3 m: l# c  f6 Q9 V( Zpublic class AuthorisedUsers4 |6 ^1 V: u1 H# i
    {
& u' v  C0 [/ i* l8 y! b/ {! l% u
9 r) k( Y' Z, _. a: N# u        //-----------------------------------------------------------------
; X+ p8 g/ h$ s5 T. W: F        // Constructor7 N* S. E( V4 g* v/ V7 \1 u
        //-----------------------------------------------------------------9 I/ r; K. S3 y( R
# O+ @+ ?$ b% q) ?$ p3 q$ L
        public AuthorisedUsers(): ?$ k5 M) Y) s# @) u. K$ a( L6 y% I: U
                {
9 K9 k: m+ Q0 z: c9 m0 J                }. Y6 A% K/ ]- U" S6 G5 [, ]5 q' p! @
! Q2 h8 ]8 P/ P1 A! z. F. z2 ?4 @' T
        //-----------------------------------------------------------------) q# |. t: w  w
        // Method for testing that class has been reached, k$ R* Q( ]8 m, ?
        //-----------------------------------------------------------------       
& Z$ h3 G$ j: d, D5 N. @+ Y        public boolean AuthorisedUsersReached()
& k4 ]" @. c9 A  G3 }                {- _7 u* ^1 Y. l
                        return true;                        . J' n# i9 l0 w' e7 ~& Q1 Y
                }+ h6 s4 g/ F8 `/ F9 f; o2 i! Y
               
/ I4 f, F- _& |4 K4 }6 I    } // end of class AuthorisedUsers+ u: A" [' F0 h5 I2 H) ]
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming$ W, Y8 a  k+ Z8 b! U
Shanghai - 2007% S- f3 V9 O& k+ f+ p, f! M" {, A
Assignment 2
9 y1 U+ I1 Q8 \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)
, p& |5 z4 q- 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.
& R7 {1 z2 s( I: y: z8 `7 U5 RThe staff must be able to:
0 W1 m. k0 T9 y, i' M$ \: r Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
! A1 H  ^8 \3 }7 O5 @2 k5 Y1 ^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.
4 W2 x3 W% y- J4 r. n% |& C9 m. O6 d The interface should provide a menu so that the staff can:+ X- S9 Z" L, l2 X
a) Enter the names of the two Java program files to be compared1 O' J" B: V* D0 ^- D) H
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
, a$ |) _$ |8 \* |7 A  _** 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).
+ J& Y% V% Q# M8 ~BSA104 Business Programming – 2007: Assignment 21 Z0 V& U% c+ ^! v+ m, X
Page 2 of 5
8 u% H# V5 b. n  {& }+ C, r+ d% cb) Print out to the screen all the lines of code that are the same
* k% N" y! o  x0 m  H! ?: x Include the name of the file and the line number of the code being printed for each of the two files) _6 F4 L( I# T# V  M8 d
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
6 W) S' h' @/ P! j the name, username and department of the user( u! v4 N( F: n, P7 \, C
 the statistics of the comparison& J  m  u& f: I. q* _# ]8 N4 L
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different) K$ g' N  o- O6 t  e# W
 the recommendation for further checking3 ?( G' L4 K1 J- h' k& v; a6 d: }0 d0 Q
- 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
5 F& n9 w7 p  X( ^4 C" w( X( S% { the names of the two files compared' p, ]( w0 q/ d- e, V' D, n
d) Leave the program (exit)
5 L- K4 S8 c% x4 v) O9 t* LThe ProgramCompare class: (Total maximum 20 marks available)
6 w; t( _7 H: f7 |$ W2. 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)/ u: d; V0 y+ ^  V
a) provide an error message if the files are not found or there is a problem opening them- N/ H) d4 S3 s- R, ^  e/ {
b) compare each line of code
5 ?, X/ F6 S2 ^4 U, Z3 Q5 Dc) print out the lines that are the same
1 K" A0 s4 D; l2 H4 S4 Z. |d) count the number of lines compared / lines the same
! w+ _  F! H( i  S) K" {The AuthorisedUsers class: (Total maximum 20 marks available)/ j; u2 b9 k8 E& C0 ]' d9 o
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)' U9 R" f+ n1 \; |: \" p
4. Provide methods to:
8 v3 q2 z( K( F! ?6 Z5 T1 ]0 {  }: L# {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
# m/ G' r1 [: u1 kb) return the name of the authorised user! ?) q& I, b" A6 O( K5 Z. v! X
c) return the name of the department of the authorised user
1 Q9 `5 q- b$ \Individual Data (Maximum 20 marks available)! [$ Q- f) f& ]: @6 N. ^
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.6 |/ |' T9 C$ H+ B
Documentation (Maximum 10 marks available)' ?  S% K) O0 Q
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.
" s! ~, x0 y2 jBSA104 Business Programming – 2007: Assignment 2
7 o* o9 c+ J7 I% Z8 ~! UPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
) E' i/ e7 _6 F# t: L7 Y不过你要翻JAVA的类库说明。你有下载没有?
  o9 W/ `, f( H1 |7 Y, R8 s& |查询关于对比的函数。貌似关键字是contrast,还有compare
9 ?) O0 e/ O" p# {& C& T6 u" V4 c$ u. _- g3 V
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
( t& P9 x5 b6 A# m痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
  D% x) ^& r1 E/ Q# r( ~可以下载到的 是 jdk-1_X_0-doc7 [' N' g- w8 |8 L1 w
" @1 c6 ^# p: W
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-4 09:13

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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