找回密码
 注册

QQ登录

只需一步,快速开始

查看: 923|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 / S& r+ p8 J; `: y- r; m 5 u' E9 y, x. r( T4 J" [, p/ j
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
0 _) s: I# e7 l6 m( Y8 Z$ Z' H+ P//  ProgramCompare.java         Provided by: DRS9 N- g9 |; |2 q& r1 d
//$ S) t1 d5 y5 y5 S' X
//  Program shell for Assignment 2- E/ V2 ]* o% h1 y
//& f' I" H2 f" `, v  \
//  Compares two text files line by line2 o* c2 P- ?/ }' Y' o
//*********************************************************************
7 Z$ B; L  \. R% p7 b+ ~9 _+ d
2 |  s( d6 j. A: r  x" r; T5 gimport java.io.*;
& X: O; f$ @. {
0 B' w# h, B2 U" Wpublic class ProgramCompare
% P9 `5 J6 y. e{* l% {/ O' _7 c# E
        //-----------------------------------------------------------------
8 z' h+ Q/ k) H5 e5 n9 t        // Constructor
1 g/ E2 ]! Q, j' U6 ~        //-----------------------------------------------------------------
' f6 W) _- |3 l0 W9 X1 C        public ProgramCompare()+ L6 }: y, Y: Q5 D% C
        {
3 l% S6 O0 }( i; B3 P! e( X9 a; {        }6 ~! F# Z6 o; J

; n9 C+ G/ T1 |3 _% z5 Y, M        //-----------------------------------------------------------------
9 L/ l# @0 B8 I$ ~& O        // Method for testing that class has been reached: v0 _6 \+ Z7 J) q
        //-----------------------------------------------------------------       
/ k3 X$ S% J% e) U
3 V& }  }* F: ~7 ]7 {        public boolean ProgramCompareReached()         1 T" `, N# K& T- a; Y" z$ }' Y
        {6 e' J+ Z7 Z* y+ Y- m$ y; l1 M# }
      try   x  g) w7 J# q5 n4 Y
   {           N# I( t( `% j) f1 E, S9 R# `* _
                       
# {/ d) y( _: x! D, L% x7 i                //********************************************************************! W/ q% I2 }& U7 j8 S
                // Try-Catch Statement is used to handle exceptions - such as file not found
& J; y$ x9 ?3 C* v# T2 w                // Reading the files will need to be placed inside a Try-Catch - just like this one!
+ C5 ~5 j4 S5 C0 }; G2 p/ q                // For more information see page 534 of the textbook
# O9 E: U* ~( B! i, R                //********************************************************************# l6 \% M. p9 f% g7 D6 q( g
                    
1 I5 X6 S$ p% |. m! D' Y        }
1 s! o( V& }% b2 s/ T8 k             catch (Exception ex) // Exception caught here and message displayed to the screen 5 S/ Y( n  J9 z. g! N( f8 o# `
          {) j* r* b( A) ~6 u% r" Y5 [5 B
                    ex.printStackTrace (System.err);
+ m5 `- c) f- J. H7 p2 `1 h           System.out.println ("Error message goes here"); // Replace this error message with your own          ; Y9 j. @) `9 I- g! N
        }
# c5 x: y( Y0 S' d6 T                return true;
( H# |) _$ b7 v$ T5 q5 S6 c+ R" H        }' `1 d0 p$ I2 r. |# b

. L" Z3 k  F7 i/ ^! w9 T} // end of class ProgramCompare
2 L1 H9 M, ~' }$ x6 F$ U2 Y  s( H' r; {6 ^' ]
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
! U* _: y  q3 B0 L& D% O* C. _//  ProgramCompareMenu.java    Provided by: DRS
- B! y& l' ^6 J# A7 \) u" b$ o//& C( v! T6 e: `/ q2 {0 r
//  Calls AuthorisedUsers.java and ProgramCompare.java, q9 G% h% P! |
//
( Q( b+ X& Y( h' Z% A  ?8 ~: d; w//  Driver shell for Assignment 2.
$ m: J4 v+ F4 Y! n- D2 V2 C, f//********************************************************************5 {3 t/ B+ b8 i; |

; o+ [$ j, X0 E& J4 b, }class ProgramCompareMenu
% w5 R; J$ h4 D& ~{; r9 O3 \# o* i/ x! }
    public static void main (String[] args)9 J2 t0 {0 g2 A7 b# y6 J) G" d* K
            {) s% _- A/ l8 j5 e
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable9 q% N9 D  [! o% U4 G& Y3 H
                ProgramCompare reached1 = new ProgramCompare();
8 I! \+ I1 C* a/ y4 P, D% Y                AuthorisedUsers reached2 = new AuthorisedUsers();       
' B# _1 v4 r$ ^1 p, L' ^: b- t8 f                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());5 e0 R! }# `" q% X3 K7 |
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        5 g0 Y- f! v* y
        }( ]# w, g6 P, p  X& }8 n) j* g5 j
}// end of class ProgramCompareMenu
5 w6 w* V8 G9 J" }, [/ K8 J# h  e* a' x& R+ w9 v- C
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************' D! b2 W' T3 s6 h
//          AuthorisedUsers.java          Provided by: DRS- |8 J* ^7 Y; t( ]
//               
, k0 j4 ~1 _$ u$ `$ C0 s5 t2 [8 c//         Program shell for Assignment 2& d! O6 o& t2 M9 n
//: w$ Y- L! J, X/ ~+ H7 V
//         Represents facts about an AuthorisedUser* A& W5 w% ~$ C9 e+ ?" @
//********************************************************************
; [- _! D% w9 D  Y
) ]4 b2 x( U$ Z0 Y2 g4 fpublic class AuthorisedUsers( ]- W9 x' E; l5 f
    {: A3 Q% f4 w2 a1 N7 {$ |

, p/ V; @3 N! X: _3 A3 L, l) G4 F        //-----------------------------------------------------------------
& J% d" g0 b' f$ b3 V: G        // Constructor% R" R; e1 B1 a* F' s
        //-----------------------------------------------------------------
9 U1 ~0 k$ |8 t1 H$ {" Q- O
; X/ c! g  L2 c& N' @' d        public AuthorisedUsers()" X- t6 k8 C7 v
                {
% ?; A# J! X9 D4 J" ^: p                }( J4 T* D3 I6 N% [. i( Y" N) u

$ \7 ?+ J+ y% J( j        //-----------------------------------------------------------------1 R4 L: A# v- u; N0 e4 }
        // Method for testing that class has been reached
8 N+ b3 Y; p" ~+ {6 M) i2 m        //-----------------------------------------------------------------        8 H0 @* {+ `: N: F) k' P
        public boolean AuthorisedUsersReached()
0 _4 y8 N; X- c& {                {5 e4 A$ i& m4 D% S) X
                        return true;                       
2 s) U3 F2 `. F, v4 _                }
5 o0 b5 K$ y& t/ ?* D5 S% ~% y2 f) P                $ B; V0 a% {' N6 g! h! b
    } // end of class AuthorisedUsers  ~+ j/ q- U" f. n' }# S; g
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming/ c7 V6 J( m# m3 t. b) {6 W
Shanghai - 2007% {, g& U- i' t. b
Assignment 2; X( m% X2 W0 X" H4 z* M7 l6 \
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)0 f& k# p, U3 h1 ], y$ K: S+ Y1 Y& }0 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., ~) M. [5 y! D
The staff must be able to:
$ i+ [4 j+ M* ^# `. y$ [ Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **./ W. R6 P3 V# c/ m- L0 t6 w. t/ \6 n
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.% E1 H# w+ z: K2 @& T# X
 The interface should provide a menu so that the staff can:% U6 W" q) r6 u1 e, l9 l
a) Enter the names of the two Java program files to be compared" r4 Q  Y& y$ q+ ^9 r& N
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.( \1 z: y& N( 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).
" F0 C# w. b6 c6 K! m- hBSA104 Business Programming – 2007: Assignment 2( g$ m2 c9 D( Z1 Z+ [
Page 2 of 5. t  ^# x7 M4 p3 L
b) Print out to the screen all the lines of code that are the same
4 h# G3 Q, b. p! O Include the name of the file and the line number of the code being printed for each of the two files
$ S  d  Z) O. Pc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared6 z4 l: E( U( m. p
 the name, username and department of the user
( `0 ]5 m0 X# d% l- x. i; t$ t0 | the statistics of the comparison
8 I( f0 t  C2 w- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
& D; K- \9 H/ C. I the recommendation for further checking& V8 z& \) }* Y! w
- 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
: E4 q) [" r0 ] the names of the two files compared  z: q- N( b+ [. P% N9 q! \5 d
d) Leave the program (exit)3 F. F3 f4 f: U+ h6 ~( x
The ProgramCompare class: (Total maximum 20 marks available)
. C2 \% m4 E2 n- e8 C2. 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)
4 ^. m9 @, G% L: y  e" h6 ?! za) provide an error message if the files are not found or there is a problem opening them, o: \, P+ H+ }5 x
b) compare each line of code
0 w, P: m; \4 R9 ~& [# Mc) print out the lines that are the same
  J0 V- ^6 S; qd) count the number of lines compared / lines the same$ A9 J+ e" o) W9 j  d5 P6 U5 m% u
The AuthorisedUsers class: (Total maximum 20 marks available)
- c' Y& M8 K% I3 E& e* W3. 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)  o2 O7 Q, B! x8 m! F8 h& l% L
4. Provide methods to:
' n/ m8 H% F6 \$ [8 {, b0 e! ]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& z* u& E: j' n+ L
b) return the name of the authorised user$ A2 B& P' t0 d4 j3 n9 ^! b
c) return the name of the department of the authorised user4 N6 R# e5 Z1 g* z' G( i9 ?
Individual Data (Maximum 20 marks available)
* A4 r7 ^8 J# Z! g5. 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./ `: w6 h  f  `& w% g( q
Documentation (Maximum 10 marks available)
' Y0 Y& v4 o6 z3 `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.
: I8 N& n$ b9 \2 t% d/ Y$ c- j) s  r# BBSA104 Business Programming – 2007: Assignment 2! s2 \, @9 Y4 q: g* z2 |
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了7 X" S$ }- h: c4 m; Q
不过你要翻JAVA的类库说明。你有下载没有?
" D. [' [) C; t5 Y查询关于对比的函数。貌似关键字是contrast,还有compare3 |3 e# q# v$ k+ _3 V6 F4 x

+ h) ^* [6 r: f+ U[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
! o4 J% n( |: k' P, H+ U! R痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。; y+ Z) y( @1 r( ^  @* s
可以下载到的 是 jdk-1_X_0-doc0 h) v2 _0 z# _3 X2 j! A# _

! J/ V5 D' f# u/ k[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-30 18:18

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

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