找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1845|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 1 r: M- @, p# N- F3 d( Y% q : h' W0 F7 n- V% `0 A
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
' S8 _6 ]8 p" L2 n% o$ E, D4 s//  ProgramCompare.java         Provided by: DRS9 u/ ~/ A* p$ \5 B' x. o) r/ o
//
4 w4 g, F9 [. Z9 @9 p9 ~9 `//  Program shell for Assignment 21 ]2 V5 \) {6 b
//
, {4 R; j7 e1 B) }% p9 ^//  Compares two text files line by line! e  b; w* v; e8 v, |
//*********************************************************************9 D0 }. N2 r1 x! i- u+ F8 B6 T9 ^
, y% _* Q( T' S; r
import java.io.*;% u7 Z) C0 p- v9 m# E4 u+ Z( A
4 y' j, g: Z# L# G3 @- E
public class ProgramCompare% [) ]3 W; ]- p; p
{
: u* B$ V( C5 x, x: g  c: C" W! C        //-----------------------------------------------------------------+ _0 {' d1 @& \8 l4 T) Z
        // Constructor* ^- F- k; G' @
        //-----------------------------------------------------------------0 [# ?$ @8 }4 I- B6 ^: O2 P, |
        public ProgramCompare()
8 A6 y: X7 C8 m4 s( \        {/ y+ Q) f# T4 m$ R6 r
        }
2 |. v% z1 J# b7 o" N& m2 T! G; ?1 C$ `: B$ f% O1 i) d  z4 g
        //-----------------------------------------------------------------
/ t: I6 L/ G. |7 ^3 K* I5 ?9 A/ {        // Method for testing that class has been reached
  E0 n; m5 K7 r: J3 R        //-----------------------------------------------------------------       
0 S! k: T, \% a- x3 ?* ]
- K2 J% M0 a8 ^( R+ k% r, p        public boolean ProgramCompareReached()        
" A" q+ d6 f; K" @; t  g6 T: H* [4 w        {
/ }& B4 l1 P3 C4 Q% Y7 f2 B: b      try
  u0 q( E8 [3 V3 Y4 R8 t3 s   {         1 k+ z+ y6 l8 w
                        ' l& T' O$ l7 e  H& A0 n% Z
                //********************************************************************7 l9 q$ f, t2 A4 p% q# ?# Z0 \
                // Try-Catch Statement is used to handle exceptions - such as file not found ( g& g$ q3 p' M2 g) y3 x9 a) c1 l
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
- S9 f8 S, X% J/ w1 P' L$ o8 S                // For more information see page 534 of the textbook, V1 |6 s. Z) e: a9 z% E+ k$ t  p
                //********************************************************************  `$ L' k* Z8 `. s! g( {/ g
                     7 Z* u/ a! W! T8 K  e' T! _3 O
        }
/ J7 Q5 x4 C" j, Q, i0 k: ~             catch (Exception ex) // Exception caught here and message displayed to the screen
" _- f4 C/ w2 w" ^" ]+ n& n* y          {
$ l$ s$ _3 f5 \# z. X0 b                    ex.printStackTrace (System.err);- ]* w& k0 T/ }) R4 c2 x7 @2 P9 R
           System.out.println ("Error message goes here"); // Replace this error message with your own            D+ I4 {  b, a( c+ P
        }
( `# L( I) Z( S6 N. Z                return true;/ \; t% C$ P$ B1 v1 `
        }6 h  O; H6 W0 R: ^
0 ]; g4 ]% {" u" C0 ~8 ~0 `
} // end of class ProgramCompare
* R/ I- `/ l9 f! j/ L( K5 T1 l* c
9 |2 a3 V8 y3 v) u# I( t//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
, t! v9 k. x) F//  ProgramCompareMenu.java    Provided by: DRS
! r! z. v% U: h9 r# I/ t//7 ^4 _2 U9 _1 Z- V8 a& I* p" u
//  Calls AuthorisedUsers.java and ProgramCompare.java, Z) w% C% x  K! a
//5 w$ I  i! l+ n, Z" p+ e
//  Driver shell for Assignment 2.8 J" G- ^1 v' b8 _3 j: E' n! j2 O2 ~
//********************************************************************
( ~+ m$ M9 H2 Q. \7 L/ Y( d
  e* J3 S. c( k0 k! Yclass ProgramCompareMenu, ~0 i) _) T0 {9 K. `) B& e" a9 X5 i
{
( P6 O6 L# ^4 o% r: x" \    public static void main (String[] args)7 v0 O% i+ Y- B5 S+ K
            {
. o# u4 j# z5 M+ e6 o/ U                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
  y3 ~. I1 R# B) F0 x7 e                ProgramCompare reached1 = new ProgramCompare();
' ^5 k3 b/ r4 l" B4 I4 _                AuthorisedUsers reached2 = new AuthorisedUsers();       
2 m: i( a; s1 d2 L0 V$ o                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
; e2 l  Q& x( w+ Y& t& D                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ) T& ?/ N2 d# P. N/ H: X2 a. e! S6 a
        }' k& _+ ]8 S8 N( v
}// end of class ProgramCompareMenu
7 F9 A$ W1 |" F$ ^7 i$ v. ^- }" H4 C4 g4 J
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
! k1 t2 P6 |3 u# _2 G0 w$ y//          AuthorisedUsers.java          Provided by: DRS7 z2 S/ {1 l0 m: ~* J$ j
//                / j1 J1 y2 @2 I! P" x6 M: d
//         Program shell for Assignment 2: i" Y/ \6 `. A, }5 P6 E. ^
//8 i, G$ e- ?9 g8 J2 ~0 V
//         Represents facts about an AuthorisedUser
  O6 e( `9 ^2 H3 Z" c//********************************************************************
! q( t+ _( P3 v. W0 O  E
" \# t$ T; C# K- Q+ J2 z1 _public class AuthorisedUsers3 _( ]/ {$ T1 k* V* Z8 @
    {+ A9 `9 n( \$ I- I
  p. }# ]. W, S% D- d' L6 `: `+ c/ N3 ^
        //-----------------------------------------------------------------
* L3 S3 m0 \, a( U4 u" E2 Q        // Constructor# {# t, f0 g( h+ R0 y7 q
        //-----------------------------------------------------------------! W3 V0 s0 c9 w' m8 h
  }3 @) ^" u8 z! X/ [
        public AuthorisedUsers()- X( M2 v) A* u. }7 h# B
                {
- w5 N% o5 `) r* n2 ]                }! N  x3 @; Q" p

) W# |0 r* G- O# ], L6 W        //------------------------------------------------------------------ g; m* p8 p7 E
        // Method for testing that class has been reached
+ h( U& M8 b1 p. L* L* e5 D% z        //-----------------------------------------------------------------        2 ?2 p% T7 ?# e4 Z' b) C
        public boolean AuthorisedUsersReached()) E4 k: g( Y  |! [0 \0 m% `
                {3 X4 O7 W# ?9 q: Z7 {9 D: Q
                        return true;                       
- {9 w7 `/ L9 X* @( {                }3 v$ X9 f. w& j! m. N
               
. L- G  z  v4 C6 z9 r+ l, \    } // end of class AuthorisedUsers
) V3 F4 o0 a2 `  T- x. {$ H; J//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
9 q( @% n# [7 O( \0 [Shanghai - 2007
* Y' x" K3 s/ T. i4 e$ Q, L, ~Assignment 2% i1 K( p) ]- t: p/ d' m
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)
' t8 R# C8 r/ m; w/ }1. 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.
' }8 Y/ K9 h; n: @. _1 n7 G; \The staff must be able to:1 @& D# O6 |$ q! h" [
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.5 y' S1 ^4 R/ A* ~' U0 F1 @+ D
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.( U& J& T4 a# M/ n2 D8 j
 The interface should provide a menu so that the staff can:
# ~  d: x5 [7 I- X# n3 ea) Enter the names of the two Java program files to be compared
/ B2 E. d! w- A% ~' g For this assignment, it will be assumed that the two Java program files are in the same folder as your program.; q. _' O4 i) D4 _% z
** 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).
/ S7 A6 v% c3 y. E! e& nBSA104 Business Programming – 2007: Assignment 2
5 g' E* r' z& x% U$ I. A8 Q6 IPage 2 of 5, H6 p2 `9 s. p7 K  h5 v
b) Print out to the screen all the lines of code that are the same6 ~; ^$ n- ~, n& i# l' ]
 Include the name of the file and the line number of the code being printed for each of the two files9 G5 t3 D1 N) c, t; ?2 J2 S
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
+ l, O' q% D" k5 z1 T/ r& a# p) h( k the name, username and department of the user) b3 V( I4 c7 R" T
 the statistics of the comparison2 y, i: \8 h2 ?: T1 h! K2 @* ^0 J) T
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
) Y/ C6 _: ]- ~' \% }3 }; [ the recommendation for further checking6 Z. M0 X6 q- o* p: A; u2 i
- 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/ R- q; o6 m0 B  U3 Y
 the names of the two files compared
3 U. k, h- }' R# F* G$ `3 ^' D% jd) Leave the program (exit): E9 d0 h( ^* l: q0 S
The ProgramCompare class: (Total maximum 20 marks available)3 N" j7 D! P2 s6 ]
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)
( I8 N: s0 g/ H1 `' Ha) provide an error message if the files are not found or there is a problem opening them! n) _1 R2 g9 B4 U0 X# J
b) compare each line of code
  r$ m+ V1 w+ J" h$ f5 E/ Yc) print out the lines that are the same- a- x( E2 H$ p* w& |
d) count the number of lines compared / lines the same" E/ }1 `5 @( @: p; c+ _7 w
The AuthorisedUsers class: (Total maximum 20 marks available)
1 O5 y, B% Q, b3. 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)
, Y5 [: r& ^+ O' a& O  b9 h5 _4. Provide methods to:
2 }0 A8 e3 l7 ~9 `6 l7 Ta) 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
1 P" P+ V/ z0 p- jb) return the name of the authorised user
' [( p3 q- d' J0 p% @( K* D# H; Rc) return the name of the department of the authorised user. |: c! C! G+ v
Individual Data (Maximum 20 marks available)
' \7 W/ X9 l% ?. W' o( g5 u+ Q5. 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.
" U. |, r& ^" PDocumentation (Maximum 10 marks available)& w6 S$ x3 i9 k5 h1 [* _1 K# f
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.
* b% Z' q; @- o& ^  R+ `/ r5 CBSA104 Business Programming – 2007: Assignment 2
. {' p9 V+ ~5 G; LPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了1 w5 ]) c7 ]9 N5 a. Z8 i
不过你要翻JAVA的类库说明。你有下载没有?; {9 a) M. Z2 R
查询关于对比的函数。貌似关键字是contrast,还有compare- ~8 F" O4 g! r$ a6 A
; p6 F" s4 Y7 V) k- r, ~- {) n2 [2 h
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
, G/ j, l5 B" [# p/ x7 e" d  Z+ X痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
/ `3 x7 S# L$ E! f( D可以下载到的 是 jdk-1_X_0-doc
& D3 a4 b) t' K" W6 h6 g& q# M9 l: ~, q
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-19 16:11

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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