找回密码
 注册

QQ登录

只需一步,快速开始

查看: 960|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 " D" F1 p; o2 r4 d5 ^) c2 q* r$ D+ }2 s1 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 | 显示全部楼层
//*********************************************************************' o6 ]6 F$ w7 V' Y" N
//  ProgramCompare.java         Provided by: DRS; F3 J1 H. ~1 e. r. R2 O
//
( ^$ g: ~  W  L6 o//  Program shell for Assignment 2
3 V2 I7 M! G$ |0 ?//) z5 S6 B3 v+ R+ x0 i, T
//  Compares two text files line by line
* ?( P& j# B% E6 ^, m7 n; Q* C9 i//*********************************************************************$ Q& g) |- I, A$ i  u* j) I6 b
- A! b$ K' p' _1 g3 L# J* l
import java.io.*;
( d$ E/ t8 g0 O; }) J
# v# \' I7 b6 z1 w7 a+ I  lpublic class ProgramCompare6 Y, n# X1 H9 y
{
4 @, o# Q9 |5 v3 h        //-----------------------------------------------------------------( W( t: [. R# l: b1 `$ ^. d
        // Constructor
( D3 Z7 p4 e2 G, a  J/ V        //-----------------------------------------------------------------
5 j" J7 {& e9 I4 d! ?3 o        public ProgramCompare()
# X" F  \5 q7 T: _" A4 k0 u$ A        {% `( M- ~9 O" q% d8 L
        }
5 |' I! g, q/ A) ?
: M1 ~9 I  I  s+ j        //-----------------------------------------------------------------, O* A3 D& r4 U# m% N2 a8 _- ]/ \
        // Method for testing that class has been reached
4 m- c" {4 k& v) g( l        //-----------------------------------------------------------------        8 T5 a! }. k* \# Y! T8 ^  O: D% D% u
/ e. Z. J- \  ^( M1 n& t
        public boolean ProgramCompareReached()        
; f: f9 t3 C) A) s# a! M6 O        {) R/ n" X8 E" `. b' F" ?/ I
      try
8 ~) @( f- j3 N5 `$ D4 y* G   {         # K- X% O3 q% y" z. c8 u1 V
                       
. i1 _+ T+ d7 q) n                //********************************************************************
+ Z8 i+ Q. U8 K& L/ s1 N                // Try-Catch Statement is used to handle exceptions - such as file not found
$ z% n1 a" r! G6 X$ u) d                // Reading the files will need to be placed inside a Try-Catch - just like this one!: r* d5 n; B) \% v
                // For more information see page 534 of the textbook
" p0 O7 I% `) }+ @0 {/ Y2 I/ G                //********************************************************************
8 Z" M9 q5 H, d8 A2 _& n7 O                     1 _# H" [* z8 @$ R/ T
        }
" A7 ?  u( a) [# G& I             catch (Exception ex) // Exception caught here and message displayed to the screen
! K" o. B0 P: O: Z7 D( L' K          {
: i# m5 ^8 c7 i% |4 g                    ex.printStackTrace (System.err);/ F7 z3 l2 c4 I8 G# N, _) x
           System.out.println ("Error message goes here"); // Replace this error message with your own          : M( S7 G7 _; T+ w+ ?
        }
8 \5 z* w3 m$ H! K5 e" o                return true;
1 K* \5 A) n/ h, Z8 s- u        }' A" S$ u. H8 D
) Y% B( q+ S. I  ]
} // end of class ProgramCompare* \4 M8 x% d3 y$ ^" m: C$ V+ o
* }( _" d- G: z% S1 v; m2 Y
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************3 H4 u& Z2 b/ @, w6 k& p# ^# e
//  ProgramCompareMenu.java    Provided by: DRS
3 @' |8 O2 q/ _: r4 }+ ~4 R//
  T  t6 s" R# T. G' j( X//  Calls AuthorisedUsers.java and ProgramCompare.java2 P2 N, X6 O# t2 p* w
//0 l1 y3 q; x" W. W
//  Driver shell for Assignment 2.  `" x+ |6 v- F) A1 g
//********************************************************************$ z: W* n4 B% k4 o* P" D

+ M) N) |7 f) Z/ o( pclass ProgramCompareMenu5 ]' G- k3 \8 A8 L- S
{
8 L" \: Q: P6 ]8 A/ Q0 F  l& i: S5 k    public static void main (String[] args)
  i5 L& Q+ ~' c" ?, d+ C            {
( V% B" F7 I; f2 _                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
7 J5 m: N8 b) n# |" r3 a% f5 j                ProgramCompare reached1 = new ProgramCompare(); $ v3 B) D. b; {# W
                AuthorisedUsers reached2 = new AuthorisedUsers();       
$ i/ h2 p) J8 ~; R                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
& k- `' C0 j4 Z3 I                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
' D1 \3 x' r& K" t) w1 b) `        }: o( P! w9 k6 a  F9 v# j5 S' X
}// end of class ProgramCompareMenu4 S# m' S$ e) d; d! D2 I

. ~' d5 I3 Z; \1 [//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
, L7 A8 f" M6 b+ P$ N/ c//          AuthorisedUsers.java          Provided by: DRS
: e; J8 G0 g' p8 A//               
! Z0 q; s1 M& x; D' R# S" K//         Program shell for Assignment 22 Z2 V. P0 h/ ]  |
//
" N/ |/ N# G! F" x3 o2 s6 C//         Represents facts about an AuthorisedUser
) w3 W( a$ N) t' U) m9 t0 a/ x) g, J//********************************************************************
- @, d4 R% O. q- q4 S4 B. n1 U7 W
( V5 R7 ~0 A# j$ |& zpublic class AuthorisedUsers) m" |" j- i. V: S" L9 z
    {
/ ]! a2 Y* t: K7 z6 y- A5 N9 |+ m# ~* w& B1 k
        //-----------------------------------------------------------------
; v; {3 {1 S9 I8 o% F- Y- `: o        // Constructor' s; s. I" P+ T9 _9 E" i: l
        //-----------------------------------------------------------------3 p0 j+ N8 p' d% b" `+ M! Z

% w. w: o1 Y" k        public AuthorisedUsers()! j% G0 {- I7 C: O0 b
                {
3 }" J( u) l! ]$ g                }
4 X/ k; w$ O, I( L' W, j5 I
( k7 T6 h5 b7 S3 O# k9 c' S8 i( I3 a        //-----------------------------------------------------------------
3 |1 R* z$ B1 \1 g9 H, J" B        // Method for testing that class has been reached4 y8 q2 k& h" G$ H- F$ D
        //-----------------------------------------------------------------        ! M4 y$ E) R' u# N: ]( }
        public boolean AuthorisedUsersReached()3 V1 ?' P4 L" }: j% L& w
                {
  [6 J+ _# N, t. x0 C                        return true;                        $ K1 N! v6 H0 i4 b
                }1 t$ ^" V' v6 z6 h8 E. Z
                  j0 d% x7 K. S# ^( [. d3 \
    } // end of class AuthorisedUsers
. X# S' p2 x* ~//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
# R9 P5 A1 {8 z: I' tShanghai - 2007
" s/ |% ]) y3 DAssignment 2
' K9 U0 Y# I. m/ M9 z& A& r( FDeadline 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)
4 N6 v$ f3 ~' S. |; S# o+ y1. 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.
. \$ H! Z' T& ^) E% K, U/ e9 OThe staff must be able to:+ D1 a! Q& F4 H; @3 m# d
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.7 r; P; D% S2 x$ i& {
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.
3 C$ q+ Z7 B! k+ W The interface should provide a menu so that the staff can:6 ^& c+ ]* Q7 I6 J" Q
a) Enter the names of the two Java program files to be compared% g3 t2 U; m6 [1 c
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
/ r0 Q: [+ O6 t$ o** 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).
$ X: i$ J4 E* A0 G5 x  h; rBSA104 Business Programming – 2007: Assignment 2! |. i% ]% v0 e0 f& q8 i" S9 v4 K& x
Page 2 of 51 f; [  I% V4 [: `9 m, q
b) Print out to the screen all the lines of code that are the same6 m7 h7 v' u" B0 g
 Include the name of the file and the line number of the code being printed for each of the two files
* W- o" N1 e" U7 `c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
& K# n$ r- ]/ I8 @ the name, username and department of the user% d. s8 o/ {& D/ W6 S9 }
 the statistics of the comparison
2 V9 B: g. t5 _, v' {1 x- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different3 D. r9 a8 g4 h7 B) D; y( ]2 D5 r2 C
 the recommendation for further checking* q. \' S; \9 y8 S, m: a; G/ w* M+ d
- 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 closely4 L5 w, m, K1 F' s
 the names of the two files compared
1 z: F7 m; K6 w2 ^d) Leave the program (exit)6 d( Y( @5 G5 D9 C1 a5 u
The ProgramCompare class: (Total maximum 20 marks available)0 x2 A3 F) ~4 q5 N2 U" V! |3 V' C+ R9 C
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)
" c+ S2 E/ J0 R; ma) provide an error message if the files are not found or there is a problem opening them
6 O4 Q! W) R; N  \1 X) H' V$ j% Nb) compare each line of code9 _/ c/ G+ ?3 m/ \. n# I6 v
c) print out the lines that are the same
/ D1 j- B. L# ]- zd) count the number of lines compared / lines the same
; |9 ^; E6 e. c" L( c: _% H" ]The AuthorisedUsers class: (Total maximum 20 marks available)& D, `, H) C5 P6 S$ p
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)
: e5 d" H5 h4 K3 A3 `  M7 W1 \4. Provide methods to:  ~4 _5 Y( ^3 z
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 n+ w' J; `- v; k: Jb) return the name of the authorised user* }' ~6 d7 y/ z. b: c& h" r% w7 O
c) return the name of the department of the authorised user& [9 c' F. f* [5 O& v7 q& m2 K
Individual Data (Maximum 20 marks available)9 N- o8 e5 F. }2 B# `
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 |1 c  l* f5 ~" _$ yDocumentation (Maximum 10 marks available)
, y4 [/ U" U, f6 h: j( E6. 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.- H2 |( n: F) n
BSA104 Business Programming – 2007: Assignment 20 s  ]/ ?% i: N+ J$ o6 D
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
7 g: D$ Q' L9 [3 Y# z不过你要翻JAVA的类库说明。你有下载没有?; f9 v$ i5 l8 ]- d! W2 t
查询关于对比的函数。貌似关键字是contrast,还有compare
3 C$ a5 |) U0 x, s8 b1 z, H. W  R1 t; z3 Z' r7 s
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
: e5 O; I* i) Y痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。% u: H# f) o8 z. M$ q  y4 Q) P( a
可以下载到的 是 jdk-1_X_0-doc
) m) _3 e% E8 k3 T* H3 h* F% T
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-22 22:51

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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