找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1801|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急3 M( M( }. b' o* b3 B0 ~ 4 X Q6 o# B: q. M
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
* `$ p' O9 ?! |6 {" L/ m) Q% J//  ProgramCompare.java         Provided by: DRS5 o# f7 e! z: A- s4 T" w
//
! i" r  u" J, X5 w//  Program shell for Assignment 2$ r# D% d% Q# B+ w. x) i
//
( l* d5 C, Z8 ]% o9 Q. O//  Compares two text files line by line
5 v# ?- y6 r# l- f/ T# g//*********************************************************************, d3 [7 u7 I9 @8 b# E

7 A- ^, ^5 w7 {. A( jimport java.io.*;
9 y2 \* r4 X# {1 r
" I2 y0 `( T5 R/ n/ U$ Hpublic class ProgramCompare
. B, q4 A$ z1 O9 \% S* O  ~{
) t3 _" m' K4 \  w& c        //-----------------------------------------------------------------% w) n0 J" i+ j" B- `
        // Constructor
9 V/ Y& }( \5 L: p        //-----------------------------------------------------------------' l4 X# c( C/ m6 l" U, r
        public ProgramCompare()
0 j# ~. |+ i/ p% a        {
% `5 Y! K$ a& _8 T6 o$ [$ K1 k2 y        }
& Q. U. w5 X0 H4 M- M
" [+ k1 |. B- R5 q2 U        //------------------------------------------------------------------ Y' D2 G+ B2 A' z& e& c
        // Method for testing that class has been reached
. ~& E0 \5 p- X! k! a        //-----------------------------------------------------------------       
) S- M7 |4 Y" p* m, F" A  F1 B4 {! G5 S/ w5 C3 {5 }  Q) E$ q
        public boolean ProgramCompareReached()        
9 Z5 W* j! B& s( X3 g        {  t% ^1 m3 B2 z9 W
      try
7 e0 k+ `/ I; t# X   {        
! l, z) w) E) F! L                        # y7 t; B; X; _
                //********************************************************************
4 l6 Y8 U3 w' D1 M                // Try-Catch Statement is used to handle exceptions - such as file not found
4 T2 g( `  ]" e; \. T! T7 y+ C( a                // Reading the files will need to be placed inside a Try-Catch - just like this one!+ Z( {7 d3 R$ b0 O0 x
                // For more information see page 534 of the textbook% E% O( g+ `% Z* |, V* D$ S# w. x
                //********************************************************************
+ j. g3 E6 [; Y1 m* ]% E) a2 f. {                     % Z' e& O5 P$ c# ^6 G
        }
6 |& w$ R$ e. R; ?6 g' l             catch (Exception ex) // Exception caught here and message displayed to the screen
6 }$ A( d  C  L4 L6 S4 f          {5 {5 }# J* W$ [( f/ D6 Q0 O' g
                    ex.printStackTrace (System.err);+ M$ m" T! k! H$ v1 k
           System.out.println ("Error message goes here"); // Replace this error message with your own          2 c& R+ G5 j+ V* ?7 I# x8 B
        }& P* `6 D8 o" t  G; b
                return true;( f- l5 H8 L  d& @* b2 W
        }+ o/ i  [/ z9 f- f5 V
: V. x4 E# T& O5 z; G& U* {
} // end of class ProgramCompare
9 m8 I5 ]8 b1 R- a. o8 i
/ F/ y6 H7 o3 b- s/ q  \//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
+ |& [5 E8 L( i//  ProgramCompareMenu.java    Provided by: DRS, t. B5 {; L4 @' h9 C
//+ i) g) g+ O2 q& q  S/ _  C* \
//  Calls AuthorisedUsers.java and ProgramCompare.java5 X, i& s0 p3 \2 V* d
//
$ Q2 \( [+ b& Z2 q2 Y' b4 n//  Driver shell for Assignment 2.% A# M3 Q7 W6 N9 ?* N# s$ d
//********************************************************************' _5 s& O  \2 G: G4 I3 l$ E

; I# v1 F. [2 c: h; Zclass ProgramCompareMenu8 e* H8 F% X) E5 w) R9 d# @
{
/ T: C7 Y, s# v7 A# s. X( B    public static void main (String[] args)
" r0 e# R3 F% K2 W1 `- u7 m            {
9 i6 b2 e: N: O" }2 s5 {                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable" o! c) h& [' c) x
                ProgramCompare reached1 = new ProgramCompare(); 2 f, k6 A8 T) V5 \) k
                AuthorisedUsers reached2 = new AuthorisedUsers();        % z+ y& W5 a. C) t- C% a) q
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());# g$ z7 ^  m3 Z, a7 u$ {
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ! [8 E! A$ l5 J5 S# F/ B
        }8 Q0 F$ d7 s: @6 H* y
}// end of class ProgramCompareMenu, s4 t8 ~; N: W
& l# \+ x! G: _# G; }0 O
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************' [( L9 E0 I( `4 \+ D
//          AuthorisedUsers.java          Provided by: DRS$ s$ R( I* m$ G  g) n1 U! {
//               
! L& v1 K; D+ x! G. o6 \$ W//         Program shell for Assignment 2
5 f6 m  e% i/ T2 |0 @5 P; q//
6 P: j$ o4 [, w% {5 D1 V4 P//         Represents facts about an AuthorisedUser
! z% d/ W  u0 E: G! x//********************************************************************
5 [* q' S8 D# ]/ y  u+ I3 q9 N6 H- s) o$ T* ^, k% K1 j
public class AuthorisedUsers* y+ h& [6 t. }$ a9 `7 P0 |
    {
2 _8 O7 Z! E  k
) T( h1 x+ X1 k. B3 G        //-----------------------------------------------------------------) N- T4 z8 S3 Q! M
        // Constructor' D2 U4 s+ E; K: }& _7 |
        //-----------------------------------------------------------------
1 v8 q, D  d0 k: M6 V% l( @; t: s" F- F
        public AuthorisedUsers()( J, F! ~5 y, E- R3 |! _9 M
                {
. \* {  b* c  L3 |                }
: U2 e/ Z$ j+ C: u: u( y4 |. Y5 p$ B6 |3 h
        //-----------------------------------------------------------------% B& g8 W6 z  H! N# l  x
        // Method for testing that class has been reached$ \4 b% q3 S( W  R
        //-----------------------------------------------------------------       
8 x+ e9 i. U" c/ m/ v7 u4 `& a        public boolean AuthorisedUsersReached(); x& `! C- b" s$ ~, S
                {
' |5 i7 T" l' B                        return true;                       
; G) ?# G4 W6 x2 @% \1 _4 J                }% M* i  l  ?0 A2 B
               
6 n6 s' V4 b6 N4 r) r    } // end of class AuthorisedUsers
, x! c" ?7 ]. i- K# N- `2 z( B//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming, p2 D, Z9 R. G2 C" X& N) {$ s- n
Shanghai - 2007
9 \6 I8 \- i5 ^6 S4 zAssignment 2
' ]6 W4 W7 z0 C" vDeadline 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)' B, ]1 Y. m8 z/ W, h7 P* g
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.  ^$ X# a' d0 E' V. R. @
The staff must be able to:
- ~8 D, Z2 x& ?  l Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **./ T# T& v8 B+ {) h( h; m$ W2 u2 y
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.
/ m7 c4 u7 y' z# V% z2 I The interface should provide a menu so that the staff can:
+ m* r# R; y$ v0 P  @+ Ca) Enter the names of the two Java program files to be compared
9 {: Q+ Z2 h2 Z# s For this assignment, it will be assumed that the two Java program files are in the same folder as your program.6 l7 v2 V- v* `
** 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 }0 L% K# `& ^/ I
BSA104 Business Programming – 2007: Assignment 2( `& b5 ?1 Y" z% B. B) u
Page 2 of 5. T0 e  E4 H/ `# e) A: l5 X4 ]
b) Print out to the screen all the lines of code that are the same; u- a5 m+ U! n4 |3 |6 D3 B* J" \
 Include the name of the file and the line number of the code being printed for each of the two files- m  k$ ?' b) S" ^( I7 C, d( L
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
" q0 Z  |7 G6 m8 g. _/ Y! J+ d5 y the name, username and department of the user. k: @  a1 S' e' j: \9 P
 the statistics of the comparison7 N% n1 q3 F, ~7 `, _4 F$ u
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
7 Y3 N+ @: P$ P+ ] the recommendation for further checking' g9 l: F5 S- t% `8 Q1 n4 O7 G
- 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: g$ A4 C  A6 ~
 the names of the two files compared. Y3 I# a7 J( a5 Z$ Z: P
d) Leave the program (exit)
/ H* f" s8 H" b* W& uThe ProgramCompare class: (Total maximum 20 marks available)
9 z+ N! H5 H" e* z/ h! m! w2. 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* S( A: u1 e0 g4 P1 [- |* H
a) provide an error message if the files are not found or there is a problem opening them, O2 g/ V: s% e) H, w
b) compare each line of code
8 z7 }  C* A8 zc) print out the lines that are the same
# ~- ^0 F' g6 F" p3 L" Cd) count the number of lines compared / lines the same7 _( d, I9 D( C, k, n) W  o% a
The AuthorisedUsers class: (Total maximum 20 marks available)
0 J' @5 t4 \. ^" l$ k3. 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)
9 O, [% C  E# _. b: t$ }- K- \( y4. Provide methods to:, B' F- W& D$ g6 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- K( Y7 u% {) \  p/ U" y
b) return the name of the authorised user  @, ]3 l1 q' n& m+ D2 P
c) return the name of the department of the authorised user
* o! `# @. Q# k, TIndividual Data (Maximum 20 marks available)
5 E$ X, s  y6 @* z. M  f5. 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.6 \. b# v1 u- U1 w1 C
Documentation (Maximum 10 marks available)
* [5 S5 {8 Y3 K' H6 [* R; s8 [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.
$ g* r6 i" @- ^8 f/ \  e7 zBSA104 Business Programming – 2007: Assignment 26 q3 i4 d3 R% J" x# W$ G
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了, z; M  P! z! O+ ?/ K8 l# t* }1 J1 L
不过你要翻JAVA的类库说明。你有下载没有?* r4 L1 L- L' _0 l# R) p
查询关于对比的函数。貌似关键字是contrast,还有compare
' a7 ?/ b  d+ c: W6 Y) h; {2 G# J' ~$ `5 ~
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -  g$ L) V/ t* r! f7 V
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。8 t; O: M0 c6 C, ~
可以下载到的 是 jdk-1_X_0-doc, G0 S6 m5 d5 y5 ], q9 P7 m  O
5 ^* J8 Y4 {" c
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-5 06:00

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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