找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1249|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ) s' D" c6 c/ J$ y5 r0 f$ c* c8 L J4 d" \, 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 | 显示全部楼层
//*********************************************************************
9 R; \' E6 Q; ~6 @7 P, i; i//  ProgramCompare.java         Provided by: DRS
: o! `# h1 f/ l, [$ m7 c5 ]//
! v2 ^, I; _& _" k& l9 ?//  Program shell for Assignment 2) ~0 L$ r) }& Z, R
//) e9 K8 ]7 f6 c5 T
//  Compares two text files line by line
& z- Q. t' @4 X- Y' Z//*********************************************************************8 Q6 ?" c* B" D3 w
- U! B3 u9 C' I4 K, x5 I
import java.io.*;
7 x2 w4 x3 I. n
& D, ]* P' L5 B* Y2 `3 h9 F$ hpublic class ProgramCompare& Q- ?8 q7 x+ `8 P( N9 n
{: U5 Z' S6 [* ?8 p; {
        //-----------------------------------------------------------------5 U: x! x7 T) F; W+ w- l
        // Constructor" f1 ^) u* l% s" S9 i
        //-----------------------------------------------------------------
, g0 D3 Y% y  t% P/ }6 s) h        public ProgramCompare()- E* `# o" l- u! i- R0 U( M, S
        {5 Z( [! d  E9 X) |; C
        }
8 y- a( E6 C$ S3 p) M; C8 A# B% d. S6 p# c% a/ ?4 r0 k
        //-----------------------------------------------------------------
$ W# Z2 f/ w+ R' N( V  O        // Method for testing that class has been reached
/ p% U& U" ~: q! x        //-----------------------------------------------------------------        1 {8 O/ j5 X" m: T  A& b4 ~- m
/ ^# d2 y! T: f# Z
        public boolean ProgramCompareReached()        
1 @  D9 z/ Z7 d7 v( Q4 E        {8 ^- }" i3 t) b# j" G8 s
      try
4 S6 ~6 R5 q; d0 V; _   {        
  V. V) N* S: l3 T' A                        - C* U0 c  h' z! {4 C
                //********************************************************************
: W. |& Y7 L+ C6 n3 {7 N                // Try-Catch Statement is used to handle exceptions - such as file not found
$ h) T' A6 _, C6 {                // Reading the files will need to be placed inside a Try-Catch - just like this one!
' ]0 {  }3 U1 G# A, W3 x- n* y) Y. U                // For more information see page 534 of the textbook
  H9 ?- d- k( Y! Z& ~                //********************************************************************/ C4 @$ m: Z! ^0 l* G5 K
                     ' K8 f4 O' C) [3 }: `6 c! s2 L
        }( y; T( e7 }" g1 ]- E
             catch (Exception ex) // Exception caught here and message displayed to the screen 5 Z/ C/ i1 x' Y' C: ~
          {
9 v' a( ^3 F1 W                    ex.printStackTrace (System.err);
* B# A- G, ?# i           System.out.println ("Error message goes here"); // Replace this error message with your own         
' e) s% _: Z. I. x        }2 d, A0 a/ J7 h. b- N" a% R! s
                return true;4 y% y$ y- J, a
        }- P5 t4 {" Q8 B1 I& e

( V6 g6 d; ^' B! m7 t) Z} // end of class ProgramCompare, r" P  F* m0 h) l* h

: {7 R6 @4 U. {: I//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************2 X- i& w9 I6 c# o% Z0 R
//  ProgramCompareMenu.java    Provided by: DRS4 [! J2 m& [' v$ ~& m, L# w
//
" D! }7 j, t: M, c* r6 X//  Calls AuthorisedUsers.java and ProgramCompare.java( ~' i. Q4 h' q) ]+ u" V* i9 `% C
//  G4 o8 W7 Y( {# L4 p% U
//  Driver shell for Assignment 2./ \) W9 ]$ O6 d- @
//********************************************************************
. P: w: N- o5 u8 w/ m' B+ _+ Q6 P  s' N- [$ t$ x- Y
class ProgramCompareMenu$ F, V$ n/ x6 d2 F( d  f
{1 F7 ]5 o: d- u* S7 e& S$ A* ~" u6 Q# |1 ^
    public static void main (String[] args)
1 ?# I2 b4 }& q+ }: t- K5 f& R            {" U9 z9 y5 w5 G  G  `( U% r+ D$ `
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
& c# t; s4 `4 P% i5 u                ProgramCompare reached1 = new ProgramCompare();
5 g9 l# ~* J0 H6 T: l3 k                AuthorisedUsers reached2 = new AuthorisedUsers();       
* `2 K5 B4 x  p1 b! I                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
. @. i/ W# i& v                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
" R3 m7 D3 `' O6 h; R        }
: y, Z2 m4 h% V& c}// end of class ProgramCompareMenu* O- `2 v4 Q: e

! g' g6 o+ H+ {, [3 p9 m6 c//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
# p0 U; Z4 q+ t( n//          AuthorisedUsers.java          Provided by: DRS
" B8 M$ q7 j6 j% Q6 I//               
+ y* c+ o9 H3 r# D0 m2 C//         Program shell for Assignment 2
  d4 L9 T9 i, k$ @7 k# @, i- r//5 g% J! `6 V: z# X% @2 z) O8 T
//         Represents facts about an AuthorisedUser
8 y; z" T5 N* T1 c6 }//********************************************************************
. S* r5 ^; I% k1 x! a# S4 X! Q
! a) g! U0 m8 e% spublic class AuthorisedUsers$ L! a% L  o+ N, D+ a9 P  T* H0 d
    {
4 G6 {2 l8 g, S6 L* D1 ^9 u  U+ o' @3 h8 w8 R1 R$ C  j
        //-----------------------------------------------------------------* M7 D! h. b3 N" |+ d( Q; {
        // Constructor
4 s4 Y2 M6 h' [/ J' U/ S2 ]" Y7 V        //-----------------------------------------------------------------5 Q7 x/ u% ^! V0 e% x

9 E4 D: Y& h3 h) b$ b( H        public AuthorisedUsers()
- {& o5 d4 P2 q6 A                {8 S  j+ L" g5 D+ E, x- y
                }" @: `1 U$ V2 I7 j* v) g# s
. w; y1 j4 s; d( i7 Q2 j
        //-----------------------------------------------------------------4 S# c5 K7 q# K% }
        // Method for testing that class has been reached$ s( |: w; N  z
        //-----------------------------------------------------------------       
. v5 J6 W7 K" b2 n; o& M        public boolean AuthorisedUsersReached()3 ~' W0 f9 B8 E* ^
                {
8 S0 m% t) I) i, m1 ?8 @5 w. ^                        return true;                       
3 u5 k" ]+ z% f. P1 Q7 `; h9 b                }. S1 S# w2 U  E3 w! Y
               
( y+ Y5 ]) {% W1 A    } // end of class AuthorisedUsers
7 K9 I' {( l9 g2 \6 F5 Z1 o9 O/ L//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
" |0 |7 B- B* G- M8 W' IShanghai - 20073 P, M8 b! w" x3 a
Assignment 2* X# o, |2 R$ C4 @9 |. o
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)
- z/ A! W9 I& f0 L7 w% e1. 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.
4 Q- L/ m" s1 `0 G0 qThe staff must be able to:
- d# t$ u; i& H6 X# t" S Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
6 C* P7 G0 F# u0 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.  m6 _* j* }1 i. c3 P
 The interface should provide a menu so that the staff can:
% s; h" f" j/ t* `2 E. ~a) Enter the names of the two Java program files to be compared
" X) y6 ]7 r' n' F4 ^% s* l6 e) X) B' z For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
1 X7 c2 H, ?/ i5 G** 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).
4 P1 L6 k4 F; c& M. O. g1 ZBSA104 Business Programming – 2007: Assignment 2) T8 ?& @, ]6 ^% B6 ^
Page 2 of 59 S/ Y  L: l  ]3 Y/ _
b) Print out to the screen all the lines of code that are the same
5 W1 B3 M: t. x) L Include the name of the file and the line number of the code being printed for each of the two files
. L4 a) K0 ?5 Z. R. Tc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared4 T; ?/ b5 R4 n; ?: R8 n
 the name, username and department of the user' K( I) G, V/ s
 the statistics of the comparison6 B. C% h( @9 q8 c" Z5 }7 o
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
0 ]2 S$ d% H: t2 T& A( h the recommendation for further checking6 z' W. s8 Q& P3 e; y- 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: `/ k- U: u* R* }+ _' s0 \
 the names of the two files compared
+ v; Y0 \' J( [9 vd) Leave the program (exit)( e1 G. R* I6 {( S
The ProgramCompare class: (Total maximum 20 marks available)
% f2 G: {2 c, s2 [/ [- C0 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)
& [% M% \  U4 \5 m: Fa) provide an error message if the files are not found or there is a problem opening them: p1 Y! c5 B) E4 W
b) compare each line of code
: r1 V9 [$ B' h7 T7 @- Ac) print out the lines that are the same9 M6 U6 C" u- A5 y* w
d) count the number of lines compared / lines the same
+ Y9 {' Q6 ~3 x2 ?1 f. TThe AuthorisedUsers class: (Total maximum 20 marks available)
( q( r, k4 C0 V; g* Y3. 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)& {( L6 d* S' r5 c$ u2 ^" W
4. Provide methods to:
  V4 E7 m: N* R: l+ z' ]* N- m0 Ya) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match4 a5 \. F  z5 N: O4 _7 c" T$ w" h
b) return the name of the authorised user  D% c" R# V1 N2 m9 ?
c) return the name of the department of the authorised user
1 T7 H# ?3 t' q0 Q* q+ [Individual Data (Maximum 20 marks available)
7 @! I  b6 F% i( I5. 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.# O- b1 B% J0 J" n
Documentation (Maximum 10 marks available)
- K, U( o- n/ P- `2 _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.
' b: y/ A. Z* x# YBSA104 Business Programming – 2007: Assignment 2
+ L- u1 g% R. k: e" c! `0 I) tPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了: T- r& ]+ j1 @5 h
不过你要翻JAVA的类库说明。你有下载没有?# `7 L' u, R* c, I+ r7 m3 \
查询关于对比的函数。貌似关键字是contrast,还有compare
4 f- p( W% t4 U9 s# ?' \
. q! G" O4 k8 Y, g8 r# G/ a[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
3 r8 q5 X* O3 V1 Z* ~" p- o4 P4 ]痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。- O) t! a  I8 o: @0 M
可以下载到的 是 jdk-1_X_0-doc
) U; r8 K( K2 I9 z+ }/ y) V# C
. L9 p. c# \% x[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-8 03:08

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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