找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1042|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ( \, Q8 S7 R- G2 P3 a3 { ! i2 i; a$ c& N7 l. n5 f& z. A6 p
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
* k3 I, g. ]/ h5 S- q//  ProgramCompare.java         Provided by: DRS
; g% c% x; J& [% u& c+ Y//7 I5 l) o" U8 [  u2 V
//  Program shell for Assignment 2
" k1 a0 K; P) z. }! M5 R//
0 O( A4 {8 m, `/ ]" F//  Compares two text files line by line, f2 o3 \' P# ]! R( N, q& a
//*********************************************************************5 R: }- a! \- f( Q; {2 \

; |5 I1 _! |/ ]' j$ `import java.io.*;  n6 h" k6 `" ~
9 s+ E# g0 G6 |- X, R/ J& A1 k* a
public class ProgramCompare: G  F8 J& C9 {% K" z- E/ {
{
% V2 ^6 k% q* A+ L6 I5 h        //-----------------------------------------------------------------9 Q2 H* q) S* i3 f/ B
        // Constructor
9 _8 a. B3 n1 F        //-----------------------------------------------------------------
7 e: r8 K% I0 D" c9 n3 W        public ProgramCompare()
  j; {& k4 d* w" J& n* _1 @        {
& Y% E  E( ]# R* D        }6 C1 {4 ]$ o+ c; }

' B3 {& W$ A( p        //-----------------------------------------------------------------( j7 ^, _0 A4 g- n
        // Method for testing that class has been reached
! T" H6 p; s. x5 O* ^8 m        //-----------------------------------------------------------------        7 i$ ]2 v. H4 y; f
! y/ g# ?( n0 D) p3 L9 V8 V1 ^
        public boolean ProgramCompareReached()         + W9 B' S  U8 z
        {6 l% z+ [7 ?* g. m: t, Z# E
      try & F$ J( ]+ b+ s( n
   {        
4 b0 @  u5 g5 a                        8 D* r: N8 J$ L& J' f8 P
                //********************************************************************1 z4 E6 L- `' X! i8 e  w( P9 e
                // Try-Catch Statement is used to handle exceptions - such as file not found
4 r9 G1 Z9 Y& r8 y% {/ y" j. p                // Reading the files will need to be placed inside a Try-Catch - just like this one!& F6 e1 S0 E# d1 Y7 Z1 z4 y/ [
                // For more information see page 534 of the textbook
/ I6 ]$ y2 A1 [" k                //********************************************************************
; W. P) ?& p1 Z7 \9 D. `                     9 P# k1 u/ H- j) `5 N- K5 n
        }
3 b5 T! c% b( q/ |( u$ O             catch (Exception ex) // Exception caught here and message displayed to the screen
7 m  U/ _8 P' n          {
8 Z" Q9 n, U3 j$ Z4 b/ L$ P                    ex.printStackTrace (System.err);
1 ]7 S8 g( g( K! U% ~! |$ q5 x           System.out.println ("Error message goes here"); // Replace this error message with your own         
/ D8 `4 v7 }# H/ r! O* W6 f        }  M3 n& s( h* P! Q9 s8 e
                return true;
8 M$ O2 A3 ]4 {0 G4 S+ k4 @- ?8 Z        }
; X* e: h5 a# b9 F) Z0 z8 z$ K' w2 _* c$ B# Z  Q; O& Q
} // end of class ProgramCompare
- T% y+ G+ r. A% v% K
* t, z3 N: @  q/ e* `$ {//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************0 i% O! n: J" z' i
//  ProgramCompareMenu.java    Provided by: DRS
1 S* N4 J* ?2 x1 y//
# t: ?7 h. Q( C+ c//  Calls AuthorisedUsers.java and ProgramCompare.java2 @: n% M0 y2 {
/// |. n6 A: U! K1 v2 G
//  Driver shell for Assignment 2.$ ?2 v) |# b- c& p1 A9 L& F
//********************************************************************
6 T4 l! }$ {, b8 i3 c4 G% C' [5 S/ T% @, O$ w
class ProgramCompareMenu
! Z0 g( N6 x( H% o1 z" U{
% k! q7 j( X8 \    public static void main (String[] args)
1 |$ `4 c' ?5 p2 x0 C. q* M            {
! U: f/ r: {  ]8 R1 P! ~; D& C                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
8 g# n4 b0 v9 L( X                ProgramCompare reached1 = new ProgramCompare();
" O: v) r( z8 G* K* U                AuthorisedUsers reached2 = new AuthorisedUsers();        % t2 P1 {0 F$ w( V1 K) ^
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
2 [( @8 s( N" s* N: \; F                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        3 S+ O( h, p4 s* {' z
        }
+ n5 N' ^" q1 j. d/ X}// end of class ProgramCompareMenu
) S; y- E3 w7 v. T; A. b' J# @1 L( j' K) V5 y6 @7 F2 H# r
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
  \$ M4 c* ?% m//          AuthorisedUsers.java          Provided by: DRS
% H) y" e( c- }' y+ j- d" a7 K//                & F5 x& ~7 [' j2 C1 q+ q
//         Program shell for Assignment 20 t; M3 c- f' r
//
: G1 p& J5 {. e2 X//         Represents facts about an AuthorisedUser
- H4 j9 k* n' ?; G//********************************************************************
3 d# q6 Q3 @; U! v4 w# k  C; v+ ]6 R6 B
public class AuthorisedUsers
9 {- I* O3 x* R4 C' _! h* u8 g; x    {
0 k* V' z0 _) `% m# U. ~" k  x8 r6 G+ t2 [  e
        //-----------------------------------------------------------------* O3 u9 h! A- B* _4 ^/ A* p
        // Constructor
8 [& z3 \, I" h0 f+ t2 \        //-----------------------------------------------------------------4 u( Q1 z- L# o7 E1 d

  X' c& r4 V$ q; @8 G! ?0 H        public AuthorisedUsers()
- F! O/ e+ B' e- b$ O                {
2 f" }2 B3 }% e7 J& q- P                }
  N/ n9 w, p# V$ {9 t' A
8 n' X' N# c* D/ P        //-----------------------------------------------------------------
1 m9 H: V0 _( G2 x        // Method for testing that class has been reached# `" x9 {9 R3 G3 s- J
        //-----------------------------------------------------------------       
; V( L" s* J& ?6 a$ g$ q        public boolean AuthorisedUsersReached()2 l, g( M) V8 L; Y: o( D
                {
+ s- Y1 M9 Q5 t+ \0 t% m8 L7 X                        return true;                        / }  n( ~$ i4 f6 K: l0 W( D
                }
' K5 ?1 m0 t# W- b9 N# p! F               
8 R; l+ X1 h" v2 B, X) S4 ^& T3 n    } // end of class AuthorisedUsers
0 {2 m* T; s) h2 T9 _, O//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming" [4 \; ]& Y1 t  q& t* u* u
Shanghai - 2007
. A* r4 o( y2 k7 H% l; KAssignment 2
" j) T' p% l8 h1 ]% J0 U' sDeadline 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)
8 z2 v+ f/ @" a9 k7 _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.
: C, R  ]/ w% Z3 u. K1 r1 nThe staff must be able to:
  @3 g, v+ p0 }1 o( {9 z# [ Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.3 a+ s+ [2 j" w& j. W0 E
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.  x1 s$ w# {2 T3 Q  n6 r
 The interface should provide a menu so that the staff can:
: y& T9 S6 ~6 da) Enter the names of the two Java program files to be compared
: s0 Z7 p/ P- i4 L& _# A For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
9 y6 @6 B/ I$ M& R** 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)., Z* k, J1 c0 l! i! G3 i' H
BSA104 Business Programming – 2007: Assignment 28 C3 T* k- I) ^& s- I
Page 2 of 5
! N" v- o1 Q# L) Rb) Print out to the screen all the lines of code that are the same9 t! b: k, `8 Z' F3 x
 Include the name of the file and the line number of the code being printed for each of the two files9 D2 ?: C. o# A* M+ a
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
; H' T" P) f8 C4 S" `4 p the name, username and department of the user
; h$ o. k* S$ o1 Y& i" D the statistics of the comparison) f6 Y$ V3 w. o5 n* f, z- L# Q
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
2 o* }2 H; V9 g6 D the recommendation for further checking
* D+ _1 n- {+ a6 o9 j5 L- 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
! ?$ A  D$ b1 U" t; p+ m( E" t" c the names of the two files compared. b& t3 ?; U9 i) b- v, n
d) Leave the program (exit)
& s) l2 `! D- C8 C9 sThe ProgramCompare class: (Total maximum 20 marks available)
. ]- D+ w) K- d2. 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)
* |! V: q2 @" da) provide an error message if the files are not found or there is a problem opening them
* o! V0 E& w( lb) compare each line of code( b/ L/ R) Z+ s9 }  h+ Q
c) print out the lines that are the same6 R- m5 ~/ t% d& l
d) count the number of lines compared / lines the same; s% p/ [2 z& Q7 f
The AuthorisedUsers class: (Total maximum 20 marks available)& w) U8 B( a8 a6 w  n
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)
! S9 T0 n1 N! ~' x& b4. Provide methods to:
+ s8 r) d2 m+ l6 Aa) 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
# N+ K, _3 h2 _1 d$ \b) return the name of the authorised user
: [& G* v8 l$ g4 }) }# qc) return the name of the department of the authorised user& f/ O/ h% U- q5 }
Individual Data (Maximum 20 marks available)
0 S" T. m( u- G% z9 g& e, ~0 b5. 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 \6 T0 v% w4 B  WDocumentation (Maximum 10 marks available)  _) Z' J2 Y+ _- J
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.! V: P% Y; b& |9 r# Q( n1 Y
BSA104 Business Programming – 2007: Assignment 2
4 t  `8 A9 S2 [) v, o; ~Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
+ t4 a# A3 ]8 X- |% G不过你要翻JAVA的类库说明。你有下载没有?9 p- R, j0 I$ D4 X8 q2 M8 U" _( T  w
查询关于对比的函数。貌似关键字是contrast,还有compare0 ]8 w6 @$ Q/ }6 y
3 f' L& f" J" D& m
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
0 d2 r  D* o4 e& f3 F痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
' Y  H+ s7 O6 i* |7 b0 `, D可以下载到的 是 jdk-1_X_0-doc5 O" q9 I/ a, K  O3 N5 c* a

0 Y" ~& u2 m3 q, w8 O1 R[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-13 13:30

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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