找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1659|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急1 h& s; A4 I2 Z4 k# O 6 u* C$ @/ F/ T/ y- e$ X
回复

使用道具 举报

 楼主| 发表于 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 m9 k6 n& ~) D' H! `//  ProgramCompare.java         Provided by: DRS
8 G7 B% m1 L5 C//6 {" q; P' a# `* J2 d
//  Program shell for Assignment 22 Q  T" m6 ?& t  E1 i0 I1 E4 ]) V
//1 E' k9 ^7 N' L2 V4 D* M/ P2 P" E
//  Compares two text files line by line
4 w4 K! s8 ?; T7 k  g" s//*********************************************************************
/ q1 l% W8 e7 V5 U# q' ]
% F0 ]+ [, x0 ], aimport java.io.*;
- e2 ~  Z; [/ t# |% ^0 b+ Z( R" X( J/ ]: _9 `) G
public class ProgramCompare; E; Q, e; l  T# e7 s! Z" `0 L
{
# z2 j7 O8 r5 ~$ E+ O- Q+ [        //-----------------------------------------------------------------* J) x: O) z+ u' Q; I4 c, p4 ^
        // Constructor' D$ o* k' c! R& e: `" W
        //-----------------------------------------------------------------
9 N+ K. k( k* h: k        public ProgramCompare()6 r8 p- [5 i6 I
        {* c  P7 m4 S$ E
        }  ^3 a0 m9 j- z2 v! I3 g

8 M& B8 {+ {8 I7 b* c        //-----------------------------------------------------------------
+ g- v, U! [1 g        // Method for testing that class has been reached
0 ]% g+ @! [1 t* A        //-----------------------------------------------------------------        / u. S% d& D7 L: {8 L3 _

: R+ @+ }- w* W6 ~  p+ A8 c8 O        public boolean ProgramCompareReached()         2 W. u8 u* Y0 y
        {
4 K/ }. _, g: `, `: a" _2 h- V      try
2 P) e3 L4 o$ W7 A$ l   {        
  g/ L8 W$ K/ c. o) c5 D                       
' x5 l9 e4 L8 t                //********************************************************************, e1 H$ `- n7 e; ~
                // Try-Catch Statement is used to handle exceptions - such as file not found
+ z# T+ k0 i) P2 e4 w* H                // Reading the files will need to be placed inside a Try-Catch - just like this one!: g6 _% u, h# P9 ?6 {' r: }
                // For more information see page 534 of the textbook4 }8 ?/ s% v/ n* H/ L
                //********************************************************************
. W# p/ g4 S" z) U+ |1 A                    
. l- j% c. K* S' p        }
9 {, b. S  a2 _             catch (Exception ex) // Exception caught here and message displayed to the screen
: k% j) l' |, e          {
) K/ {4 m. x/ Y! S3 S* U6 a                    ex.printStackTrace (System.err);
! [( R( D' A$ [1 X/ [% D2 }           System.out.println ("Error message goes here"); // Replace this error message with your own         
: B' c3 L  u4 a% U& ^1 e$ H- |        }, H+ q. u. \. V! F
                return true;$ h# Z1 \- I4 i1 L) q8 k8 D
        }0 r& X2 D3 r/ I0 [! {
! }% M" K, n( j
} // end of class ProgramCompare2 h  S5 D5 M3 F1 C! k
% x4 }& K$ D8 h, S( H1 x/ Z) _
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
& s. m6 O0 e9 }/ E//  ProgramCompareMenu.java    Provided by: DRS. d3 u8 N5 l4 Y" D
//
, F' C( y8 t. i+ f& T2 i+ h//  Calls AuthorisedUsers.java and ProgramCompare.java8 x9 }% S4 {% k1 ?
//9 b# R% {5 W* j; `% W
//  Driver shell for Assignment 2.
! R7 G$ ~' {( X3 F4 R& j3 n//********************************************************************! _+ w0 ?  x+ n8 ^: X

- ~9 }* t# F0 W3 t- w; Tclass ProgramCompareMenu7 ?2 [) H# r- ^2 v) _! H
{
  z+ @: v' a) E" O0 g    public static void main (String[] args)0 |' W2 J+ \; H) P, c/ T
            {, s) P% E: h1 k" G
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable; k& Y  j: \. J! E6 m9 F# F
                ProgramCompare reached1 = new ProgramCompare(); 3 I7 f7 T3 i9 z! t* W# c
                AuthorisedUsers reached2 = new AuthorisedUsers();        % ]7 Z, s+ a& M+ e0 h
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
' G0 J# ~% o0 y' z( F                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
+ M: ^5 e, b5 U* _% T0 G* D6 @        }- f! O6 |7 x. Y
}// end of class ProgramCompareMenu  I5 r% [% x6 ?8 @! f5 C

* q2 R1 p/ z* h: C8 O! ^//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************, {# @6 C. c7 }5 d$ ?
//          AuthorisedUsers.java          Provided by: DRS
( e4 i& r" _, v' u, g! Y//               
& L4 C" {* |$ k! ~//         Program shell for Assignment 2
9 p! R2 k( A" y( I//
1 P/ Z* U' G3 `' ~6 m//         Represents facts about an AuthorisedUser% |# g* p' c- Q
//********************************************************************2 T6 `  M0 u" i7 C
4 D  g7 U0 Y7 u" a9 f
public class AuthorisedUsers
/ H! o3 L( a8 C4 z; g    {2 n/ I: P. M- C7 c' t2 ^

, k* N; x5 K  Z" e        //-----------------------------------------------------------------& h& x; t: p; W+ U1 E6 U
        // Constructor
! H8 w" a1 I6 o# |        //-----------------------------------------------------------------; i- R0 p3 {1 ?4 x9 P, J+ \

* a9 k4 h  s5 ]( R8 V        public AuthorisedUsers()2 s1 g5 m& O0 ?7 W! }5 D0 [
                {
6 d1 M, b, ]/ t! J  x( P, x                }
8 s! W* w4 @; I% H! ~! E/ ?% W' O" a7 [, X) g) T
        //-----------------------------------------------------------------+ w: O1 K3 W* Q* E7 k! T
        // Method for testing that class has been reached
& D, G2 r5 P; C2 E3 A0 c/ d# I        //-----------------------------------------------------------------       
4 ^. Z3 w  y1 c        public boolean AuthorisedUsersReached()% J5 C+ S& Y" |6 c( }
                {5 J3 M. v9 x0 K! M, Z
                        return true;                       
* p3 `% n9 a+ M, C                }
7 O6 T& i8 @* H1 j7 ^: Z. ~               
; \6 ^: Q, N! ?# a$ x    } // end of class AuthorisedUsers
* z3 |# q6 q  n3 Y! p//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming5 B1 e. Y  W' Q3 Y
Shanghai - 2007
' s: W. P, u. C' s% xAssignment 2; R; D4 U. [$ t% C
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)
" {# K) D: a0 x& o) {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.# O% N3 n! l6 q1 A. C! c0 _
The staff must be able to:
+ X6 @7 ~3 P) U9 c" q Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.! y5 k: }% o! r. H
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.4 h& y+ F" c8 g( |  z  R! S
 The interface should provide a menu so that the staff can:
1 D- G' A0 m3 i& Ca) Enter the names of the two Java program files to be compared6 X0 Y' N: K# O5 [6 s
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.  e" q& H7 h* a, t  ^$ |
** 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 w+ A. B$ g# Q8 aBSA104 Business Programming – 2007: Assignment 25 @* k4 ~- ~4 {/ `, h# ]. E
Page 2 of 5
3 c& L6 U" O: q: t; v# q9 z" s# ]# fb) Print out to the screen all the lines of code that are the same- p3 i' D, h9 ~: h+ m, X, Y3 I
 Include the name of the file and the line number of the code being printed for each of the two files
# g4 C( w3 h  |* Q" P7 f9 Gc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
! q* R, \# ^: n4 E9 a& n the name, username and department of the user( n) v, K5 r9 t* F/ f, h0 k) @
 the statistics of the comparison! o: n, K% Y4 w/ G2 t; X
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
2 _& {& g6 p7 I/ w& f. F5 r/ K8 c: b1 Q0 G the recommendation for further checking' g* l5 H  i8 [; p. h) `3 N
- 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
% j7 L4 {. v) U, U the names of the two files compared; R' b) ?; c( B5 p/ J1 B9 E0 m
d) Leave the program (exit)7 o* k: e# P' G) n9 ~2 h1 x, c
The ProgramCompare class: (Total maximum 20 marks available)
5 \) C; n, u; \' S! Z! U5 S2. 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)
7 _0 H' D# H+ z! n$ K& h6 s! za) provide an error message if the files are not found or there is a problem opening them
% I/ J7 H9 E! \9 g) ob) compare each line of code
; z, w# M, D  N1 z' b+ oc) print out the lines that are the same
: ]0 `7 x# l+ J- `d) count the number of lines compared / lines the same+ f1 `3 L- G3 T" _' l. c
The AuthorisedUsers class: (Total maximum 20 marks available)
9 X  y& a2 n& _" e0 @8 t; A3. 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)) C, b! P5 P" n( n3 o' _4 T0 P
4. Provide methods to:
' e. {' G, I1 J7 pa) 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
! ]: T! s, V" H! C9 ~% p+ Ob) return the name of the authorised user" O' }3 I7 s2 F& y  B5 q; D5 b9 t) ]
c) return the name of the department of the authorised user
, G# t0 k# O+ O- l5 O4 P6 V- y  {: gIndividual Data (Maximum 20 marks available)
, [1 U( o& v* I5 h5. 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 q2 r0 |+ fDocumentation (Maximum 10 marks available)
- i0 ]9 }8 \; b7 A6. 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 D) z1 a0 X1 C) P
BSA104 Business Programming – 2007: Assignment 2
4 v- i1 ~1 ?+ L, S9 A. X0 jPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
  _7 S0 e" u7 k( x, d. k不过你要翻JAVA的类库说明。你有下载没有?5 o8 f- v5 ~" x# _+ c, N
查询关于对比的函数。貌似关键字是contrast,还有compare+ q% U7 c/ ~- d: [, [% ~% R0 |) n

8 k" H  C/ ^- K# H6 s' W7 P[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
: K  J8 E- F- a5 z7 \9 H5 n  O: v可以下载到的 是 jdk-1_X_0-doc
9 @. J6 R( \1 n) `2 \0 N) K# {
# q- b; L% Q) o2 ^7 h[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-23 02:07

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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