找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1608|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 # A. f- Y3 {0 }+ P9 M5 g; ^3 y ' `+ u3 m3 L( L+ q% v7 c+ U# C" @
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
6 Y  J+ ^2 E; ?) e+ d" P9 ~$ o//  ProgramCompare.java         Provided by: DRS- C+ _" O- x$ B8 H# y: D( ~, ^
//1 U1 _. O$ \5 x1 m# E, H. ]* B$ e
//  Program shell for Assignment 2& J9 R# T9 U, V3 m  I1 C4 K
//$ Q) Z/ G9 W1 H" K. ]
//  Compares two text files line by line0 t9 D/ O  i: t
//*********************************************************************
; r  F7 c! a2 |( z$ F. B' E2 X! ^- H9 \
import java.io.*;
/ C) ?5 k* y) a4 |2 n+ t
  X$ `4 ~* O: \. x  Q3 mpublic class ProgramCompare
) @5 E. K1 |( I* J/ f& u{" M0 v. K& e- ^& G$ m
        //-----------------------------------------------------------------
5 F3 U" Z! O" ~& b" I: p( f2 U, E        // Constructor* {* g! L" T0 ]  o
        //-----------------------------------------------------------------
: h2 d  d: g9 `        public ProgramCompare()% b5 v: W( V  I2 B, m" e) O4 ]$ J* C
        {% s/ p7 c2 u2 H+ c
        }
7 U4 q4 [# q; |% k$ x
* @+ r) l& i# e4 |* C$ Z+ O        //-----------------------------------------------------------------
* e' a* |% t) w        // Method for testing that class has been reached
) g* F1 j* V8 R) r        //-----------------------------------------------------------------        2 O0 g( s% p. F: e& C- c5 d0 w

+ f8 f: l) `1 f+ ~: \& i9 Z" P0 [        public boolean ProgramCompareReached()        
4 {. m- }0 V3 V        {
/ d  D( m9 U. h/ ?      try ! D4 c: P: ^8 P$ w+ K5 R3 P
   {         ' I5 o' ~* A6 M6 Y1 c4 F' F
                       
/ t$ @' U6 F& B) i$ J1 U                //********************************************************************. p" S5 C( n2 W; |3 R4 q
                // Try-Catch Statement is used to handle exceptions - such as file not found
# U; H3 I. D1 s' w& i4 \2 q# ?                // Reading the files will need to be placed inside a Try-Catch - just like this one!: @3 W6 `! ~& _& A- `# v
                // For more information see page 534 of the textbook* X, e5 b  F3 }7 y9 e. [" C' y
                //********************************************************************
0 y$ `  q# l- W* |: H5 c  [                     ( {8 B  A% q7 h
        }
4 m5 I! ^! y' J. b3 y5 c             catch (Exception ex) // Exception caught here and message displayed to the screen 4 n7 {# P4 i9 G
          {' L+ C5 n5 C9 B) W2 l
                    ex.printStackTrace (System.err);
1 J* _0 o, [; V5 J/ K5 r8 r+ ]. ]# Z           System.out.println ("Error message goes here"); // Replace this error message with your own         
0 G& t/ ?7 K1 r6 a/ r  q        }! x- k- e! f# d3 P0 v" I
                return true;4 V8 z6 F9 q. ]
        }
; K3 R- ]: [  t2 y( s  H9 q8 y1 s$ w9 x! l
} // end of class ProgramCompare
* l/ v. q3 c3 ^
% ^: M0 n6 \# V; r& J//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************+ v( I" y3 k) ?4 W) g  a+ o5 Q
//  ProgramCompareMenu.java    Provided by: DRS
( z! N, K1 k; C* a3 ^2 q0 b% d//, P! E- S/ l0 G3 m0 l: J8 ?5 }9 c% o1 G
//  Calls AuthorisedUsers.java and ProgramCompare.java; P; E/ g3 S. Y5 `! f' g$ f' k1 Y
//7 D8 M+ K% n3 U8 Y3 x, I# E
//  Driver shell for Assignment 2.
! m. Z' M& @7 u" J) o! y* q//********************************************************************
* J# b+ J* g! U# U* Q
0 n; F5 p/ ?( v0 R/ ]; f. Z2 T8 Cclass ProgramCompareMenu
; M( H, |* z3 E{
, J1 D8 f/ p( ^0 Q    public static void main (String[] args)0 n' _, a" h( Y4 \+ ^
            {3 H8 ~! a) O1 Z1 x# k, p
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
5 M% r4 K, G: D6 ]- \                ProgramCompare reached1 = new ProgramCompare();
/ X; b& u/ S$ {; n, b                AuthorisedUsers reached2 = new AuthorisedUsers();       
/ n3 U9 C" @5 k% D* ^' q; x5 A                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
0 `1 Y' d, z8 ~2 d8 c                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        # z& v% \! }" @( u2 [, Y3 ~( X
        }
) U8 n6 h( ^! O' _& h" I}// end of class ProgramCompareMenu
; Y* }& C) h5 _  m0 Y) U* h- B, Z
. F, B! o" R8 `8 d5 U/ I1 k//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
4 F) `$ s% S$ W5 N" }  Q//          AuthorisedUsers.java          Provided by: DRS
' V) u2 @& u. U5 ?0 l//                4 y& l9 I/ V$ M# _; F' ]4 |
//         Program shell for Assignment 2# b+ G( P$ w: S
//
7 `- \9 ~8 H2 X0 Z* _//         Represents facts about an AuthorisedUser
, q/ _3 F- H8 ~' t7 d( z: q//********************************************************************
- W& E" ~* s, L3 d! E+ T
2 j+ X' C/ t* A0 I1 Upublic class AuthorisedUsers
( t2 g2 O3 [9 I  i! l9 H    {1 g- s! r; }$ l& b/ q
$ R4 V' Y' K( \0 ?- ]; X$ P4 h
        //-----------------------------------------------------------------
5 @0 G( i; `- f- p7 E0 I* d" ~        // Constructor6 a- _4 d# C3 p
        //-----------------------------------------------------------------$ R2 f' q5 l: v0 T

# u* V5 ~8 K, |+ J        public AuthorisedUsers()
/ k. k: C2 t  e1 z# \; r                {
" U2 k9 h1 [; J# a' V* c* Z+ y% o                }
$ ?. m- C6 C4 Z- a2 m& @5 |, T5 a/ l" _
        //-----------------------------------------------------------------' V/ o% t$ _. i( b; G0 @
        // Method for testing that class has been reached' o8 a3 e7 X' X( O# w( O8 v3 `
        //-----------------------------------------------------------------        + f" e" X! l* j4 ^/ C
        public boolean AuthorisedUsersReached()
2 M/ x/ P. ?; m- q3 {$ w5 z                {
0 H: ?( W2 w6 K) c  C' ]4 H                        return true;                        0 m8 G3 W6 ?: X4 d' x9 ~( \
                }
- k+ q  i( v3 E1 ?9 }                . c7 u, F0 n& L2 [0 B/ e
    } // end of class AuthorisedUsers
* v8 z1 h$ h* p+ Y+ a//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
2 M& R( z! k% _; K' o' y7 D6 M8 KShanghai - 2007" P8 W: g$ C5 j1 a% a& ?) H1 t
Assignment 24 r  ~8 K5 ?9 O5 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)" l( z1 f5 |) k! A* ]: d  J
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.2 S/ A& j* r- ^4 r2 _
The staff must be able to:
, s$ F. W8 M8 V& ` Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.2 T- K5 S7 L# y( C/ ^8 V' q! c
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.
% H3 Y5 v7 C& R3 B$ J6 P The interface should provide a menu so that the staff can:, S* `. b3 U; B: K8 ~
a) Enter the names of the two Java program files to be compared4 i6 B" a, C: I) }! n  w
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.  J& u$ }1 m; m3 x) X% m4 B
** 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).
* O+ u  X: `* Y( l4 FBSA104 Business Programming – 2007: Assignment 2& J7 I  j& K2 Z/ b
Page 2 of 5
: c& i" L3 F+ Z3 hb) Print out to the screen all the lines of code that are the same
. [' }* n6 e; m& B' ~, ~, m Include the name of the file and the line number of the code being printed for each of the two files
, w1 ~) m2 \2 B9 Oc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared1 l& v# E" |* v8 Y' `' p1 Q4 {6 L
 the name, username and department of the user
  R7 j* o4 u8 F7 z9 l the statistics of the comparison
% K% ^1 s: A, b( \4 z- R+ @) X% z- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different! E2 k& p8 {1 F( H" J( ~* Z: d
 the recommendation for further checking& Z5 o$ M$ N5 u% u! h
- 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
& N1 x1 ~6 U+ T/ _$ y( I/ _ the names of the two files compared6 x# z! k  y* C- |' A: V
d) Leave the program (exit)
1 L( t& F, j" e$ h* a  R9 V& gThe ProgramCompare class: (Total maximum 20 marks available)
/ Q+ e6 O! q! e8 J% c2. 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)9 X6 i% h. Q5 a- p% Y
a) provide an error message if the files are not found or there is a problem opening them# e1 S3 P4 z* j2 K5 W
b) compare each line of code
7 C) `3 X# V- ^2 v1 X# ^7 v+ vc) print out the lines that are the same
; ^8 j' ]/ }* _9 gd) count the number of lines compared / lines the same3 ]% I& L" I0 a. e% {
The AuthorisedUsers class: (Total maximum 20 marks available)2 K$ N% Z; C+ `7 ?5 ?" d: L
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)' x2 z, c) i  g$ I, J8 x3 p
4. Provide methods to:
% {2 Y* e( U$ o& x( W/ M3 wa) 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/ n/ Q% v. p
b) return the name of the authorised user0 G: N% e  A( ?* B3 c8 d
c) return the name of the department of the authorised user
$ J. F" i% {8 M# LIndividual Data (Maximum 20 marks available)
0 R/ k, ^! }' d; J3 C' z5. 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.
. B% |3 T2 B% n7 d, j9 S& t8 q  ~Documentation (Maximum 10 marks available)  l2 {9 ]- f, p
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.* p4 ?2 l# Z1 P. X; j9 O: y0 \
BSA104 Business Programming – 2007: Assignment 2
* [( K: @. B2 d9 q4 V  {Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了8 x1 L4 X& Q% \  D& j( h6 k, O
不过你要翻JAVA的类库说明。你有下载没有?0 }5 Y' F0 i* E" O9 a5 H3 \
查询关于对比的函数。貌似关键字是contrast,还有compare* ~4 K( O; H' g

3 a: R8 p7 m  F/ ]& e  G! W[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -. ?* V' R9 U2 h- R8 R
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。2 o) U( p: P/ V; v1 h* \& w2 u
可以下载到的 是 jdk-1_X_0-doc
5 i" s- z6 I- h" {# F7 U+ Q
9 U* W, p2 x2 U[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-6 16:12

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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