找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1673|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 * e# R6 x# H* w7 V$ F4 {/ }& j3 S- Q0 d. ^8 ^
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
- r! \" V. a, `, R//  ProgramCompare.java         Provided by: DRS! q! J2 Z! Z! d
//+ ~( e+ h4 s6 C# R! M
//  Program shell for Assignment 2- K3 M; l1 u* E4 e0 T
//( o) R1 ^) p4 |! ]
//  Compares two text files line by line( q3 v3 K6 i" l
//*********************************************************************
' X( d7 W# ?1 L) c8 o/ ]
+ p4 _# ]% \, Vimport java.io.*;
6 u5 k7 {- V7 }" S5 T! U0 K* s1 X) d. x! n! s& U, [
public class ProgramCompare
3 ^; S# _1 I. k: o- a; ^5 ?{
% }2 ]3 Z3 ?: s0 N: L        //-----------------------------------------------------------------: _7 V3 a; {7 w8 ~' g. Q
        // Constructor# q# \9 P$ O6 J  ]( {  P, V' H) B9 T
        //-----------------------------------------------------------------4 u# h+ X) y# Z. v+ x# [/ V. M+ g
        public ProgramCompare()
" ]; W: a* U) q8 W: A1 G+ b        {
( \: g/ d, F! ~2 n        }3 J8 Q# O: c8 B! i
1 ?$ X2 \, r1 a3 Y& F" H
        //-----------------------------------------------------------------# o/ O# n+ T+ B; F5 s$ f% r1 h
        // Method for testing that class has been reached7 ]& o3 ^- O# ~" i: u
        //-----------------------------------------------------------------        - ]5 ?; F8 r8 ?  W  i$ i; q  \

. M8 o8 r1 H1 y/ b- P        public boolean ProgramCompareReached()         : p- i. [" N/ s, _
        {
: n* f: y8 A: o" q  @$ e      try
5 h+ X* C2 {) p; q+ A& ~   {        
$ `2 y' a7 Q" C6 m) u% {, h                       
3 i) p+ h9 n  s' ]. `                //********************************************************************
+ h  `7 o, h% B; u                // Try-Catch Statement is used to handle exceptions - such as file not found
! r3 ?# y  H  A- k# p                // Reading the files will need to be placed inside a Try-Catch - just like this one!
# G1 K$ Y  q1 ^2 R                // For more information see page 534 of the textbook; w8 V: p) V, a. h* m' k( j
                //********************************************************************) V2 `2 i2 K) `- _
                    
$ w0 d6 M2 P0 U" w9 N        }! Y. _) L# ^: W- h5 ?  }
             catch (Exception ex) // Exception caught here and message displayed to the screen 0 U6 [0 O0 k' I; h( X& u+ k: m
          {! I+ Y  D$ r! G% J
                    ex.printStackTrace (System.err);" M2 y3 W7 z) V
           System.out.println ("Error message goes here"); // Replace this error message with your own          * I0 @! \; i2 w/ `9 o+ X# V, K* M# |1 O
        }" N1 O: o1 ]5 R& z* w: T  y/ M4 N
                return true;
0 G3 R' L6 m" b! b' r        }& K; J% A! n2 T0 F7 f
3 ?6 O; v. a% V, w
} // end of class ProgramCompare
- t; O' P: ^5 N5 C" {9 ]  x- Z4 `' g6 ^  [& m- h. \
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
" x/ q( Q& x9 R- s" [  N//  ProgramCompareMenu.java    Provided by: DRS
, X7 l7 w8 Y) @//
1 I8 y: X: A! \* Y//  Calls AuthorisedUsers.java and ProgramCompare.java
/ q) n: M2 F6 ]6 w1 s+ A& I: p//
6 Q, u( J: J" c' K//  Driver shell for Assignment 2.- B+ r  o* F# q5 G( S7 n4 r' ?5 n
//********************************************************************7 I9 ~& Y0 d; N) H( T8 ]* B
" j3 p( O8 `  G/ c  S
class ProgramCompareMenu
5 d1 F0 B% D8 u, n# f# w{, G. _  f& M, w5 M% P/ y: M
    public static void main (String[] args)
4 a2 M. Y2 }! _) Q9 e            {, [6 ~: g4 G; R7 c+ n
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
5 t  P' K0 o+ E& `3 O! n& S- A( |- g                ProgramCompare reached1 = new ProgramCompare(); : _( E4 n3 X$ _4 f8 A
                AuthorisedUsers reached2 = new AuthorisedUsers();       
- X2 K% a. g$ ~8 V8 a                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
0 [6 u; x/ E, Y- G' n/ Y                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
( g9 F3 l( Y! a' A! l6 S+ `- `        }
+ C3 b( _! J( I$ P0 }/ y7 @7 C# S}// end of class ProgramCompareMenu
* d2 y4 j; O0 I8 c) ]' j; Z4 n; ^" {- M
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
2 o9 Q* z+ `# I/ C) V//          AuthorisedUsers.java          Provided by: DRS7 C8 r! x; b5 @. o
//               
: b3 m. a2 W5 p6 G//         Program shell for Assignment 24 L+ a3 c9 \6 _
//
, V* r. p- @. A0 V4 q" f//         Represents facts about an AuthorisedUser, y1 h# {& \1 s; C3 X
//********************************************************************
. i  T" w$ `, o  }+ }- K' }* }  V( Y. Z
public class AuthorisedUsers
0 h, o% n) o9 f6 h% x    {
! X% Y$ H+ {# ~+ \" O3 P
, N' c3 g; a. e; G7 ]* \3 M1 `        //-----------------------------------------------------------------! I- l6 @) c: G
        // Constructor4 \7 [* A/ v* ~: M) |! t/ ~
        //-----------------------------------------------------------------* `! X7 z( ?  G
* ~( ^, w3 T* a
        public AuthorisedUsers()
* j: [* }2 I! X% P- I  G- d' w                {: b% s. o8 y1 _$ R" z/ @
                }, Z' l7 l' l& n$ j

3 U: y2 u6 y# \% z# {, S7 d% U+ {        //-----------------------------------------------------------------
  M: x/ |( R* x$ P        // Method for testing that class has been reached
% E1 o3 c/ g6 D% R# y        //-----------------------------------------------------------------       
+ m3 q* a% Y% H: ~8 k        public boolean AuthorisedUsersReached()9 L! I" i% }# X" E9 V3 g9 T
                {
8 T3 _* T8 G& H% X3 j6 s                        return true;                       
* F3 H7 ?3 s+ F6 M5 |                }" q2 U( F( @8 O
               
1 W" ~2 Y' t3 Y6 C$ P1 D- N, \( q2 w    } // end of class AuthorisedUsers9 Q* z1 G6 X" S7 }* B5 a
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming2 i" K5 {% x3 s0 n' D
Shanghai - 20078 I& m5 ?( i! U! k7 _
Assignment 2% U2 z' h* R. i/ Q7 ^
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); ]7 p# r1 }5 I$ B9 R( _* E" I
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.  S; K/ E& l) L3 T1 M- M
The staff must be able to:6 l. X6 v0 Z7 ~
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.0 g/ v2 ?9 W' m8 T# [) w5 i' C
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.$ m/ _# X9 g" ?( ~' K; p
 The interface should provide a menu so that the staff can:  i3 A) m' A8 c9 C
a) Enter the names of the two Java program files to be compared
2 v$ n; S. @4 f% ^/ Q& B, O For this assignment, it will be assumed that the two Java program files are in the same folder as your program.+ D( y5 p5 t+ d
** 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. F* U3 B! t1 w/ RBSA104 Business Programming – 2007: Assignment 2
8 ?" V$ K: Y, |. HPage 2 of 5
* w; h6 G) ~. ~4 L9 {- |b) Print out to the screen all the lines of code that are the same
" |$ z. [6 c, q, \  o- ? Include the name of the file and the line number of the code being printed for each of the two files
- g& v6 w5 b( ]* Z# Lc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
2 P$ t5 x0 R- @ the name, username and department of the user7 \: r- s9 X$ i
 the statistics of the comparison
* O: a6 w" V2 M0 _; _  s- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
" @$ t0 g* P& G5 T the recommendation for further checking
8 |/ a2 M' I+ y. n, O. j% u, H% |- j- 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: V% c( l( P. m8 Z" w
 the names of the two files compared
: }6 ?1 [/ o$ ^0 h0 D+ bd) Leave the program (exit)
/ C! p# P4 i4 `+ M! N+ VThe ProgramCompare class: (Total maximum 20 marks available)
  Z  Q$ j( m  b, v6 L/ \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)# y- r, t2 Z8 c
a) provide an error message if the files are not found or there is a problem opening them
) h) Z% R) I% e7 o5 `0 y9 f3 h9 wb) compare each line of code
5 @; c3 u3 b( U8 rc) print out the lines that are the same
  v+ J& g3 q% n' c; hd) count the number of lines compared / lines the same
) h7 _/ w1 c$ IThe AuthorisedUsers class: (Total maximum 20 marks available), Z2 }5 H1 A, n5 i
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)
# K. z; @7 j# ?  [# H. ^" K4. Provide methods to:
5 ^8 \! F1 ]+ s9 k7 @) F4 b3 E; Ca) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match3 |' Q# F( B. q" o, W
b) return the name of the authorised user
' P1 W! S4 B3 }' K  _: [+ N9 \4 T; ic) return the name of the department of the authorised user
  K% j" [. o! {! o; Z! VIndividual Data (Maximum 20 marks available)5 A1 b+ b; C- L; i$ ~+ x
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.8 k, t8 N6 R+ J. v2 T7 c
Documentation (Maximum 10 marks available)
* C( O9 A+ \4 z0 L  m  n" i6. 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.4 T7 S$ Z( s2 C2 _4 B
BSA104 Business Programming – 2007: Assignment 2# b+ i/ k0 @  ~4 a8 p' d- w1 U. r
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
& E0 l5 S+ O1 M不过你要翻JAVA的类库说明。你有下载没有?  n& \/ g9 K' @5 d  Q) R9 T, K
查询关于对比的函数。貌似关键字是contrast,还有compare
6 Q6 _- B' i% p% |3 h
" v6 [2 d' Q: U; B: u+ v8 \[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。/ b8 t6 i6 E  O* R1 C) E' D8 W0 L+ s7 n
可以下载到的 是 jdk-1_X_0-doc6 k  I* ~7 I8 a& I

1 u1 L2 L% }3 ]. S# @# N: o. h[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-26 15:17

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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