找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1729|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急- F* G" o* B( O* l4 ^ 3 V- l9 E6 f7 R) @/ O2 k$ |. P, o
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
. g/ ]9 W% O) C# r  p& k! j. ?//  ProgramCompare.java         Provided by: DRS
. k+ Y( ?. y6 K5 f$ ~- o//9 n/ d( e1 S* X
//  Program shell for Assignment 2* [7 P2 E& x/ b
//
# n, |2 o0 ]. s8 K$ A; n//  Compares two text files line by line
" N3 S3 I% L9 {//*********************************************************************
& X9 A8 q8 c1 Z4 i3 I0 s  z# i
6 ]# ^: g! g0 Z" |5 Vimport java.io.*;
  M$ d5 s" a/ _; m/ r
& n7 D1 d) p. _public class ProgramCompare
# D4 R  P# U) N! ?. e{
/ \. b# T0 j7 A" i  O        //-----------------------------------------------------------------5 [# z4 c4 _/ v: c$ X
        // Constructor
. o: q, k- E$ c& _        //-----------------------------------------------------------------  c, }, E$ W: Q' V& J) E9 B
        public ProgramCompare()
9 X' w" f8 N7 h/ P* u        {
" ?% {; S; {3 D" X2 A        }
, G) X$ C% c) J6 ~% t6 q6 ^! `6 E5 C& x) l  u
        //-----------------------------------------------------------------# [: S" C2 L, I& D1 O8 h
        // Method for testing that class has been reached" v/ ?8 E1 j+ a0 p! L0 s% X3 C) X! k
        //-----------------------------------------------------------------       
* S  j) A; I. F& s
5 z5 K7 Q. i) J- r- u        public boolean ProgramCompareReached()        
, E9 R- c( r; c4 W  D6 b4 l& o5 N        {6 r6 Z. Y* d2 w+ {4 @
      try 0 v8 E- Y( ~, r" e1 I
   {        
; w: ?% x  f8 l, X( i6 Q  u0 Y- Q                       
: E( {4 g$ d4 i2 m& Y                //********************************************************************* Q# ~/ X/ C. ?: I: K, i" @
                // Try-Catch Statement is used to handle exceptions - such as file not found
/ O8 A" S- o; i                // Reading the files will need to be placed inside a Try-Catch - just like this one!
/ k0 C4 Q0 g% k2 O) h. }2 g                // For more information see page 534 of the textbook% H2 v: E; W( ]9 u/ @' p2 y) K
                //********************************************************************+ o( h8 U4 Q/ c
                     # K) n/ N( I$ C5 \
        }2 d* r/ g0 b! q- q: k( m! N
             catch (Exception ex) // Exception caught here and message displayed to the screen ' T4 ?8 ]9 A4 m6 Z, f
          {9 K! e1 R8 N7 Q. g
                    ex.printStackTrace (System.err);! ?( ^) W$ `# t2 e1 t
           System.out.println ("Error message goes here"); // Replace this error message with your own         
8 F! x$ `5 o+ ?/ G        }
7 d8 w5 C- s% m+ r1 J; t                return true;; E* q! C0 Q' W7 A/ [
        }
& V# _( }3 c* R- S3 o
! t6 Z4 i4 E& |; E. C7 t} // end of class ProgramCompare
! F& g* g" b4 A8 j$ h' d* K( Y; s* X, e
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
# O  s, a5 ^4 ^9 F. o//  ProgramCompareMenu.java    Provided by: DRS
; Z% i+ h7 M/ ^4 k& e1 J% [- \//
" H6 U# a4 H. C4 C' \//  Calls AuthorisedUsers.java and ProgramCompare.java/ D- K# p9 A' B) B) D! g
//
' f' D5 M% K$ }5 \//  Driver shell for Assignment 2.
2 }: l4 M2 `. }9 W$ S6 g6 e. W//********************************************************************; y6 v+ E2 g1 H2 H
" ^5 P, d: M2 z2 u2 \
class ProgramCompareMenu' C& e" G* P! J% r5 c
{: P  k4 y! [2 J3 X
    public static void main (String[] args)) l! M1 X' J$ p
            {) b, n4 a* X2 \7 O5 d
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable( X) @  E0 k* O* W% \% _) ^
                ProgramCompare reached1 = new ProgramCompare();
2 f0 j7 V; x7 v: g. s, V: O                AuthorisedUsers reached2 = new AuthorisedUsers();          Q. Z: v3 A$ h+ `$ f
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());' l3 P0 Y) C2 [) q! T4 p
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        & R! y0 a5 z' O5 y
        }
6 j1 L6 H& f/ g% L; S}// end of class ProgramCompareMenu$ i1 S0 T  y# l) }, b2 C
. k! y6 S8 t% M6 }& u
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
' Y) |. w$ O$ F( @4 E3 [% ?$ f' l' Y//          AuthorisedUsers.java          Provided by: DRS
# b0 f5 y0 Q, a" X# B& _2 c//                , Q6 \+ S3 g; f0 h% P
//         Program shell for Assignment 2
0 R' s/ ~" I1 K% J: C//' o1 }; Z" h6 L. J
//         Represents facts about an AuthorisedUser  r( O) ]$ F. H& [/ B
//********************************************************************; w9 @4 O6 x3 ]4 `
# E* a& x8 ?# X4 q
public class AuthorisedUsers
, _- r+ p$ y* T    {" M: Q  ~) U9 ^! i7 J
1 v8 z9 O7 h' }
        //-----------------------------------------------------------------" F3 P( t' _! t; H3 C4 W0 s& O
        // Constructor. _+ u% s: r8 P" O% t+ Y
        //-----------------------------------------------------------------
2 a5 C4 I) p! ?% M1 C; O
  \# E. u7 T/ k& C$ k# H/ ]        public AuthorisedUsers()
  a9 r& j$ M% S- p+ r: K  b                {5 s! s8 O2 u1 {
                }
  k& A9 P% z% P" F* D5 s) c: z- Q
$ q: R7 @0 N0 H# ^        //-----------------------------------------------------------------
5 s6 a- S* Y8 N! ^- j* p6 |6 F& r, o: P; A        // Method for testing that class has been reached
/ I4 s# h3 `, A# k/ }- J        //-----------------------------------------------------------------        , U& {9 Z3 k2 M' i9 q
        public boolean AuthorisedUsersReached()7 B& p, P3 b: y% Y* y# E
                {# I  k+ a. u) }0 D
                        return true;                       
- A3 r, N4 s) L8 n2 y: @                }0 R6 N6 v3 m  y" _1 r: L" a% H
                , V/ p3 [; w" R* @8 }: e' G
    } // end of class AuthorisedUsers
2 p  b0 {9 I6 m1 ]. |$ y. W, ~//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming# C& ]& a& L) O# X* p  L
Shanghai - 2007
4 o% s3 t4 i/ i: dAssignment 2
0 z, x7 ]/ M: u. aDeadline 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)
$ c6 ^, s. b3 R3 t7 }( g1. 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.
2 m5 D% L" B" p1 _. [- w! bThe staff must be able to:: g' ^' N7 A# @5 I
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
$ y# w. [' |" E" b. N1. 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.: G+ S) N7 c% l9 a1 j" P
 The interface should provide a menu so that the staff can:
5 N' D6 z/ X3 Sa) Enter the names of the two Java program files to be compared  T3 {2 y, B7 j/ z" C( W5 x
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
* n1 Y1 d1 ~4 A' |1 e** 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).
) q; \; p$ n: E) Z. ZBSA104 Business Programming – 2007: Assignment 2
. v) H- N$ S( U9 h1 c7 ]Page 2 of 55 B! g  J. ^0 [& ]  @; s7 D# p  x
b) Print out to the screen all the lines of code that are the same
# k: `5 w: `# o/ h% m' a. Q Include the name of the file and the line number of the code being printed for each of the two files
0 j+ A8 A8 f. t7 ~' |c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared* V5 a+ R8 Q$ R
 the name, username and department of the user5 O$ ?$ V0 \4 D9 E. [/ W! ]; E
 the statistics of the comparison, W+ _! |- Y! b1 u( U
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different* {, a3 d- q# o8 M/ B
 the recommendation for further checking: Y$ ^' h0 H# ~  L3 g2 b
- 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& T% @8 G" q9 O, U7 E5 P
 the names of the two files compared+ P! [7 {& t7 v6 P2 c- t0 X/ y
d) Leave the program (exit)/ L: h4 G2 r" _# Q! r$ |4 _
The ProgramCompare class: (Total maximum 20 marks available)
' B/ T0 {+ e* B2 S" ?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)' s3 O) B; {0 W+ g+ ^" `; c
a) provide an error message if the files are not found or there is a problem opening them
) Q8 ~5 J% v& Z( C7 P9 V  m3 m' {b) compare each line of code
& [8 f9 \9 p+ Z0 N% Z8 ?5 l; nc) print out the lines that are the same/ j( M1 q3 O' e, T. F( H( r
d) count the number of lines compared / lines the same
! r5 S/ y# O) m6 A2 h, j& y1 s0 {The AuthorisedUsers class: (Total maximum 20 marks available)" N( ?5 {4 N, f% a3 i" 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)
, e. b/ ]* W1 V0 G/ r9 @4. Provide methods to:! w$ P; ]8 Y5 I$ [
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; e! r9 z' B& @3 g
b) return the name of the authorised user0 u8 b6 d+ ^; j; L0 n+ g
c) return the name of the department of the authorised user2 H7 r8 f4 I$ s5 ?. y' q3 E
Individual Data (Maximum 20 marks available)
) T: I, E0 z3 Z/ ]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.. \. _5 a) s, E, s. d; M# h4 l6 m
Documentation (Maximum 10 marks available)! z) C! u2 I9 k4 _+ a
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.% X) O( l( n, ?8 v' e( V( I2 k
BSA104 Business Programming – 2007: Assignment 2. a9 b3 D1 O& n0 x$ B$ y+ x5 m+ ?
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
$ }5 g  |0 }8 o, _, M3 j' G不过你要翻JAVA的类库说明。你有下载没有?5 w5 A) Y/ l0 H  G
查询关于对比的函数。貌似关键字是contrast,还有compare
& ~7 T$ M: C$ c1 h4 @4 |8 j  ?6 y  X4 a4 d: y
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
7 o9 e& t0 Q% B6 C; K+ a可以下载到的 是 jdk-1_X_0-doc
2 I: w) p3 f. f8 |1 q0 o2 I$ g# |: j# P  {/ D" D# u
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-16 20:35

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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