找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1811|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 1 _/ {' L+ p; h F* W) y3 Q) ]/ v% J : t0 i5 }/ J) M8 S, P! k
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
$ k6 Q8 T6 E. u9 p# d8 e//  ProgramCompare.java         Provided by: DRS& h$ u3 I8 A/ d* m% j- l
//
3 u$ q! |* Z9 |! I//  Program shell for Assignment 2
% P" \9 y$ S& c) \4 w/ u//' G" h4 o) j- y9 Z% D, F
//  Compares two text files line by line- h3 }% N. ^4 y$ ^' D) T4 P
//*********************************************************************
$ h0 L0 K. c  Y5 F* D
3 C" ~* h$ o; V  O9 }import java.io.*;3 |8 o* G5 k3 }
: Y5 \$ x5 i' a9 a  C: C
public class ProgramCompare
: T1 W7 G& n8 C$ K$ T  j& Q{
' r  ?4 L1 t( s        //-----------------------------------------------------------------2 I9 y; P# I1 R3 x' L
        // Constructor
' Z$ K5 T% z. R% w2 z9 t, ?5 Q+ T        //-----------------------------------------------------------------6 \, D& r% A9 `5 \$ x5 w! B
        public ProgramCompare()
- c9 f1 @  J) e3 ~. x. q0 c/ c! q        {2 t" y7 A( |; A2 W( D2 R4 J9 O
        }7 y/ u: K/ b- {

  w* Z& d* b' c        //-----------------------------------------------------------------+ H; [5 {/ m* h; r7 Z$ i
        // Method for testing that class has been reached
, H2 P5 D( _" ~4 _. t        //-----------------------------------------------------------------       
1 D5 }  M  I) S$ Y1 E. J
  {6 o4 }) W7 W; C: i7 o: a        public boolean ProgramCompareReached()         7 ^- O( O4 h1 i2 _$ [
        {
! i/ K; r1 w6 o$ R& F& F      try
" q6 `6 D2 ]: i4 U( J   {        
. _# O* N  X( c/ _                        * z  Y. l* c9 T- c6 |. r# q$ ^
                //********************************************************************
2 a0 ^6 ~2 B8 C0 k                // Try-Catch Statement is used to handle exceptions - such as file not found
6 y, @! q9 n) p& f                // Reading the files will need to be placed inside a Try-Catch - just like this one!
, _' u% y- j. T& k/ \+ V4 U3 N                // For more information see page 534 of the textbook0 E  O) O& F0 F) n/ l* U
                //********************************************************************7 a7 x) W2 h6 b1 U
                    
' L2 |, z5 s) l1 R; V* @        }% N% D) M+ S2 y5 l
             catch (Exception ex) // Exception caught here and message displayed to the screen ( F$ B. ~, U" y% b
          {
7 k  j7 k5 ]: {* g# z/ H" O                    ex.printStackTrace (System.err);
9 k  t$ A9 M; A           System.out.println ("Error message goes here"); // Replace this error message with your own          $ z8 l7 @. @3 m# O; ?/ @! J+ f& I1 ]
        }3 L3 ~* }# E1 d
                return true;  k% Y; o# G3 ], ]) j
        }
/ F" W4 d  I0 x) i% t$ R, \0 T, v! @9 d  G8 \9 ?# S- {4 E; a1 @7 U7 b1 _
} // end of class ProgramCompare
. T) ^2 r3 j$ L
$ I9 L3 i2 R# W/ |/ I( u, s  I//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
. d3 w. z0 n5 C* j; O, K& j% `//  ProgramCompareMenu.java    Provided by: DRS
: L" a3 K/ u. u5 W2 Z4 z0 [* N. r4 A//
" o( ?" H7 W. ?/ v. b0 a//  Calls AuthorisedUsers.java and ProgramCompare.java
+ |7 \' d; a) |//
9 F6 C( b+ U) e; R//  Driver shell for Assignment 2.
5 H3 \/ Y& I* B& J//********************************************************************: C& v) K. K( Q2 a% t5 P& _

9 C. G( E- I1 |3 [+ @) N6 Z) Lclass ProgramCompareMenu% Y1 s* v9 ]) L2 Y% ]1 B
{
: U. g9 c' `# M7 f; g- L    public static void main (String[] args)4 J+ f- p/ |9 H2 [& N7 p  Z
            {2 ]& ?6 t" ?, e" U: D# U0 O
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable: K* ~  V  @, B& ~
                ProgramCompare reached1 = new ProgramCompare();
( _& _8 h( r# @: l; C                AuthorisedUsers reached2 = new AuthorisedUsers();        ' H) w7 _8 [* O7 E- J2 e8 m! q! k
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());' G  R' U7 E5 r! y" x
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        $ Z$ o9 \* r. B% @2 d7 E0 [# C' d
        }
) D) t: z1 U9 k# i3 g  {. S9 I}// end of class ProgramCompareMenu4 g4 w7 H# s) |" q. t
" ~; C  H: b7 B+ F
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************- i2 Q! G% g, S' e
//          AuthorisedUsers.java          Provided by: DRS
3 J5 s) f' p& x6 j6 ?5 [' t2 Z: |//               
5 z1 P. K! L+ ]6 M# E9 e# u//         Program shell for Assignment 2- G9 w; j( ?2 j% |
//. `+ b/ c- X0 x( {$ Q4 d
//         Represents facts about an AuthorisedUser
' r( I; f, S; }8 I3 e# c9 j//********************************************************************* Y/ V' E- q& r5 Q7 b
6 |, ?! N1 {4 Z* T$ d( l: U
public class AuthorisedUsers. B" A* A6 p5 d/ N; S
    {
9 J8 j* I+ W# I% h1 {0 H8 m3 j) r' O; l9 |  m, l5 w. }( n+ d
        //-----------------------------------------------------------------3 m/ X, S& J' ]3 h# }8 C, B
        // Constructor# l: H% p/ z) |4 t0 Z( S# P5 S
        //-----------------------------------------------------------------; q9 Q0 I) e1 W+ d. _
8 O. P" O* X" Y0 N
        public AuthorisedUsers(). e* }6 @9 ~% g" E7 {1 [
                {+ V; Y; R7 g% z  W
                }' z& s3 @9 s& {5 ]+ [6 ]6 e8 E- E9 ^

6 a% ]* d8 f1 B5 n3 x        //-----------------------------------------------------------------7 d& A( c, C1 \
        // Method for testing that class has been reached
  z2 X) E" n* s        //-----------------------------------------------------------------       
" X- s2 J. P! v1 {' f9 Z$ n+ A        public boolean AuthorisedUsersReached()
4 v* _( c* f9 R3 Q* b                {0 \2 b7 k+ _5 [$ I3 R8 C" F
                        return true;                       
; l/ S6 @+ s/ B. r# {( _                }
; y4 ]: k% r; d  u) w0 [4 Z               
6 l+ q7 X+ U5 r& H2 y    } // end of class AuthorisedUsers
, v& _8 t) |9 O' S/ t; U7 D//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming) `& S! M# S: z' f9 r
Shanghai - 20076 Z3 L0 m; v! ]) [9 {
Assignment 2  P! o7 _+ X2 c% G
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)& t- ^* z- O2 V( x% [
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.
/ I4 N, U4 h3 z2 SThe staff must be able to:4 d2 k% o7 g# k( h1 @' R3 E8 ^( b, ?
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
2 t8 L) ~/ \, \. e4 i3 z$ u1. 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.4 I6 _* u( i: X+ r' F' c" W7 d
 The interface should provide a menu so that the staff can:
6 t- Z: ^% o8 A0 H) Fa) Enter the names of the two Java program files to be compared: @7 X- o: {" W
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.* k. W4 Q0 A/ b6 R
** 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).
! F: |/ u" V4 S% |BSA104 Business Programming – 2007: Assignment 2
& F5 O$ x, `9 _' u$ vPage 2 of 5
/ X+ D: U2 T* k) j7 i% R3 X) tb) Print out to the screen all the lines of code that are the same6 K8 j% Q4 N+ V9 R# e  N
 Include the name of the file and the line number of the code being printed for each of the two files
" c, I; s6 {* z7 q7 v0 W8 Nc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
& B( p/ y' _& u. c the name, username and department of the user
7 d4 X* C/ S/ c# c8 T; s the statistics of the comparison
+ e: V, R0 O6 E2 E3 J- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different) v! }% g2 ~8 S% [' r
 the recommendation for further checking
9 m7 s; ~, }$ d* V# ~- 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
0 k. x5 [2 b3 x) h. L0 ~) f the names of the two files compared
! |' A! ?1 L4 P9 c* x* Q$ K( Id) Leave the program (exit)
% R* A0 y" J2 Y: YThe ProgramCompare class: (Total maximum 20 marks available); o$ x/ D) i4 _; v" Q7 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)) e1 ^3 o2 w6 Z4 z8 g7 ]
a) provide an error message if the files are not found or there is a problem opening them
; A2 n7 i6 d8 y. |b) compare each line of code) \, ]! h; N8 @8 s1 _! l! s$ B
c) print out the lines that are the same
; f. l% ]6 j" c- Z( Xd) count the number of lines compared / lines the same
8 }7 [! t+ q! i# c. t7 cThe AuthorisedUsers class: (Total maximum 20 marks available)" Q. O8 l) H" O- Q8 I5 Y
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)2 Z1 t2 J2 `" Q) C! m' o' N
4. Provide methods to:) f) ^& z/ @6 H0 W6 v
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
) X5 Q$ T0 s2 O% G3 H' u; a( }% kb) return the name of the authorised user
/ e0 E1 o0 g8 _c) return the name of the department of the authorised user, P4 ~/ W' A5 }
Individual Data (Maximum 20 marks available)
" a& s2 a: Z' A3 ]6 ?$ r5. 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.2 ~" m5 w+ G+ r" V+ h
Documentation (Maximum 10 marks available)
+ O1 d; U) q5 D6. 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.
- V* r; m/ r" o, O# s7 ~8 rBSA104 Business Programming – 2007: Assignment 2; p: h! H1 e) `, M$ S7 T
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了& L! J* t. B" \$ e
不过你要翻JAVA的类库说明。你有下载没有?0 |: Q. c2 U; W! v, ?2 H: A* a1 a
查询关于对比的函数。貌似关键字是contrast,还有compare: T0 P8 J( q. F' X1 Q( }

, ?  f. U  l" T+ L: R" ^[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
: B! Z# Z1 j* H( v可以下载到的 是 jdk-1_X_0-doc
: v; J+ {# f2 f8 m' ~
! Y0 c$ M2 S( _: }: K& F2 Z[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-10 16:47

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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