找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1591|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急+ u f6 p8 x) M# C: o ) \8 `2 e" L1 `' 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 | 显示全部楼层
//*********************************************************************$ A; g9 S+ L! b5 z
//  ProgramCompare.java         Provided by: DRS
( }2 D# x, b4 D$ q8 q$ ~( {//" ?) x8 T, P! @7 M! W4 c
//  Program shell for Assignment 2
, O! d. b9 Z  m* }% _* g0 ~; k//
6 G8 i1 f) t, [//  Compares two text files line by line
) t. I& V1 R) n: E//********************************************************************** W: s2 ~0 v/ x3 M* f. C! Q" j
) F9 D: w% [. Y- t
import java.io.*;
' c/ f% n3 t, u
, F( s7 P9 n8 x' w: ]  tpublic class ProgramCompare9 y% `- q+ |' f$ k1 s) V6 k
{
: C% {7 U) G3 t$ }- `  _        //-----------------------------------------------------------------
; r+ N) K6 T' r5 j- B        // Constructor( V9 G3 n) \/ t8 \
        //-----------------------------------------------------------------
; C) Q8 D6 U2 H- A& ?7 N        public ProgramCompare()1 F8 d% p" L) C
        {4 k5 _- Y: H) ^( Z* V
        }
6 y, W; W6 ~! k
) Y& H. h3 @0 E+ ?) d) B        //-----------------------------------------------------------------
( k+ e2 J4 a, C5 d1 a        // Method for testing that class has been reached  u! Y4 K6 m5 p' y. K) M
        //-----------------------------------------------------------------       
7 c/ d2 x7 L: ?1 ?7 @+ H' Q$ U$ A8 ~. d9 M" v; l* o& u9 z6 F) f
        public boolean ProgramCompareReached()        
  O! f0 A0 N, v/ d6 N8 V- c        {1 z; i5 }+ U/ `8 l! X, J
      try
/ v, v. l) t; ]' [- w3 g2 P" j) F. |5 ?   {        
! s0 W3 H9 c9 l                       
# G/ X* B+ ?* M7 t                //********************************************************************
9 O! ^9 V* s0 Y  U6 K                // Try-Catch Statement is used to handle exceptions - such as file not found
- D8 [  h8 k) y' X  ^* h! p! o                // Reading the files will need to be placed inside a Try-Catch - just like this one!
' F8 g9 ]5 K/ G" R                // For more information see page 534 of the textbook
' m! a+ x4 n+ X  `# b6 E                //********************************************************************
+ P& r' {4 V  ]# q                    
6 J, J! W' z5 q- S        }# V, V) u$ I- I& u, D& Y) V
             catch (Exception ex) // Exception caught here and message displayed to the screen ) P* ?- V1 c2 f- z) B3 ]' X
          {7 m" u- K* x" F( |4 t
                    ex.printStackTrace (System.err);
$ b, Q. p+ S- z1 A( w5 i           System.out.println ("Error message goes here"); // Replace this error message with your own          ( O5 \0 ^  n* I) F
        }
  x, c( S: l9 Y3 z6 t* h( o* O                return true;
; ]( h( f6 Q7 O/ e# o        }
' Y4 u6 Z7 [- X5 K8 Q: o% `( k, v) B3 t" V9 j
} // end of class ProgramCompare
7 R8 n1 `; [3 K% C6 r
8 L& l4 o, ^) z& f//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
7 x- \2 d0 ~" o# U2 X. X//  ProgramCompareMenu.java    Provided by: DRS. |/ k: \' f. M. h8 O$ d! v
//2 c7 e0 ?6 Y! _9 X/ C0 h
//  Calls AuthorisedUsers.java and ProgramCompare.java
/ Y: V6 A- p5 t5 u. X0 S' g//
, m2 X0 d  v2 j0 t5 L5 L) [$ ^//  Driver shell for Assignment 2.4 r6 ~1 l, ~3 r! X7 g: U  S
//********************************************************************
! w5 u$ \8 H  h  P1 I- w
$ {7 C1 x, _* I( }class ProgramCompareMenu! W0 [# H9 }8 S- V( Y! v
{
4 W* M8 {* s" T1 F    public static void main (String[] args)
8 u# ?) \' a0 _; w            {% P6 B0 l8 ?# E( K  y
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
6 b' B4 R! Z/ {) x                ProgramCompare reached1 = new ProgramCompare(); 4 Q% P+ b) S# q9 K
                AuthorisedUsers reached2 = new AuthorisedUsers();       
; K3 a$ W- h4 s; h3 y3 [                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
  h  i' m9 |' H7 m                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
: ]1 v1 W$ ]) c( u7 M* ~        }! c$ J8 ?* C) s! H9 y8 W/ K( F- X
}// end of class ProgramCompareMenu
6 J  i3 V! h. p" l( X4 Q  T# `9 {- p  P$ Q3 p8 i: R
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
" l; |' p6 U1 A3 v7 N; d//          AuthorisedUsers.java          Provided by: DRS
8 Q  Z4 o: w% f) k//                1 e5 w" S7 C# d9 X
//         Program shell for Assignment 2/ ~6 y- ?$ A* u- D/ M/ r
//
( x8 P" ?. s- O2 A$ v4 a' s. C//         Represents facts about an AuthorisedUser
% [- N- Q( {0 {# D5 y//********************************************************************" @+ Z3 _  d& x+ ^6 j
3 c" x& y( y$ |% N3 c! S
public class AuthorisedUsers8 j) u3 {6 W" \: F
    {
# g8 @3 T* R& C. D* U& Y* D. H& M; d/ I, x( s" T1 l7 s
        //-----------------------------------------------------------------' T- F2 q8 W0 }- f6 s! @. H: \
        // Constructor
3 z3 ~: y2 H  O" w9 ~/ C/ @        //-----------------------------------------------------------------
4 \! s7 Z9 J* I7 ]% V. ], I/ s! P& C1 `1 \. U1 k/ I$ B. }
        public AuthorisedUsers()
* d) _9 \9 n3 W, O- D                {- [! F# O; s% i+ g
                }
6 P1 I' J+ q: Q* s0 s: k* J: [2 |' x
        //-----------------------------------------------------------------3 n% a2 E% n7 @7 l) b) Y
        // Method for testing that class has been reached9 ]+ m  a  m8 w
        //-----------------------------------------------------------------       
! D+ W- C' L; y$ [) Z  T        public boolean AuthorisedUsersReached()( l, c' Y. A& ^
                {( [9 _" f! s' a4 y1 m
                        return true;                       
8 A9 {% `, v0 O7 S                }, Q1 g# G# |5 V  p; f0 r# _
               
0 [* r. H3 T7 L# r% v    } // end of class AuthorisedUsers
( M& i( U* [: `( _6 e0 c3 Y" s# K, g//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming( \0 z2 Z2 c) ]$ ^
Shanghai - 2007+ ~6 y5 j" r7 }8 ?) Y
Assignment 2% B% ]( p/ l1 X& S; S1 q+ I5 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)! B, U; M9 G9 F# E
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.6 |$ q4 Q( X7 r
The staff must be able to:5 X: V6 X! l- X
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
: `( v- H+ {% W: y1. 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.( n% r* v: k: A2 F
 The interface should provide a menu so that the staff can:
9 E6 Z/ j% [* L/ a3 _! t! U7 X8 d0 ?a) Enter the names of the two Java program files to be compared
$ G4 o2 R9 D5 R( Z For this assignment, it will be assumed that the two Java program files are in the same folder as your program.8 n- `. ?* b# m  ]3 X% ?* K8 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).
& q) f4 d& s1 S( gBSA104 Business Programming – 2007: Assignment 2! B  F9 m: P* Z4 G
Page 2 of 5, g+ J5 [0 P- p  J+ B
b) Print out to the screen all the lines of code that are the same
! y) C4 M$ B8 I- A' { Include the name of the file and the line number of the code being printed for each of the two files5 _0 ~" u- ]$ t/ L8 R, d
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared# \' R0 {+ ^( p! X
 the name, username and department of the user
$ U: K4 ^$ l, p6 @9 z) a the statistics of the comparison) ~/ C  ^+ C, M- _' S
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different( [, @% X0 n4 o/ H: B
 the recommendation for further checking
( u8 z6 y8 a/ s7 k9 _- 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 closely6 \, Z5 K$ w# A# J: h
 the names of the two files compared% m# V" J; @/ F- }9 K7 V- Z0 o
d) Leave the program (exit)
0 ]. T7 p* T( \. u7 B9 `8 |* EThe ProgramCompare class: (Total maximum 20 marks available)3 ^8 M5 ?  g& S
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)9 c1 ~3 ^' I9 m1 O0 I# @
a) provide an error message if the files are not found or there is a problem opening them
  J0 C- K8 ^& t- eb) compare each line of code+ z, [8 x/ E: d  K* l4 h. o
c) print out the lines that are the same
7 I( j3 Z. p. P% R* x6 n) {d) count the number of lines compared / lines the same( P4 F6 n% }2 y/ `1 }
The AuthorisedUsers class: (Total maximum 20 marks available)
; b; u* S7 S7 w6 q3. 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)
! d4 c* S3 w( Z2 A% @- T. @4. Provide methods to:
5 h0 J; Q! ]( b/ z9 P( B/ g' `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
- l/ [/ R% B+ Z2 f8 [" nb) return the name of the authorised user
. _4 ]1 h$ p" B% c6 v" j, ac) return the name of the department of the authorised user
* |, ]7 Q+ |% m5 L4 v6 DIndividual Data (Maximum 20 marks available)
+ s% m% X- B7 b: I0 X9 H; D& v5. 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.: l! \" ]7 f- H1 a) a6 _: \
Documentation (Maximum 10 marks available)
6 C2 J1 Z9 U/ f6 E4 N4 |7 e6. 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.1 W  A- B7 f& T6 k
BSA104 Business Programming – 2007: Assignment 2  W! y& X5 H$ g
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了, \) C5 K0 h/ |5 q# h; M+ }7 `
不过你要翻JAVA的类库说明。你有下载没有?, p7 m' y6 o- {4 J* e
查询关于对比的函数。貌似关键字是contrast,还有compare
0 `* |6 m' \# V9 Y4 U4 V
0 p3 O7 b7 ]9 X' b% C( ~# J  y[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -: y* v; N! V- v& R! i
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。4 g+ y" ?- g: b/ X
可以下载到的 是 jdk-1_X_0-doc  H/ `! b8 q2 X, M
+ ~' T) t/ x1 B0 i
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-30 23:25

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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