找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1325|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急6 v% ~8 t0 T# @ ' i' ]1 ^& B1 Q# z ]
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
* Q3 F$ t& b1 v- a//  ProgramCompare.java         Provided by: DRS
! Y; X: X  r! c" W- f//
6 s* F7 J3 w$ z! u0 y# P. U* C  p//  Program shell for Assignment 2; F8 _8 d# I; [- [' r" ^
//0 ^2 @' l' d2 |2 P
//  Compares two text files line by line! ^3 |# s, h  ~1 V
//*********************************************************************
" ~- s- v1 Q  s! k, Z$ g$ p: }: f
  t- ?& p6 ~0 @' nimport java.io.*;
# S# M+ [( {, u$ C+ H2 G  g: S3 _7 w; N, ?- U  I
public class ProgramCompare
- L) R" E6 c4 A/ i{
2 ~% I+ Q- t9 _: W8 E! b        //-----------------------------------------------------------------, @( F. ?% f* ]$ D  l
        // Constructor' g! Y' a+ A6 z' Y
        //-----------------------------------------------------------------0 x4 e" R4 c0 K$ @; K: D6 p
        public ProgramCompare()
, [7 F' B. o( I2 |: k        {3 f* y! ?$ k( w, n! V5 f/ Z
        }& k+ s) C: W' f, M1 {( y

# y4 I. e' k! w4 {1 p) I$ I        //-----------------------------------------------------------------
# U4 T. q% T9 @4 m# \        // Method for testing that class has been reached
  o- O- p7 O% y" u' ~# V        //-----------------------------------------------------------------       
  k5 f/ q# L/ j1 B
$ Q+ E. C- M" E5 e0 p        public boolean ProgramCompareReached()        
( ~/ O6 z7 U' P7 R. J5 m        {3 V, b/ D0 H7 g
      try
4 s( B" n# m- ?  X6 z9 v8 Y   {        
" ?: d6 I) t! b/ }( w                       
2 d  Q( ?' y% ]! {                //********************************************************************" W5 I' O& d9 w. A  c. M+ b
                // Try-Catch Statement is used to handle exceptions - such as file not found # Z. f9 x# c! A9 C
                // Reading the files will need to be placed inside a Try-Catch - just like this one!& U8 s  u# C5 v
                // For more information see page 534 of the textbook
. B' ]. ^2 y. {! s+ _5 }* }                //********************************************************************
- F9 P' I' g( ]% `7 z                    
  f3 h5 |0 h2 t" l/ j7 Y        }( U( a0 W9 Z7 v+ s% [3 T
             catch (Exception ex) // Exception caught here and message displayed to the screen
: a" N0 O. @1 W/ a% `9 |" p          {6 R2 q  c5 i( W- j. L! b# Y  J
                    ex.printStackTrace (System.err);$ X! e3 [. G( }  _' f
           System.out.println ("Error message goes here"); // Replace this error message with your own          5 O. M; O9 h9 U8 d% z
        }+ E# ~% b0 ?: P4 Y
                return true;
! ~/ n# l$ o# d        }
4 a8 P+ q- C/ j: D- D* ?- T% Y
} // end of class ProgramCompare
) P+ \0 V9 Y9 F
. {! c/ F5 A8 F& @% ?* _2 s0 P' G//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
5 [$ E  ?0 ^6 Z! ~" i: S7 K//  ProgramCompareMenu.java    Provided by: DRS
- c' Q6 K  e1 ^9 L+ h//, M+ s. u$ f' u0 W8 }: P
//  Calls AuthorisedUsers.java and ProgramCompare.java
- ~2 ~1 G+ Y6 b* b. D! ?+ r, Y//1 `1 N. @: Q' q# j; w
//  Driver shell for Assignment 2.
+ A3 P6 ~. R+ I9 \( H//********************************************************************  `9 V: G: k! K0 Z" k8 Q6 k4 V

% v, b4 i+ ?* G# ~/ Jclass ProgramCompareMenu3 U* h8 Q; f, v! h+ [5 N! r
{
4 ^& z, Z6 {8 ?9 Y    public static void main (String[] args)
1 E) N+ R1 U! Z            {4 V( e- P4 q& @- ?6 q; m; g  p
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable5 p* D; R* n7 O, O( t, ~
                ProgramCompare reached1 = new ProgramCompare();
' V$ o& y& ^# ?) L8 n                AuthorisedUsers reached2 = new AuthorisedUsers();        + r: ~; c8 h5 t3 Y  ^& P2 h
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());% z' u3 |1 B# v/ N8 V/ }! K& J8 C
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
2 n0 c- E; \3 M0 u        }
! f0 y, l, f! Q9 g}// end of class ProgramCompareMenu2 {6 _( M9 t7 n  C8 k7 e  U
6 i: h0 a; i4 `2 j3 v; Q, q, Y
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************2 C& t4 y( x6 ]% [0 S
//          AuthorisedUsers.java          Provided by: DRS
7 n* h7 [% l# a6 v0 M) d% |//               
; l1 `. p) y, w2 h//         Program shell for Assignment 2
9 x6 T$ N& D5 C6 l) ]; K//7 X4 Y2 g) i6 i1 S/ f9 e1 }3 y+ w
//         Represents facts about an AuthorisedUser
! @+ _) n: [& k% W+ e) I//********************************************************************5 j# {1 i! j- b, A/ _' D

7 B' a( b( A, ]+ R' lpublic class AuthorisedUsers0 l- a% k' _; t  r$ w
    {7 R: T; \$ A5 q& e' `2 s  S5 N
3 D1 _0 k; d0 @; _6 v8 u; F
        //-----------------------------------------------------------------
' x' ~: x! ?& h3 V        // Constructor
/ i; f5 h7 C' [5 x" X        //-----------------------------------------------------------------
8 W: a$ @& R5 g7 i. |; i8 R  \" p4 X8 [  n# a
        public AuthorisedUsers()
: N$ z9 E+ C- @; A6 ^                {
3 e6 b3 W6 L' Z; |3 j& y                }
( E5 R% ~+ ]3 |: \+ w* t4 ]+ \# y$ U
, D/ U" t; `' d$ @. h* b9 e        //-----------------------------------------------------------------
9 ?" j& c) O4 |$ Q. V- m        // Method for testing that class has been reached  a& q: Q, C! `, |3 M2 B4 p$ G
        //-----------------------------------------------------------------        2 u: Y( i6 {8 L/ n/ P; Z
        public boolean AuthorisedUsersReached(): l' `! [6 b3 O9 r
                {1 p6 D6 L  p8 B' C
                        return true;                       
: y$ H3 c4 Q, v                }
) K& a& U2 A( W$ G( ?+ T               
5 E+ ]& y% ~$ }' m( l. X: {    } // end of class AuthorisedUsers$ Q& @6 h1 h5 U- E" H
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming7 \  p3 `; N7 K% S
Shanghai - 2007
; d6 n3 Q6 R; }" E$ `$ bAssignment 21 \: _9 W( h$ f8 O' y6 A
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)# ]5 I" d3 L* F2 \
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.& S4 y: R8 ~6 M" F/ @
The staff must be able to:
3 p" F6 y1 y; v; R' ~. O+ q9 r% A Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
) o+ N. V+ x  m) q/ E1. 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.
1 ?/ M/ E1 y6 ?/ V& f4 j4 g; P The interface should provide a menu so that the staff can:
# p9 U+ y  Q0 _3 va) Enter the names of the two Java program files to be compared2 Q& \3 s, u9 @: c+ `7 W  z
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
# i1 n' v+ w- W- i5 g& e# w** 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).
2 T" l: Y; ^9 s! ~: i; J" pBSA104 Business Programming – 2007: Assignment 2
. r6 D, h7 g4 _" z0 pPage 2 of 5
) Z! I# Y1 K. O/ ^$ `b) Print out to the screen all the lines of code that are the same7 n6 t$ C/ `5 N8 h
 Include the name of the file and the line number of the code being printed for each of the two files9 H5 o- ^) c4 o, F; Q
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
# J) Z1 k7 r' }; I$ W the name, username and department of the user. `) O  a. y% F0 ]" ^
 the statistics of the comparison' `2 W0 W; K! o( l
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
$ k) B3 e- v6 w* K the recommendation for further checking5 r; v( e% G1 W6 \6 y
- 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
& _4 |0 r. B* \, C the names of the two files compared
+ T$ Y+ ?9 Y7 ?( [! Xd) Leave the program (exit)
; W& k: K7 b0 h0 \The ProgramCompare class: (Total maximum 20 marks available)
9 t$ @( h; C! d5 P2. 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)  q6 S9 b, R# d. d; ]: ~
a) provide an error message if the files are not found or there is a problem opening them
; f4 `) h3 t; t% M0 [' K: Ib) compare each line of code
5 N, }2 x! |1 e4 u3 e, Ec) print out the lines that are the same
! }  F3 h, a9 K3 G' td) count the number of lines compared / lines the same
) Z6 k  Y% K' ?, e4 CThe AuthorisedUsers class: (Total maximum 20 marks available)8 F) q5 A3 ~5 U
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), a; W0 m/ k* x. r, F8 h
4. Provide methods to:/ G! }6 Q& X8 X6 s3 u8 B+ b1 h, R
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
5 w& s, M; z( B! ?, |( Bb) return the name of the authorised user
" J' ~3 }  e9 C% Q% }% ^$ Z7 o# Gc) return the name of the department of the authorised user
. \0 N: B: P2 yIndividual Data (Maximum 20 marks available)# P, m( v# ?0 t' o& w2 m) V$ G
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.
1 f  K5 Q$ o4 U# @" c1 a, e# `Documentation (Maximum 10 marks available)
# y2 z% f7 H3 ?6 V6. 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.8 r  x! T/ {- Y
BSA104 Business Programming – 2007: Assignment 2
3 i/ A* p' `0 ~' d% b6 ~Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了6 w6 C0 s3 j, _6 j
不过你要翻JAVA的类库说明。你有下载没有?
- z* A( n, q1 R' c9 q查询关于对比的函数。貌似关键字是contrast,还有compare
0 p: g' s( R/ \8 A7 f9 _+ [; V3 F* m9 K; \
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
6 m( _6 R# \  u# b. K' w( ^痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
8 R! Q* x0 k3 I5 A. y9 V. Y可以下载到的 是 jdk-1_X_0-doc" j2 r: a/ e5 w% Z5 `

6 Q9 t) k  ~+ Q[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-29 05:13

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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