找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1611|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 5 E) A% [; ~; S: P9 w! r" i * s2 M$ u$ v" F' R' Y( `9 ^/ C
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
( m4 A5 C% J3 }/ g//  ProgramCompare.java         Provided by: DRS
4 t" n6 N" n6 g% h//
6 s" `; _! Z  Z; k//  Program shell for Assignment 2
! r% b/ d1 ^2 |//
6 m! L) k! \  \% q1 c//  Compares two text files line by line
0 `! I5 b1 C7 T//*********************************************************************" [( F- w! b7 ]& ~

' {  ]+ ]3 O8 h' n7 Uimport java.io.*;
6 W- }$ |; I" |3 Q8 D/ S" p. |6 O& F( l' C* C+ Y
public class ProgramCompare
$ q" {; h) i, r- r& q) R{' a1 U& [5 w/ }+ g. y1 j! d3 u, C0 C
        //-----------------------------------------------------------------8 n( H( G& S1 W5 m
        // Constructor
# P& a8 n# |: r3 t        //-----------------------------------------------------------------
8 M  p3 W1 K9 V" L2 g' C8 ]        public ProgramCompare()
  r5 m6 x3 c2 `1 R        {) N5 g. d1 |9 `' I# K5 r
        }5 s3 j9 P, K2 W) _( c5 t

2 Y$ a/ w' U5 S5 c1 Y1 o        //-----------------------------------------------------------------
0 C7 y( N% n3 r% C, r+ o        // Method for testing that class has been reached
* I& b6 ?' T4 s) H& w        //-----------------------------------------------------------------       
0 H2 Y3 }2 f7 ~+ N# w" ~9 K" l
2 d; t" [- i- a1 p  s4 E- h# T        public boolean ProgramCompareReached()         , \% X$ m) O1 t+ _  T
        {
6 \$ j  x  L+ S/ C7 J      try
. R5 T3 w& \7 F4 w   {         # r% {( ?% B8 I
                       
4 M# a9 w& W; A& q  X! l4 {7 f8 u6 g! l                //********************************************************************. u8 A% K) O9 v' K  |/ t
                // Try-Catch Statement is used to handle exceptions - such as file not found ) O3 f# P& c0 q; d0 p+ W
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
9 ^3 h6 r1 W' L8 L6 Y                // For more information see page 534 of the textbook
& W6 }# Z3 R8 Z8 F                //********************************************************************3 Q% q# i# [5 H# ?" ]
                     . h4 X; L1 s1 O* x' \
        }
; j" R4 V8 m  q" N4 I! n) _5 W. p1 v             catch (Exception ex) // Exception caught here and message displayed to the screen 6 q$ j, O: Z9 \: x
          {; o$ ]/ C$ _! g& R& T) t
                    ex.printStackTrace (System.err);1 K7 E" T" a: w: F
           System.out.println ("Error message goes here"); // Replace this error message with your own          6 D- _% _% f3 d8 [
        }
" {1 g- m5 I6 ~, W7 Q                return true;( b- d6 d, ?% i2 f4 e3 a0 j$ v
        }
, g. U( k- ~: O
. O/ m) y$ H) Z} // end of class ProgramCompare
. z  [2 N5 j2 Z5 Q. y# M0 L, o2 A; C1 ^: n, W
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************- }) `/ O" R: R
//  ProgramCompareMenu.java    Provided by: DRS; z6 a9 M& W/ M: V
//
) g. C5 L3 X) s: N- m- c% |//  Calls AuthorisedUsers.java and ProgramCompare.java
* c0 R  i5 A6 r" {4 s; g8 U& k//
) Q  e. g! g$ q2 v//  Driver shell for Assignment 2.
4 x" c8 F) e* G5 l, D" y: K- [' m//********************************************************************
: [- B# y+ H6 `: D! `7 G% B  C) C! `. H' o) k2 B4 Z2 k
class ProgramCompareMenu1 H: Z# @- x' E$ K" e5 v0 ]/ P: p# n
{' b" x- V( C  `4 I
    public static void main (String[] args)7 I5 w3 u( j- w3 {: N
            {
  J: U, {# B3 O  H$ r3 X                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
9 P, x' `# o# T+ e                ProgramCompare reached1 = new ProgramCompare();
- ?# Q# @0 s( r& Y                AuthorisedUsers reached2 = new AuthorisedUsers();        ; |3 M5 A$ }% x) g6 s
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());5 r- n* @1 c8 F9 S$ G0 o
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        - \5 Z5 R. @$ n) @4 E
        }
0 [9 _+ p: ~) K" E, _" Q4 ~}// end of class ProgramCompareMenu
4 X1 d) {; q+ @+ @$ s: p& r
! T- o6 H; m9 u) q& A- j6 C//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
9 f2 }% i; S# g2 R. |: J7 j) |//          AuthorisedUsers.java          Provided by: DRS
, p; z, _, z5 D) T* p//                  O: }$ F2 Y( I1 F) r5 a# h
//         Program shell for Assignment 2
* V  _# R" z1 p: z. d3 ^$ `//
* V3 a3 _5 T& o: s/ X4 V//         Represents facts about an AuthorisedUser
  O. P) ?# r) l% ?) C//********************************************************************( p( t" X2 }' \8 R. t

  v$ C  P' L0 n9 Qpublic class AuthorisedUsers( H: S/ @% E! ?/ X' W" m
    {
! [3 n5 @; B# M1 k; o$ `
& L: e4 `* I, \, w! V5 E        //-----------------------------------------------------------------
# p& A% R% u3 @- {. j& K5 e        // Constructor
4 l3 V" `+ z( Z$ q" |# b        //-----------------------------------------------------------------6 I, n2 b  I; k* G1 P: \- I6 M* k4 p

; \. ^: F- b$ S% t' Y) s% P        public AuthorisedUsers()
' ~# `) X8 Z; A, n9 @                {
( d1 f+ M! y' t) g) `3 w                }
, J2 r5 \, m% Y
7 i: {' u. ?4 K# r9 t, \        //-----------------------------------------------------------------% |3 j) i7 I/ {& t- ^
        // Method for testing that class has been reached- T- I! P/ w" c+ E$ h
        //-----------------------------------------------------------------       
5 T! [( Y% g/ e! w; C. T- f        public boolean AuthorisedUsersReached()0 q$ E' O) ]: |! H+ u
                {
. z$ y+ h+ D0 W' j( |) i                        return true;                        * ]; ?4 V) o# W% O
                }! [6 h9 ^' X0 B5 F7 x
               
* [- A, {( `9 Z, e4 G' A4 g5 Q    } // end of class AuthorisedUsers
6 O4 k) d7 H  i6 A& c; Y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
+ k+ |0 Z& F  D% P. O: lShanghai - 2007" A$ R3 B) W3 [9 [3 e
Assignment 2+ d5 E9 y+ U. D
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)
3 g, }2 y. ]5 i$ F& M- z1. 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./ c+ I4 [2 I9 v0 {% Q7 D  F! A
The staff must be able to:4 _! w! c# I' a! Y
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.* }! r* |1 X0 x. p! `" `/ L
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.  ^' M; ^) H+ r; ^6 O
 The interface should provide a menu so that the staff can:
& T" m2 _! E5 E& ma) Enter the names of the two Java program files to be compared- [6 J+ C5 G0 r7 \. _  c- S
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.4 g3 Q. i4 Z# ^, c% K- B1 r% U
** 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).
% V$ n  }' M. ^) w8 u9 aBSA104 Business Programming – 2007: Assignment 2
% u0 d- u: k; K! H9 q" x' m7 Z8 r& |+ w  gPage 2 of 5
9 n$ ^, _9 f' B: D) F/ a* c; Pb) Print out to the screen all the lines of code that are the same
2 O) x+ g/ j) h  Q3 r4 e4 A# w4 Y Include the name of the file and the line number of the code being printed for each of the two files4 t+ U' P. p% y# S; C( W: @2 Z
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared/ \8 y. F3 G) s+ D8 L; ]
 the name, username and department of the user
4 K' ]! J/ M0 q4 E0 R( Z the statistics of the comparison
0 K+ r1 s7 b" C- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
7 V$ ?7 L' Y, s the recommendation for further checking
6 M, Z0 ~3 O( p- k- 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
9 l1 v( R4 L& Q; D7 W the names of the two files compared* S" S" F' M. E6 J8 _3 T/ w6 W+ a
d) Leave the program (exit)
1 l8 J  R! Q% O! o4 A) Y9 ^) KThe ProgramCompare class: (Total maximum 20 marks available)7 X) T$ C9 ^+ U% `" I6 L% ]( a' g$ z
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)" x: Y) N. I7 i- l* A$ |6 Z% i7 S
a) provide an error message if the files are not found or there is a problem opening them
8 }. N8 n& g, ?6 eb) compare each line of code
* w1 ]1 E  v" l5 t, l( ~5 pc) print out the lines that are the same. Q, X; r1 i3 q" J4 P9 R
d) count the number of lines compared / lines the same
- }' u* [2 N5 D# C% YThe AuthorisedUsers class: (Total maximum 20 marks available)! N3 q& {0 w9 T) `" T1 b$ p/ o% a
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)5 z1 S4 p" ~  {1 f1 b* J: e9 _7 R
4. Provide methods to:* B& s7 w: ?& C, r; X3 C
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
, \3 r! q4 ~' c7 `: V6 v, x9 B( n+ Rb) return the name of the authorised user' x! n$ f% Y, \
c) return the name of the department of the authorised user
; Z1 ]% D4 _) S6 Y$ g$ lIndividual Data (Maximum 20 marks available)
6 N) D" U. K& R  A5. 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 W4 S1 r2 b/ h, [
Documentation (Maximum 10 marks available)
3 g5 I. f* ]( p- K6 f6. 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.
+ Y. F8 y6 L, U& F% Q: d. ~: X& lBSA104 Business Programming – 2007: Assignment 2* T, @- u$ d+ ~+ v4 w
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
4 [$ h: Z. I; M不过你要翻JAVA的类库说明。你有下载没有?
& H$ h5 m6 u1 R' {查询关于对比的函数。貌似关键字是contrast,还有compare
! d* i5 a+ h3 w1 d, F- W4 O% B$ h# g" a: q- [  k! X
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -3 |# v4 a) t/ j# w
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。3 s% Z; y( ]1 y
可以下载到的 是 jdk-1_X_0-doc" o( _1 N- h4 m* b* S! p9 u
% d# d) T4 [7 ?" T- ^
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-7 08:48

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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