找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1452|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 6 y, m% W; Q' N* o. p/ e, y ( p F% r4 X5 L! ~% c& y3 y) |
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************5 \  E- r% U- N; z9 g
//  ProgramCompare.java         Provided by: DRS
; f8 G: @! x/ u9 Z: a* @//
( d* X6 s) s7 N3 @0 H5 L7 S( V//  Program shell for Assignment 2
3 F* E/ Y! Q( l% [5 l: k- Y//* ]5 O" i+ B6 z
//  Compares two text files line by line
, g. j4 y6 ]( q( P% P//*********************************************************************9 l5 p  a1 a6 q7 a: W
6 }, g6 u2 B' Y0 P
import java.io.*;
$ v, m, G' `' h" q7 Y+ H" q9 L2 Q+ @' L9 d. w* r1 p
public class ProgramCompare+ Z) ~, [8 h  A/ X4 [3 W* P7 u( H
{* W" l6 q. K3 s8 q. Y6 Y8 c
        //-----------------------------------------------------------------
' @" B0 @+ s8 _! z4 W7 m        // Constructor
, o9 S5 v8 W" P/ q- t0 i* N/ G        //-----------------------------------------------------------------
& e7 t! M+ O  l: f; e        public ProgramCompare(); B) ]! W5 W$ b9 j, ^
        {
0 L& U  w( Q* \* q1 V8 u        }
! Q' e$ N) G0 C) E! s, }4 h
# s' ]1 l3 C# N$ M( l        //-----------------------------------------------------------------
1 y/ j4 S) [9 y8 g& J$ J- ~        // Method for testing that class has been reached
1 {$ O+ u& X) w        //-----------------------------------------------------------------       
( l" D& k" G/ U  \# }
: Z# m! M5 l6 T1 Z+ `- J        public boolean ProgramCompareReached()         + g+ l& u6 M: i
        {4 L' B1 ~* A6 M" v" f5 g- t
      try 2 z/ |' u% I- a% e' F
   {        
- ?' ]/ r, G* a& o0 U* l8 L                       
0 Y7 V  Y$ Z7 b5 ?  }- g/ b                //********************************************************************
+ R. W5 N: F( v( J/ Z0 m! G                // Try-Catch Statement is used to handle exceptions - such as file not found 7 j$ P) M& W% a* u
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
3 `2 s* ?- P/ \1 l* Q6 g4 t; T. r                // For more information see page 534 of the textbook
2 ?1 Z& m) c3 l4 G- x                //********************************************************************% p& ^& m1 u; B3 `- O2 d. ~% m: y5 {
                    
; k+ w5 B( i, \  F9 |9 F$ O        }) x5 s2 h. J/ [& d' \! k$ a
             catch (Exception ex) // Exception caught here and message displayed to the screen
$ J, E8 z; h( E$ M. m. n0 ?; F$ {          {
, x" S2 K& a% [2 R% ?7 |& c+ z/ R                    ex.printStackTrace (System.err);
: K5 B/ o  `) E2 Y& b  D0 V           System.out.println ("Error message goes here"); // Replace this error message with your own         
7 y1 H4 ]( E; g- M  y8 @        }$ ^) e' }+ \- d
                return true;
. @" |6 l8 O$ w$ T        }
9 @/ |" N% `8 z& N( b1 a# A8 x7 a0 ?1 q7 S+ t/ }
} // end of class ProgramCompare5 r2 ?6 y* K) Y9 s: j( V4 {
& L6 n; \: }" f& [
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
+ I/ s  M1 N2 w: U//  ProgramCompareMenu.java    Provided by: DRS
2 @! h4 s! L  u& N" m. [! j//* v$ P  I& m, |; S. b; B" {
//  Calls AuthorisedUsers.java and ProgramCompare.java+ W5 b/ d5 P" G% b' }; x* ]
//2 B" u- ?" H4 o" T2 [
//  Driver shell for Assignment 2.9 R# z9 m+ N3 X, V! D1 h: s. e/ U
//********************************************************************
7 i- R0 Y) v4 _# B; ?) j( e5 r$ R. E) L+ R/ o+ p
class ProgramCompareMenu: N& L/ P/ Z+ `' @
{
- ?- {4 [2 T% g1 w! G$ O+ S    public static void main (String[] args)& U& O- M4 m# ?' f/ m
            {/ Z4 X- A% P  A
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable& B7 U& Q8 p5 `3 n+ p
                ProgramCompare reached1 = new ProgramCompare();
3 t+ V) J: Z. c9 u5 k                AuthorisedUsers reached2 = new AuthorisedUsers();       
* q0 l6 j& E  X: @8 u0 L5 Y                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());9 O. N2 D. c/ y
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        6 l& Y; P1 X, H9 d
        }
% N8 G4 w$ y+ _+ v4 y8 P9 a" \4 F}// end of class ProgramCompareMenu, F& K0 j  B# o& s4 ]$ g% R
* }2 r/ Y1 |  u7 P
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************) V( i4 d: m2 J' O
//          AuthorisedUsers.java          Provided by: DRS
7 k! I6 p( g7 K" p) f- _//               
: r) b( Z( x' p6 P//         Program shell for Assignment 29 d, s. R+ t; S# Q
//
# k  F1 z4 ^8 Q//         Represents facts about an AuthorisedUser
# l8 |4 N5 [1 X//********************************************************************
. U( o6 P4 e0 i' x/ w
2 M- k3 p$ D$ h. G4 ipublic class AuthorisedUsers" @1 o( R# [# D' W  t5 ?
    {
! S3 f! x4 p" @' C' {& h0 |. i
. M9 R9 q; O. x( x) M- a        //-----------------------------------------------------------------
2 T, C& p+ l; u$ Q+ R: N        // Constructor# ?: P6 i& `1 B# W' |  G# Q
        //-----------------------------------------------------------------
; b: @/ e, L! I: ~1 O& B% N0 K
* m+ O* |8 G, R3 i- [        public AuthorisedUsers()
" ~* r" O9 d" N4 @! I5 ~                {9 A; j+ r% _' d/ z, @' z' L
                }- b0 q! ?4 f' z6 K$ `' l3 j* V5 j

1 C5 d! q8 s$ C( y( a        //-----------------------------------------------------------------
+ k! w$ X2 i7 L. `( W2 t" k        // Method for testing that class has been reached" e' J  B/ X% i0 y+ g
        //-----------------------------------------------------------------        " V3 _0 u2 \7 l. O  O
        public boolean AuthorisedUsersReached()
+ F" ]6 M0 C( r                {- A$ {. ?1 i' `. y4 Z8 c$ r* m
                        return true;                        * I3 e! W; s/ \. i7 r; v0 V
                }
8 d+ L' b/ Z  `$ \3 D! N$ N# M                . b6 X  B4 s8 H$ v% b
    } // end of class AuthorisedUsers0 ^1 q- h" y8 M" u% S$ ?
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
4 x5 V& d# T  bShanghai - 2007+ n9 X- N: E, _
Assignment 29 s) G' P% P3 y) q! s5 U
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)
' E5 O# F# z% f# B: v( x; t$ c( S1. 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.
6 S, X# c6 }, [1 u% h% m5 P$ xThe staff must be able to:
4 X9 a% o( e& r/ Q+ Y9 z Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.6 Y% p. _5 |5 m) E, P2 A# O. I& S* ~
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.
; w- ?* u- u$ I/ X: [- b  ~) {$ A The interface should provide a menu so that the staff can:4 i) |' }; d1 o4 i$ E; f+ |
a) Enter the names of the two Java program files to be compared
9 K; J+ p! Y! u6 d: n. J; Y9 q For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
9 T$ K. g& s8 T& Q# o** 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).
) l) L% |8 u) V4 |# N- e6 TBSA104 Business Programming – 2007: Assignment 2
& {# L! b  h* ]$ n/ e1 VPage 2 of 5
- x5 y; H$ B7 c* Y4 ib) Print out to the screen all the lines of code that are the same% L# y/ G2 d- [" a: g  p. s
 Include the name of the file and the line number of the code being printed for each of the two files
" K7 Y: U/ @1 s$ A3 x* ^* Zc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
" B6 g; P/ N; B# h- k* y the name, username and department of the user
* I% [# j2 n: t  G( q( O the statistics of the comparison
$ l& C, h# R: ]9 M# A- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
6 _" S: R+ w9 I' x5 o the recommendation for further checking6 L' k! u3 _% x3 t
- 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( p+ B: U+ A) O/ A$ }' j" }9 c
 the names of the two files compared
, s1 T6 ~+ N6 T  f! d5 N4 }6 B! ]d) Leave the program (exit)
8 a3 Y: S) K0 S, U5 q( BThe ProgramCompare class: (Total maximum 20 marks available)
; d7 Z7 R% a& x' d' f' A2. 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)
8 U/ f! n# O- {5 N  ]7 ~a) provide an error message if the files are not found or there is a problem opening them
8 s: Q4 |8 F$ f3 n7 j" Mb) compare each line of code) q" S5 H; `9 J' n9 z  m0 G& x/ t9 N4 v
c) print out the lines that are the same1 Z: s9 K7 h" P  N% ~9 j, b& v
d) count the number of lines compared / lines the same
& e3 t. b# h$ L5 a/ kThe AuthorisedUsers class: (Total maximum 20 marks available)' x5 l0 H9 x  W' o9 h* O/ ?
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)
0 B2 P/ K, ?% I0 m/ M4. Provide methods to:
' T& s2 f8 u- [: _" ~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
$ g' C3 y" M7 r. Q: eb) return the name of the authorised user+ P1 f5 F, O2 S0 ~
c) return the name of the department of the authorised user  c  `; h) _' v. J4 T
Individual Data (Maximum 20 marks available)7 m+ K6 \, t" o8 i1 b' y9 G
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.
1 X& r% l- ~: j" v7 I7 P  T) TDocumentation (Maximum 10 marks available)/ n' s3 t3 R2 r/ z4 z
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.0 C3 [: t2 ~# C4 r& n
BSA104 Business Programming – 2007: Assignment 2
1 g' f5 V+ h3 v  W, ZPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
- q8 N4 B, Y+ i: z不过你要翻JAVA的类库说明。你有下载没有?/ ?* y; g; ~( M+ R  y
查询关于对比的函数。貌似关键字是contrast,还有compare4 b! r' T) ^0 A0 |

3 [0 ?6 r( M8 g* [$ P, u[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
$ s9 e9 v4 D" @* G9 O痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。4 j8 ^0 W) O4 ]! }* D/ P
可以下载到的 是 jdk-1_X_0-doc% h: k! |$ b/ U( t- g; C/ o
/ ^# \9 {' \. r0 o5 D
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-12 03:55

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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