找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1791|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 : C5 E, {+ d5 s) D6 K6 ? B3 J6 j , i0 Y* P I9 f- K8 O, ~! E. b5 R
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
' s( F- J+ @  L0 B8 }* G0 G1 F//  ProgramCompare.java         Provided by: DRS& }6 y* I4 o+ _7 U" V& v
//
) q, ^2 t4 b) L9 S2 j//  Program shell for Assignment 2
- P+ x0 q8 [9 Z8 J; B# [& I" H//
9 g# P: O- S) k; T0 ~1 I, C5 D7 _//  Compares two text files line by line
- m5 P3 B$ f8 ^# i9 T//*********************************************************************4 ~9 y4 X1 [/ P& r. d
5 e; _& {4 B& R9 n+ L) l+ M5 V. i
import java.io.*;
+ }8 f7 a8 u6 J! ?3 S# r" X- n! d+ D5 A) z/ p0 G' u
public class ProgramCompare& \0 ^* V# k$ f8 W3 h1 [% Q
{/ d) h1 m% R9 b) ?1 w* l- Z
        //-----------------------------------------------------------------
' ?0 }$ F! L! n, ^        // Constructor
  X& W- Y3 O$ g; ~  M3 C$ R        //-----------------------------------------------------------------
3 i0 s0 E. g8 M1 s        public ProgramCompare()
/ L3 j' {6 d; p& j% U. `        {
! R* o) y+ N+ O& z6 j        }: L* b! n5 G4 K" ^& N5 A) p# z
4 }6 z" r5 g4 ~4 w
        //-----------------------------------------------------------------5 F" y: I: L+ Z2 D( m
        // Method for testing that class has been reached+ `2 Z, @, n, w* Q# u$ y' O& i
        //-----------------------------------------------------------------       
- ?! q; r, _* [( K* n; A1 Z" m5 J; B5 \: [
        public boolean ProgramCompareReached()         $ }2 o( j6 z% i
        {, D- F( d) g6 n( I3 `
      try
' w$ F, K0 m) D1 J! `6 S   {        
% r6 o) y& G- W  B4 ?                        6 a3 R/ ^! C1 u) X% U: b) \, G) v
                //********************************************************************
6 M4 A- t" g; Y( }                // Try-Catch Statement is used to handle exceptions - such as file not found - M/ @& {3 t  c+ h! B
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
6 ^5 Z5 \8 ^& |                // For more information see page 534 of the textbook
0 c" `" o" q/ _0 L5 A                //********************************************************************" r+ d5 f& [: `7 |; W( v8 V
                    
" ]; v! }" X! O7 D, x        }' h" y6 h# l$ O2 \
             catch (Exception ex) // Exception caught here and message displayed to the screen / g/ v% N0 O4 ?% v0 K7 E( d
          {
# N  S& S+ R( ?* s                    ex.printStackTrace (System.err);
0 Z+ p! g3 d8 m; P! a5 j& ^( y           System.out.println ("Error message goes here"); // Replace this error message with your own          , v4 X5 D# j* v
        }8 w: m8 d+ @* x: O
                return true;
) D1 R7 r8 S; W4 v) _% K- N. b        }
8 _# d$ b3 w9 q- G  {4 ~
9 t9 c* X& y2 B5 h9 w5 C7 h} // end of class ProgramCompare5 ]+ z/ |3 C% v" i3 @7 {: o: ]

7 R0 `0 h) K7 C! k: _& q  m7 r  t//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
. ]. \! `" x% [& W//  ProgramCompareMenu.java    Provided by: DRS5 d" J; o( R8 W/ N. V# `" K
//) U" I* B; _" X9 C" @
//  Calls AuthorisedUsers.java and ProgramCompare.java
3 c! i" d# |( C: \3 S: O* ^3 n//# f; q5 V3 H* X" _1 U
//  Driver shell for Assignment 2.
& y8 N1 \7 P. P//********************************************************************
0 U( |0 T# k- _( Q  A$ m$ D1 |* l% P3 J! V* A+ ~3 X* d
class ProgramCompareMenu* V4 u  X: {: D' j2 d. `
{
1 E+ p: ], j0 `    public static void main (String[] args)7 a! s: U) M6 T2 {% @
            {7 z1 \( _4 C+ B$ e) x# E
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable1 _: x: c% ^- t: b1 w* ?( K7 ^
                ProgramCompare reached1 = new ProgramCompare();
( `2 `! @  x- z# O                AuthorisedUsers reached2 = new AuthorisedUsers();        4 f$ b1 ]1 h5 e
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
2 Y  N  b4 S6 \4 B# }3 f7 ]  o- p% m                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
" e2 n/ O; t2 l: x4 a9 S8 I" n        }0 W, E+ m6 A/ C( q. c, T! o
}// end of class ProgramCompareMenu
+ M" _+ ^$ _& ]) F4 a( e' e' `( q5 n
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
1 N# U6 t  F/ J. K* P! D//          AuthorisedUsers.java          Provided by: DRS/ s# P  f% h* M0 ]/ z/ h1 r
//               
, V. ^( T) k% V5 q& q6 O9 \//         Program shell for Assignment 2
! N% P6 m' M& w% e3 h$ U. \//
1 D' |6 i8 ^$ u2 n//         Represents facts about an AuthorisedUser. `9 |* p, Q3 L' m/ O6 L
//********************************************************************
9 ]: B1 Q# j2 v+ i
: K  e9 t/ \' f$ f$ k/ Kpublic class AuthorisedUsers$ o) S( A& G2 q1 x! r* I
    {% ?& B" n4 @5 S) D% T, ]: F. |4 c
0 O& Y) V! `1 a: q- A/ d/ \' z( v5 x
        //-----------------------------------------------------------------  u1 M, K; c: w$ Y; r
        // Constructor* I0 W9 s+ c) z4 O* w
        //-----------------------------------------------------------------& o" I  ~/ H( ~' h0 S: Z
2 B5 B7 d0 {- X( x% U! H
        public AuthorisedUsers()
+ c2 {+ C) o$ C                {- s# t; q: s/ f! S
                }/ i; W, Z+ p1 N- ~& U

0 P2 D: o5 O3 T" u        //-----------------------------------------------------------------
. e& |& ^8 V, p) }( W4 _& O- Z        // Method for testing that class has been reached
- S1 }- {+ y( C0 I        //-----------------------------------------------------------------       
( e& X; J3 F1 ~; I        public boolean AuthorisedUsersReached()5 @! g0 \' G3 Q' M
                {
- l- K  n2 Y; F1 |                        return true;                        8 S; T5 H" j. m8 Z( L# ]1 b
                }# {- w) _2 ~1 ?, y9 h$ R/ k
               
# T4 T, ]3 u4 w; w! O4 i    } // end of class AuthorisedUsers
0 d3 W1 E+ g& S" B7 X, K//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming) d/ I- m0 H* k) G* \4 s
Shanghai - 2007
9 N. f" U, _! |9 K! d5 ZAssignment 21 U6 L" S; n9 f
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)
, f* P4 E( e- |& ^3 o3 ]+ |" N) U, l7 [$ O1. 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.
3 N: \( K9 X; H; g' x+ Q( b- d- F/ mThe staff must be able to:7 g; v3 x5 b! d( ?' ~
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
2 u; e6 p$ p& _. D! m1. 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.
$ t* G  H4 |  O6 ~* l+ n The interface should provide a menu so that the staff can:: e7 h/ ]1 P5 T0 l
a) Enter the names of the two Java program files to be compared
1 ~* I  L% K% K0 n5 @1 f For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
+ j! e' _0 K6 l# X** 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* H7 H5 p* R
BSA104 Business Programming – 2007: Assignment 22 Z- f% K" ?% ]  ?# H/ q! j+ |
Page 2 of 5
& T. u0 B, F4 H0 V8 l- y  jb) Print out to the screen all the lines of code that are the same
! X- I5 J6 W( o2 V% V" J  ~" }% O Include the name of the file and the line number of the code being printed for each of the two files+ {1 X* j8 m1 V. f/ G
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared. D. [4 c9 G2 j/ z; g
 the name, username and department of the user
7 o  X5 N* L. x4 x( T the statistics of the comparison# V# @' ~" K* M" @3 _8 E
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different9 [; l. M  E/ x' n
 the recommendation for further checking
$ R, y# B& [* Z$ ~5 w  w) q& 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
- F& ?2 J+ P; w" J3 \  Y the names of the two files compared" f; B" R# p4 p' a: t5 _1 n
d) Leave the program (exit): r5 r* N: K( \+ d0 E
The ProgramCompare class: (Total maximum 20 marks available)5 w* n9 P/ v6 {& P0 C
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)
* [; T# D3 H2 ua) provide an error message if the files are not found or there is a problem opening them
" h3 a% M/ t$ B+ }( k- [5 Yb) compare each line of code
! R" F$ ?! X/ J- Q  T! o; C  sc) print out the lines that are the same
  [6 k3 w7 A0 c% ^d) count the number of lines compared / lines the same
, `, x7 G  q/ `$ y9 s+ vThe AuthorisedUsers class: (Total maximum 20 marks available)5 n' q! d& K) _3 \  n& E
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 n* \/ J- O0 L
4. Provide methods to:& p) V0 b" N- G9 s
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
: l) m/ k. \: T* n4 Q0 s& ib) return the name of the authorised user
' {3 b2 ~5 e/ w% O: Nc) return the name of the department of the authorised user
* ]6 W5 l# P+ @( k0 bIndividual Data (Maximum 20 marks available)
6 ~1 ^5 S. L8 {' A4 j5. 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.
) C; Z( g4 H) x" d+ X: {" m5 MDocumentation (Maximum 10 marks available)
8 B; Z  a& Y! U3 @" ~5 Q6. 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.7 p" t+ o5 ]/ |, F3 _8 @+ r" T
BSA104 Business Programming – 2007: Assignment 2
8 _( ?2 {( ], d- U' b: R8 S; fPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
% s: p- v8 Y3 A) v1 q- j0 r不过你要翻JAVA的类库说明。你有下载没有?
4 ~' q* F) f2 B) t2 J查询关于对比的函数。貌似关键字是contrast,还有compare
' [5 T1 U% q' Y- x1 g& y8 _; }" t0 g8 S8 d0 x6 ~8 V" u- Q9 L! \
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
+ L# v* Y7 l1 x) v痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
" E  C$ u1 G" g5 L! i7 _可以下载到的 是 jdk-1_X_0-doc
2 @1 u# x: u/ `0 ]8 F9 i3 @! s1 l- I: Z- t, [  Q
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-1 22:34

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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