找回密码
 注册

QQ登录

只需一步,快速开始

查看: 930|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急7 o% @$ `& U9 V, O! K; l" { 6 ~0 d8 J' k" v4 z+ u H4 U' W( v
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
- U) [  L7 Z! C3 M. U# e- I; G7 y# l//  ProgramCompare.java         Provided by: DRS
/ [7 U/ U! g# f- q* }//
" \. V+ [5 G( H# p//  Program shell for Assignment 2* [7 Q3 c1 h/ Z$ e! ^+ y1 G' s
//
( a1 U  y9 I9 @5 t( N//  Compares two text files line by line
- u: E2 y+ r4 K! H//*********************************************************************+ b! w6 P. j+ ~6 p: n) k

7 p# B% i3 E: g. h' Oimport java.io.*;7 d) z/ ^( h2 ?

0 t1 n0 ?1 k% _4 [; o2 jpublic class ProgramCompare
* h* ?6 J7 }, C{
5 v" C2 C$ W9 g+ Y        //-----------------------------------------------------------------
6 T: [+ S# h; E4 W9 n. B) _1 ~        // Constructor
- W3 `& F/ v, r2 F0 k" I' _        //-----------------------------------------------------------------/ W, P7 f( A: O3 K
        public ProgramCompare()
$ E: g% m! m; x4 u) H        {
4 |5 Q( \$ \" F4 B        }
: N! n, U* v. Q$ }9 K! {0 c8 t
  ?7 x4 V, H- U. W; `5 x        //-----------------------------------------------------------------
8 H9 D/ U( A7 H; ?0 x        // Method for testing that class has been reached
% n$ E- _1 ^  `4 {        //-----------------------------------------------------------------       
/ G5 ]" n9 O% u! j& x
8 g. V  [+ h& f9 J        public boolean ProgramCompareReached()         + p, V  G/ v4 A
        {& x) d3 n! c  w( @
      try
* R, [  T/ w. ^' I! q   {         0 I8 B( |2 ]+ |- t+ Y2 C
                       
* O/ {; y- o* S$ ~                //********************************************************************
. H; Y% t! l$ K  k$ s                // Try-Catch Statement is used to handle exceptions - such as file not found
( Q- F- O7 V0 r* V/ R                // Reading the files will need to be placed inside a Try-Catch - just like this one!
6 i+ i9 P0 l5 {. ]$ n; l                // For more information see page 534 of the textbook
0 r* B& j# d' b3 [# t                //********************************************************************
5 k  ]6 ~8 ~* `. n                     9 W8 i% f6 {; W) F7 @. f5 q% w+ z
        }
: |, \4 e/ ~2 M9 c7 L9 A  i3 [1 d             catch (Exception ex) // Exception caught here and message displayed to the screen 7 n5 m  y2 g' p6 q# @' U
          {5 Z% s' p+ U+ s" Q, r' a* W# A
                    ex.printStackTrace (System.err);
1 u0 [7 u& ]( b) }. ^  `           System.out.println ("Error message goes here"); // Replace this error message with your own          + D/ p  a7 i. [0 Q5 ~: h; c
        }
; I/ q/ U8 t, h5 Q4 T3 |/ N                return true;- W8 w/ }" W8 u* z! M4 z' P9 C
        }
6 J; ^  W! d4 I; O1 {7 j  r4 H$ x7 t* L1 o
} // end of class ProgramCompare7 ^% i+ U- U6 M* a) A# S

" m* \6 c0 Z. j2 d0 Y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************$ Q, {( \2 p  {  Q
//  ProgramCompareMenu.java    Provided by: DRS
8 H3 l) u6 C! J9 w//
2 R# }1 J  m9 f+ ]# T//  Calls AuthorisedUsers.java and ProgramCompare.java
" }1 I. h. x' V' b  o, \//) y. W% `. z3 p3 ?- K
//  Driver shell for Assignment 2.
- s; f- W: u7 d6 h# \8 T2 z//********************************************************************: z/ K* F. K6 n4 @& l9 {
$ B3 B+ O' K5 d: U& r8 {" y
class ProgramCompareMenu0 k  R; C' I) |! b' C+ D
{3 r7 j6 T0 p/ u, G
    public static void main (String[] args)
6 {: e. F) r9 R+ `. @            {: R- _  y' E' K* B" ~8 H2 ]
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
' B( g  p, n6 E! H' Z' K- f' c: {                ProgramCompare reached1 = new ProgramCompare();
; ^7 i1 x0 g, N$ q+ x8 c                AuthorisedUsers reached2 = new AuthorisedUsers();       
: b0 _* K" e: I( i# G  h                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
$ Z# c6 e; F1 R% I9 j* t; [                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        4 I# ?4 S/ b# W8 d
        }
! g' s1 s6 r! w3 d/ i1 M8 m8 ?$ Y}// end of class ProgramCompareMenu
5 L+ C8 m8 R. ?5 H$ A
) S& U; l8 Z2 m* J% |//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
6 b# _! b/ @* L' w5 Y. e//          AuthorisedUsers.java          Provided by: DRS
4 D/ e+ x, t0 ]  m* ~//               
" Y% \4 d/ Q8 t+ Y5 e//         Program shell for Assignment 24 s; L. v  ]' T' l: X
//
- y: H# T0 m5 x  r  T//         Represents facts about an AuthorisedUser- y4 n+ m5 n! h1 G
//********************************************************************4 f) ?# V8 {) ?: P/ H2 _

  r" @7 y8 z- @7 Y0 tpublic class AuthorisedUsers1 l# d9 i$ N) X7 c5 e1 K
    {
4 @% {8 ^/ U# l- K* E9 C1 l( W/ z
/ l! M- y( R  O  @4 ?5 C        //-----------------------------------------------------------------
! `5 o! S& J3 D0 V! W2 C; U        // Constructor
9 B# s+ b4 n: R' |; d0 C; m0 B        //-----------------------------------------------------------------
+ l1 j* T7 `+ o6 O4 s
0 o: ]; Z( j5 h" ~# B        public AuthorisedUsers()
3 S: A/ Z1 `+ B8 c4 A0 C* `% x                {7 k& r5 v4 ^3 i# a2 x" }
                }& \$ `: T$ Y9 X5 b$ x8 B3 ~6 }

, s0 a$ c3 R4 R        //-----------------------------------------------------------------
5 R6 c2 J( C7 q" t# b        // Method for testing that class has been reached
& n8 M) ]9 U- q        //-----------------------------------------------------------------       
* U/ b5 B! K# l- W# c! w2 |4 c0 [        public boolean AuthorisedUsersReached()
. T/ q: U5 v/ ^' b                {- X& T; \) D8 K3 R0 s# L3 ?
                        return true;                        5 }, J3 q  V$ u2 o
                }+ s# z. A. o! D) w7 Y. ?8 S
               
/ r0 l& P0 z0 u* b6 N    } // end of class AuthorisedUsers
6 g* o3 _0 d4 D//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming' ^" Z  b9 D7 O
Shanghai - 2007
4 ~# ^$ Y. H2 J  n0 PAssignment 20 M: P4 M" h% N  S
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)9 w; Z; X2 l. c! `+ T% ^7 ?
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.
0 {' g# D/ Z3 Z& vThe staff must be able to:7 N1 i( p4 O, ~4 p# Q* Q0 m
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.+ R  \! U' ?, t7 {" @& I2 a
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 E7 Y+ V/ p6 }5 [
 The interface should provide a menu so that the staff can:
' s  U. w3 H. Q0 v. L. X  Ya) Enter the names of the two Java program files to be compared
1 ^8 }) H2 g7 l# Z$ w1 z For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
3 M& J# o3 f& _6 S1 g7 A** 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).- b, t8 p2 j6 f( W3 n& ~2 o6 S
BSA104 Business Programming – 2007: Assignment 2+ I+ m8 m% `# l" O8 G
Page 2 of 5! T- x! h3 C8 e: V" {% i9 B6 u
b) Print out to the screen all the lines of code that are the same/ ~3 C+ ~, n$ s. y! V6 Y
 Include the name of the file and the line number of the code being printed for each of the two files$ u4 m1 e4 y" c( F5 b; _! m- r
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
0 B1 s3 Y* i) n" p2 K6 k# \  S the name, username and department of the user
, g0 G/ a1 d  E. q) a9 r* F the statistics of the comparison/ Q& P5 H) L1 z
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
% a. ?% d+ f! l  {, } the recommendation for further checking: U1 y6 q% F! e2 L' V0 N/ g( 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
5 z0 u9 ?2 S6 p5 d/ D0 m# u9 R, y the names of the two files compared  t5 q) e# R8 w8 e- N/ g/ _
d) Leave the program (exit)' K  g. n% h3 n! ^1 K
The ProgramCompare class: (Total maximum 20 marks available)
! y' v0 I  h, j9 }: ?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)
/ F9 m! B& V, V6 ^% O6 C2 ea) provide an error message if the files are not found or there is a problem opening them
* _" }0 F3 G) u7 j: u% k( `b) compare each line of code! j# |9 v5 L- }" h" y/ ]" a* B
c) print out the lines that are the same% o1 ^! I+ Y2 B, [% i" R
d) count the number of lines compared / lines the same
. T- O5 i5 T8 {# i4 U4 r7 EThe AuthorisedUsers class: (Total maximum 20 marks available)% z& M! T- Z' F% o
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). M( m5 X7 k$ c. N' m; p
4. Provide methods to:; i) w, ?" u6 P8 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
; V$ ?2 P! y: C: q9 tb) return the name of the authorised user
1 F4 f0 |( G+ ]7 E% \; b4 J& J1 m" qc) return the name of the department of the authorised user2 F, u  N9 V0 y. ~7 [
Individual Data (Maximum 20 marks available)
7 N' i8 p) ~+ ^3 Z: L. |% t6 j5. 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.9 }; L% {6 O9 i$ W( `
Documentation (Maximum 10 marks available)
# j) M/ ~) c6 D! R+ r9 ~0 f  g/ ~* r6. 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.# W2 [, A% X) P
BSA104 Business Programming – 2007: Assignment 25 Z# {  c# m2 h! @0 N! V: v! _6 z
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
2 K1 P* j6 a8 @- @不过你要翻JAVA的类库说明。你有下载没有?9 x4 @% M7 y  P3 \% W
查询关于对比的函数。貌似关键字是contrast,还有compare) I' |$ ~/ Y/ {, k0 X; C

: s) m  j7 ]3 s: j$ I[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
( u* q8 L5 j) U" p0 ]6 I2 G痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
. Y1 ^, r& o! u可以下载到的 是 jdk-1_X_0-doc1 N- P0 v" s3 _" [8 O/ P4 r  D
( d6 A7 V! l5 M! y/ J% `" l
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-7 12:33

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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