找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1230|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急: J5 B& V7 C5 l% I- W/ {4 ?: S " ~% X* ?) T* `3 m7 |; h0 R
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************4 R' G4 ^# w# Z' p- X/ }
//  ProgramCompare.java         Provided by: DRS
+ g# q7 q% M/ f* {& Y//4 c( X+ E' @! k* P% B
//  Program shell for Assignment 2
8 e/ f  `" T' h0 k//0 U3 H1 ~, c. C+ {( h2 _" `" p
//  Compares two text files line by line. X# L* [' D; v2 u7 N( y8 B" e1 u
//*********************************************************************
; D2 |( B, c7 L# Q2 c5 c( ]
' x. [9 M- P) y& I0 j  u0 Bimport java.io.*;4 b( a% O$ X1 @5 s' W' |
* O. k2 S- e1 G" H: H
public class ProgramCompare4 R. O( F0 W9 ?6 V
{' v. H# s. o9 p/ }+ V! X% Q. m, R. J
        //-----------------------------------------------------------------
# ~! L- o. G5 M" A# F8 u! ~        // Constructor
/ L1 H( T) w( j+ Y        //-----------------------------------------------------------------) Y% b- j! D1 {1 i3 I6 Y; @  p  M2 K5 h
        public ProgramCompare()
6 a% }6 Q3 t) ?$ e        {0 g% S( H8 P, p( M
        }( l. r+ Y( Q5 S2 V

% N. }1 I8 H5 z5 T        //-----------------------------------------------------------------0 `5 `) }$ L8 E$ U8 `  w
        // Method for testing that class has been reached
/ [* U8 z" E- i" J        //-----------------------------------------------------------------        ! s- e$ |& m7 ?# m4 k

$ ]& |+ s3 A/ o/ c& y8 p        public boolean ProgramCompareReached()        
5 W3 z: [* S; t6 s9 @: c9 H. r        {! e$ r- ]9 x6 X; O) d( A) V
      try 6 I1 @; \# D8 I1 ?+ @. T; _& z
   {         : ]5 G9 ?) A3 j( V3 F1 M) K/ s
                        & `1 f. v9 @& L  \
                //********************************************************************
/ c9 }/ I, ~" K$ @% h" q8 i- S                // Try-Catch Statement is used to handle exceptions - such as file not found 4 g/ G) j2 y! I& M" u% ]1 x2 d2 `
                // Reading the files will need to be placed inside a Try-Catch - just like this one!' ~4 `! l2 j/ u1 i& |5 W4 _8 }+ \
                // For more information see page 534 of the textbook4 R( ~( Z5 e$ R5 \
                //********************************************************************
# w  X* U- X# w                    
- T; ?( K# f  ?1 W' k3 x        }
/ ?0 F- S' l* p) U, G3 I7 t, ]             catch (Exception ex) // Exception caught here and message displayed to the screen ) q( V) ?+ R4 y* f! T2 b
          {
7 H& L( q7 k4 T, _5 g                    ex.printStackTrace (System.err);0 s0 z5 g! H" j+ l) v7 h
           System.out.println ("Error message goes here"); // Replace this error message with your own         
2 \1 F' W) |, q* X0 |        }/ `' R: f7 w( I
                return true;
3 _3 p6 [# L  o: ^. o0 D8 [% o& Q# W        }
5 e6 }+ e- ]' c+ m8 c9 s% p2 G5 q. T' a
} // end of class ProgramCompare3 [6 _! D0 o4 K3 ~
7 J6 Y, i* y- Q# f. K
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
) ?' A- m+ @% e# V//  ProgramCompareMenu.java    Provided by: DRS3 G+ v" c/ P& h: X4 u; M
//
* }2 J' {' a! r7 f( r+ I//  Calls AuthorisedUsers.java and ProgramCompare.java* S% m3 z! y2 s  w
//, d0 F, f2 j: F0 f" U8 C+ m
//  Driver shell for Assignment 2.. ^! c5 D  h# I
//********************************************************************( F& e+ y! q/ `) S
4 w" }  o4 [" G9 }* F
class ProgramCompareMenu, H$ M9 O4 [1 l, A& b
{
: @3 s* L$ \9 c, \( q& Q    public static void main (String[] args)2 t. z. }" K+ D  T+ s" i
            {) Z1 D" D3 g0 f( f
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
! g6 |' a, H! _' @- B                ProgramCompare reached1 = new ProgramCompare();
, Y$ j" V  Z4 T0 z. e$ x3 K                AuthorisedUsers reached2 = new AuthorisedUsers();       
2 e$ I, J  X* g9 j* \/ ?8 W                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());3 ~0 A9 e$ F, z  w" n; l
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ) @2 F) r# U( F) n9 {2 A, C
        }9 T1 ]2 A" t  ?1 J, S. x2 F; i* _
}// end of class ProgramCompareMenu
" `. n8 m1 q$ n# j+ \2 U3 x- ^; }/ ]$ B2 {! r
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************* D3 O* l. }! M1 `
//          AuthorisedUsers.java          Provided by: DRS
1 ?1 Y" y. A' H1 ~& M$ T; {//                4 |7 t4 @% C2 r, T0 V7 l/ P9 ~  Q# h
//         Program shell for Assignment 2: I6 x& T6 B% z7 g- Y% q
//
+ U* h3 j/ z( d% Z4 a0 c3 _! a//         Represents facts about an AuthorisedUser" o3 f* K  `% Y
//********************************************************************
. ?. p3 Z0 y/ c* j/ x
" a. g% |1 i$ R; F$ Z! w+ @public class AuthorisedUsers
2 f3 i  q& Z# Z* \    {/ l4 W" x7 g+ y! ~: V
! F' Z/ p# ~, P! N' K' e9 v
        //-----------------------------------------------------------------
( o& d, d8 l# a* l. C; L" h        // Constructor
$ Z4 y0 J7 ]: n% @- n4 V( x        //-----------------------------------------------------------------0 l1 c* N) u+ v% k8 m

, Y( E. P* S2 `' n        public AuthorisedUsers()( C9 H5 E1 a0 m/ Z
                {/ C$ i8 w5 U1 ]5 o. O, S
                }
) d# k9 j* s% d) M5 U5 u* i' k% a# J1 n/ {7 Y8 ]8 R
        //-----------------------------------------------------------------# A5 c" }/ G" u
        // Method for testing that class has been reached
! v4 d, Y" e% f        //-----------------------------------------------------------------       
5 O2 D$ u: G* M) P. _! v, b' l4 I        public boolean AuthorisedUsersReached()" f" Y+ P: A! T, F- L7 s. Q+ B
                {
$ @1 r& I5 m' m" w3 x                        return true;                        , b% T8 e: U0 T1 @
                }
/ y# p* x+ F% @# t* c3 @                5 R. s' r; P: B' B% t' j/ _
    } // end of class AuthorisedUsers
* r# U' e  e' H9 E( U/ p//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
" [9 q4 W* d- ~; [1 q. a1 y' i2 AShanghai - 2007: h5 x% J, P1 v, Y* g: @
Assignment 2: p& N3 ~2 r: i. B: N
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)
& k8 z& Z" o' a5 Z$ h1. 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.
7 j0 j/ b. q2 YThe staff must be able to:: H- s' a0 W; r( E. M& n( i
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
& o! U* x: @/ y, C: v# a1. 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.
/ d8 n3 K0 H* L( B; p5 r! |7 ^/ Y: b The interface should provide a menu so that the staff can:5 C- e2 g" e0 K& R& }# l, i
a) Enter the names of the two Java program files to be compared
( b, v9 k* k% A/ U6 b For this assignment, it will be assumed that the two Java program files are in the same folder as your program.) Y) L' K2 B" w, o: v
** 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 ~5 W* c0 P& ?4 g
BSA104 Business Programming – 2007: Assignment 21 {/ R7 d5 R1 ~' p) H/ l" N
Page 2 of 5
+ z2 Q7 G, R! X' B5 h/ Z; M6 rb) Print out to the screen all the lines of code that are the same
( R# }% R1 M  f Include the name of the file and the line number of the code being printed for each of the two files3 z8 S: E" |$ D' f0 P- h
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
8 I5 [" H+ p1 L" o the name, username and department of the user
* `4 Q# Y6 P# @4 b0 B9 A the statistics of the comparison
* J4 `5 K3 o5 z1 i3 X: G- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
  t! b( _$ R  S; y the recommendation for further checking2 V  ], D1 m. @7 t
- 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
' o# F( G$ T* s$ c! O. t  n the names of the two files compared
! V6 v) `2 C7 N, l% hd) Leave the program (exit)
; j. C+ R4 x" H) V/ nThe ProgramCompare class: (Total maximum 20 marks available)2 Q3 c! a; r7 Y3 E+ 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). |$ b" f: }; c' @" Q
a) provide an error message if the files are not found or there is a problem opening them
# G3 d7 d- [3 M+ a! Ib) compare each line of code! d! P1 T7 ~- m! E2 n. {5 f
c) print out the lines that are the same# g& Q' j% K/ [- v$ }9 |- f. F! Y
d) count the number of lines compared / lines the same
6 ?  ~7 F, n  ?6 Q/ X; g6 ?8 hThe AuthorisedUsers class: (Total maximum 20 marks available); S& \$ {! P' L4 q
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)
* l1 I' y& U) d# Y! x9 w$ g" Y4. Provide methods to:
: w3 A1 E" a7 c' e% m7 z( C- La) 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
' z: [: _# t" }! b3 tb) return the name of the authorised user
3 o2 q# d# p! Q: }c) return the name of the department of the authorised user
0 @# V! ?9 }. D% x7 L- V; `+ OIndividual Data (Maximum 20 marks available)
# v; d! M/ s5 P5. 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., q  ]- x* V8 a7 y
Documentation (Maximum 10 marks available), J% Q2 ^& W% d; l
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.
5 O) y! y% r3 lBSA104 Business Programming – 2007: Assignment 2
# M2 U  F# b' p6 ]% }( ]  NPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了. c) F+ t# T9 e: T2 ^5 W; z2 ~2 `
不过你要翻JAVA的类库说明。你有下载没有?& i7 i' ^% b! }: V' Z
查询关于对比的函数。貌似关键字是contrast,还有compare
  n" I! }: A' c* Q; {; x" \; M; h& a9 M( f
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -- Z" _$ O  @( P9 p: n# Y4 [& q
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。0 v( g' [7 m( c- U
可以下载到的 是 jdk-1_X_0-doc
1 ^5 d0 W$ t/ {& ^! o" v* s' \2 a: E* w3 R! n$ W, M: |- W; D
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-23 11:56

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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