找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1587|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急: G3 f$ L4 i/ l( T( ~' G/ y$ J1 h + E* t) ?: [$ t+ o
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************! ?, N" s. E& o. B+ S
//  ProgramCompare.java         Provided by: DRS
5 t$ F0 m0 n+ C//) M7 u$ c6 i1 B$ n
//  Program shell for Assignment 2
2 _1 P2 h% k$ T! n  U( s- C//
+ q: u7 ?2 C# o" U$ O& {* S6 K5 `//  Compares two text files line by line
  t- ?2 d( `1 B( x//*********************************************************************0 B8 z3 Z% P* x3 W7 u

) m. i  B: ~. k& t$ ?0 z: Limport java.io.*;
8 Q3 v2 {( H% U5 f! F* ]  C. Q# m( q( n) d  [
public class ProgramCompare# W6 @9 m4 H6 `! y+ f) R9 o
{
+ o& S8 i. p4 ^/ E        //-----------------------------------------------------------------( l% g$ w# s" u
        // Constructor$ @9 A: t- i9 f& c
        //-----------------------------------------------------------------  J: L( f' M3 J; x7 X4 A) {
        public ProgramCompare()% [4 E2 y. k5 l2 s$ {8 }
        {& p+ w1 v1 n/ [8 h  A* `
        }
4 C+ [! r$ Z' h: b4 n/ m# g
" a% U6 G& ?5 t* U+ C: T        //------------------------------------------------------------------ K% a& Y' X9 \% F6 A6 p' {; N
        // Method for testing that class has been reached) z9 U3 `- \! O1 e7 T! ~6 c2 B) ]
        //-----------------------------------------------------------------        , w; j9 W8 S- A- F( e1 d

) m: ]* f! J: F+ h& K9 u7 v$ z        public boolean ProgramCompareReached()         ; N+ ?( l  U8 X0 J) t8 j
        {
) W6 H  g9 K0 A- F% p      try ) j: m& a: P$ F+ e% L1 v/ h; ]
   {         ! A' @$ x" ^5 w& p
                       
, F$ |# D! J* J$ P% S                //********************************************************************
; D7 A" y$ G6 E7 ~                // Try-Catch Statement is used to handle exceptions - such as file not found 6 z$ ?; L  L. p! k
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
) u( }0 J( t9 L; G9 }                // For more information see page 534 of the textbook
( Q7 E5 l, T9 A6 }  s# f1 \6 ?: n                //********************************************************************
9 C$ L# t$ D6 H8 E$ u- L                    
& |9 O7 h9 Z* m' K( c6 I' a        }' C$ F9 l7 s; _! X0 A7 O8 _
             catch (Exception ex) // Exception caught here and message displayed to the screen & s. h, m+ p/ b! s, @; B, f7 h
          {6 F1 e  O5 r% y* w
                    ex.printStackTrace (System.err);. K; }4 J, Z1 E5 s7 a
           System.out.println ("Error message goes here"); // Replace this error message with your own          : D! C! i( V2 y
        }  }# G- \; D7 m" k' j/ V) D  M# E
                return true;. B' A6 ^0 J' J! H9 l8 H
        }1 o( D; f6 Q* @7 R$ i7 A- B' W  g
( P. X9 o* c6 {4 h; y5 e3 D& R% g
} // end of class ProgramCompare# D# p8 f: Y3 ?& f+ N
: h( ]/ ~3 W3 u
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************2 r6 N6 Z8 u( H9 T
//  ProgramCompareMenu.java    Provided by: DRS
7 A5 [7 A8 ^1 N* Z" Z/ u//# U+ _# H- [2 {  l4 C
//  Calls AuthorisedUsers.java and ProgramCompare.java; G8 @6 }: ]  E  H8 p) B
//$ ]  O% u) Y( O. l8 x
//  Driver shell for Assignment 2.
0 ?4 N0 t  ?# `% }. H//********************************************************************
/ ^8 Z/ j# F1 a( q3 B
8 @: {* z3 S3 Tclass ProgramCompareMenu
4 D! a/ l" c7 s1 s/ r{! r+ T/ e* S# I' u
    public static void main (String[] args)
4 F2 d! m; W  q1 E$ l, d            {
7 }, v- m  J# J" ]                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable3 T" e3 {  K8 g2 n- e' @
                ProgramCompare reached1 = new ProgramCompare(); 3 O  ~# p; H& U7 _( y4 g- ^/ v# d
                AuthorisedUsers reached2 = new AuthorisedUsers();        $ e# e/ z) G* x% [" Y+ k& `
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
) [/ A1 Y7 c; p                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        + w: h' C& T7 q1 l7 d$ t" m
        }
  `( d5 S+ U" V* H) t7 M}// end of class ProgramCompareMenu- Q- J; Q" N8 F
, [  [9 x4 V* x
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************. }: O" |  O2 m7 P0 c" j4 R
//          AuthorisedUsers.java          Provided by: DRS
7 r, w) P- A/ g+ u( Z1 S//                $ F! B! N" B# ~3 r' E1 `
//         Program shell for Assignment 2
2 G0 x( X' ~/ H6 V, M2 }//, b+ H$ D$ |/ R/ |, W
//         Represents facts about an AuthorisedUser
+ _) y0 T  _2 F% y7 ~2 i//********************************************************************
0 i8 Q9 {8 Q' j- }/ e6 `8 ~
" R; d, T3 b" w8 c5 `( Zpublic class AuthorisedUsers
9 P8 s5 y( r" `$ d8 m. e    {
9 g* g0 ?% Q# I7 d% c, t- C
: ]( ?' I3 w4 ], {) q" C; {        //-----------------------------------------------------------------+ c+ U( p+ ~1 i. [
        // Constructor
- Z& Q9 H7 s* ^* {1 [, |% x        //-----------------------------------------------------------------: L8 Y; c( h6 m  m! y
" L3 \9 A: f4 Q
        public AuthorisedUsers()
' N: W; {: ~8 o3 K4 p! T$ v4 k9 a3 Q/ v                {& l5 }! A) i, h: k
                }
/ e& s. ~; z+ f7 M0 R0 Q
1 Z% w, C/ a4 u, v2 }6 X' x        //-----------------------------------------------------------------
/ |1 K# [6 v  H! R1 ~. [7 m        // Method for testing that class has been reached/ C6 x6 s& B, _# Z
        //-----------------------------------------------------------------       
/ s. j( ]0 g0 v  E9 `! G. h        public boolean AuthorisedUsersReached()
; I  d# s- Q' D* M0 e4 W                {. B- U% ~; P3 [  m/ F
                        return true;                        5 S6 x/ A& }+ s( H
                }# H+ h7 Z/ ]6 \$ o
               
8 Y; s# T. S6 g; s3 ?0 u" R    } // end of class AuthorisedUsers
$ J! `) B* w  f//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming: e8 E- Y! u, k& t
Shanghai - 2007' R* m8 d! T; y9 T7 u" q
Assignment 20 l4 }% e2 {$ m5 K6 K
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 G, e$ F* \" c8 `- V! }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.
9 r) Y9 i( E- k$ M3 s% AThe staff must be able to:0 B% z" ]4 M9 f8 n4 H9 s4 ?
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
& g9 w+ m$ }# ~# r+ {& x8 T# V* u' V1. 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.
* r' {) O* @" L! v The interface should provide a menu so that the staff can:
2 L/ S9 s8 H6 ea) Enter the names of the two Java program files to be compared% z1 `2 i; T" m! p8 v$ z
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
7 j! n' @# m& V* M5 P* [1 k** 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).5 d: |/ e+ D1 ^: H
BSA104 Business Programming – 2007: Assignment 2/ b* j5 F" ?/ V2 L
Page 2 of 5  S* a& P2 p7 W% `, f1 D
b) Print out to the screen all the lines of code that are the same$ w. d' R  s" O' m0 j/ ~7 o
 Include the name of the file and the line number of the code being printed for each of the two files+ _1 E8 ?( |3 k+ e2 e6 N
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
# d- F% U! f3 c# d8 | the name, username and department of the user$ g$ d: f* O3 {. Q" n" V( H9 v
 the statistics of the comparison
, W  m6 w$ b/ f* V4 W9 H+ }  A3 ~3 G% T* F- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
6 w2 U* Z  k8 Z! r: _* ~ the recommendation for further checking7 p3 N6 R: G- u$ o$ I
- 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
5 z* j" @$ H6 n6 B, i) @/ K the names of the two files compared
/ C) F5 h' k' v1 Y: O" h5 id) Leave the program (exit)
* q6 a( @: q7 y: h5 k0 A# _8 [The ProgramCompare class: (Total maximum 20 marks available)+ y) n- n% e8 s1 y: g
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)& Q5 M. t4 C4 ^
a) provide an error message if the files are not found or there is a problem opening them$ c1 t0 @" @( v; `
b) compare each line of code* q8 n: V4 h. p* N) H
c) print out the lines that are the same
1 e% M( U; m3 W$ ^d) count the number of lines compared / lines the same. e2 B0 V' }$ O
The AuthorisedUsers class: (Total maximum 20 marks available)
( n5 J3 ~' @! V, {( j+ d) M3. 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)$ H. s% F$ I4 `& [. B
4. Provide methods to:
# q6 J: m; A. S! l0 Z1 K  |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; c+ y, B0 e7 [5 d' `9 A, O4 }# ^
b) return the name of the authorised user
' x6 h, [+ m; S# K8 Q% @c) return the name of the department of the authorised user; m4 h3 u: g; A3 |
Individual Data (Maximum 20 marks available)
; |6 \% Z; W& O% g5. 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.9 j, B) p# ^  L: w2 l9 I
Documentation (Maximum 10 marks available)$ K2 M. q  W  c- Y' }
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.8 P7 C. g6 I/ T5 I6 T  ]0 y/ x3 J
BSA104 Business Programming – 2007: Assignment 2$ L! a0 e8 b& O9 B, p; F
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
$ J8 c9 }+ x% C9 f- \0 B不过你要翻JAVA的类库说明。你有下载没有?2 n1 t: x6 P& R: a5 V4 Y
查询关于对比的函数。貌似关键字是contrast,还有compare
1 o. ]* P# H' n' a
% P, m& z6 U) ^3 a% X  Z4 j3 v* A$ m[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
4 k- j4 j4 K& @0 o9 j痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
; b5 C8 J- `' I: a3 B可以下载到的 是 jdk-1_X_0-doc
9 {) G7 @; l* m9 B
& s2 H7 B0 g  v# q7 ]" R. L[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-28 19:30

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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