找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1495|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急7 i8 n b: t3 V' u$ k6 ?5 b n l" B& o* S, u% {4 i& M
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************9 R: x. s1 M( J/ W- I- m2 q0 K
//  ProgramCompare.java         Provided by: DRS
5 x  @* J: g4 Q- y//
# Q8 d! z) G' d  h+ {//  Program shell for Assignment 2, f9 |" ]- Y# I; E: W2 l1 g0 t
//
- z8 L0 O: |( W. L; O. `2 @//  Compares two text files line by line  Z* p9 H, C" K0 Q! s8 r
//*********************************************************************
8 \% [, a& a& q0 Q( a0 ^: n  Q% D6 J: x" Q, K
import java.io.*;: x/ J* f; H. o; W* G6 u

, L" \* ^) O# |% v' epublic class ProgramCompare
2 u2 j+ q; `* U! n6 h5 I+ W{
" [* v) P/ V, u3 o        //-----------------------------------------------------------------
" D+ I5 T3 h$ o  d! e        // Constructor
, ~3 T! h+ ?- K: J9 \" v        //-----------------------------------------------------------------' R& D" E- {+ T5 z
        public ProgramCompare()
# N8 V- |. x- d$ k, x        {/ W2 ^+ c6 c) C
        }9 t0 T  Z0 r9 W3 Y4 U( }
" S9 D! u" p$ @  u& n" R
        //-----------------------------------------------------------------
  v. M0 |0 E, C% {4 a/ [: b) z0 |- d        // Method for testing that class has been reached+ w& O2 [9 P9 T" J
        //-----------------------------------------------------------------        ; E& ?% I7 K! X. j. J- r+ e, `

5 U4 L- h' [7 Y9 i! X) `- E        public boolean ProgramCompareReached()        
" {# Q  @) C- _; W3 `. Q        {
* Z1 A. L$ u2 ~+ ~$ a# X      try $ c$ O; Z$ J1 H' n
   {        
! M" c9 M7 R2 H0 {0 E" h, G8 G  {                        ; Z1 Q. _' ]) ~' @
                //********************************************************************1 }: Y* E/ |6 n! E$ B5 h8 ~: Q
                // Try-Catch Statement is used to handle exceptions - such as file not found
! ?, v$ ^. a& X                // Reading the files will need to be placed inside a Try-Catch - just like this one!
& O0 c0 u$ d$ e4 d; h" \& Y                // For more information see page 534 of the textbook
9 g/ n/ c; g9 g                //********************************************************************6 E% G  h+ D& B) R
                     0 Y& H* A$ I/ c: R, z4 M# g
        }
) r0 L9 r4 K, p8 s( c4 L9 t             catch (Exception ex) // Exception caught here and message displayed to the screen   |2 k0 ~! p: f& Q3 b
          {
3 p& R2 K* A6 x* X/ {6 G                    ex.printStackTrace (System.err);
( P$ a8 E; K: X3 n: T- F           System.out.println ("Error message goes here"); // Replace this error message with your own         
, J) e/ l8 V* Q1 d  `# ^* d        }
% z- G3 r* i; f) z4 z* L5 n                return true;
" ^% t! ]$ k1 z7 \7 ?/ s# q. o" i        }! S# }- J  Q7 j3 z" s' v

3 q" o& ^8 X* \& M2 [/ J  y} // end of class ProgramCompare5 p1 o" {* q0 S' \8 t, V- F
" ^/ k* _/ i  \/ o1 E
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************& k$ a$ x) i$ N# G# f( J" a/ A
//  ProgramCompareMenu.java    Provided by: DRS0 g6 l% P' X- e! r) H) z
//$ ?" c' F3 B& v! v! ?. {! ?7 l# w
//  Calls AuthorisedUsers.java and ProgramCompare.java0 G: u# W4 a6 b6 @# T- M" @
//
! B! B# z0 ?6 K% d0 K: Z9 X//  Driver shell for Assignment 2.
- Y: o5 @4 ~* c' W; B! E3 m8 \//********************************************************************
; j& g" g0 H4 O: i0 F* V! m
& J. d- C6 c- t8 j  Pclass ProgramCompareMenu" {; r! k) H; c# }) ~2 e
{
. m3 J% Q1 ~* a) P    public static void main (String[] args)# @& D  d; h) M+ H
            {
6 T3 Y2 r- B3 N6 P, E8 G& R                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
" a7 x) v1 X7 y7 u/ z                ProgramCompare reached1 = new ProgramCompare();   M& g3 C! ]; B
                AuthorisedUsers reached2 = new AuthorisedUsers();        " A$ k7 @$ q  ?( Q6 d  q8 d
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());  c& Z' G7 i8 d! j& x3 }3 D% k
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
( |: A2 o& q* j9 C' _( J8 \6 l        }
& `: Q6 Y2 }9 C}// end of class ProgramCompareMenu8 x+ C7 O, m$ i: ^- R

3 q" S1 c9 e7 |$ H( {//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
: v. a+ l8 a1 J4 s$ R/ E//          AuthorisedUsers.java          Provided by: DRS
- U* W9 ^  w& h0 `+ h//               
9 k2 I& D2 e) W9 X; p//         Program shell for Assignment 2
# I% f9 Q" g+ ~//2 T% L) v# [" O# a2 F# a
//         Represents facts about an AuthorisedUser$ S: _& L3 g( p, i% I
//********************************************************************5 W; v3 h& n1 k# |
' x1 K9 a6 \/ [' U
public class AuthorisedUsers
8 g1 b4 B2 E4 m    {, W0 o+ R' x- E2 l2 F. }
- Y3 Y% ]( U* J5 c, u. t) V# {: C
        //-----------------------------------------------------------------% y  {3 b8 z/ Z( ~
        // Constructor
0 F7 c: L9 e& p        //-----------------------------------------------------------------9 {/ n1 w. i# D& F8 L

" D% k, L4 a- w  g/ M+ [# K" J( w        public AuthorisedUsers()2 z4 N) N$ c6 c/ Z/ w
                {6 h  i- p5 ]7 \, M1 e  ~/ e$ i
                }" h: A( F. N! y4 i: ?$ Q* @4 @

# B: E9 Q' @6 C0 b, k8 O  G        //-----------------------------------------------------------------' [+ J. b( X& D; s1 b
        // Method for testing that class has been reached9 d) q; U. u8 v) W! w7 O, L; x
        //-----------------------------------------------------------------        7 e2 e, R  e# P, q+ w
        public boolean AuthorisedUsersReached()
; y% g: E. l' z4 \8 G4 w                {
$ f- p3 v* G" P) n) K: r) h                        return true;                        ! Q3 [0 l. z& o5 ]/ Z
                }
" m3 N$ ]3 P9 g, f                6 w3 f( n* ]: J/ r: K$ d6 W# N
    } // end of class AuthorisedUsers
' b8 s& x, l& u( g//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
' p4 @: K: y4 WShanghai - 2007  f* f1 a5 u: u1 l$ C
Assignment 25 _1 H5 P& M& l6 V" n! V
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)9 i- Z9 W& _4 S0 U2 e3 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.% R+ p6 I( a8 l# |
The staff must be able to:
( ^8 a' X" J( ?, Z! |2 x) F Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.* o- S. ]! F6 \
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.5 r- E( G; K: |  \
 The interface should provide a menu so that the staff can:
2 H% P; X' r, p+ Va) Enter the names of the two Java program files to be compared
" l& x: x& R- ?2 [. E For this assignment, it will be assumed that the two Java program files are in the same folder as your program.6 P3 w8 g5 C5 W! C
** 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).
' `) \+ d  q1 j& z1 |BSA104 Business Programming – 2007: Assignment 2
+ f1 F7 k3 r+ D9 P) u/ `Page 2 of 5
( @4 F9 Y$ {7 i$ O) a8 kb) Print out to the screen all the lines of code that are the same
7 s) m2 v2 g$ W8 \, d. y6 Q4 N Include the name of the file and the line number of the code being printed for each of the two files* @# W  W' m4 ~% F* l- c
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
% t* F$ a# I# N- |" \) \# Z: m# [ the name, username and department of the user
& f; ~  x- I+ ]4 T8 Q the statistics of the comparison
; T4 w0 P4 ?+ ~% O8 V% t- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different6 l, o+ u9 t3 O# w6 A# }8 S" j
 the recommendation for further checking
$ E' D) y) k2 g- X- ?2 G- 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
- o. ]& G3 M; R7 ? the names of the two files compared9 v! n, ^9 h/ r4 d( y% i
d) Leave the program (exit)  k" ]9 X9 l, W% j, t
The ProgramCompare class: (Total maximum 20 marks available)3 k2 y# Y* ]& N4 ?& h+ o- h
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)" v& Z/ B! U: {, H7 ~: h  q" _
a) provide an error message if the files are not found or there is a problem opening them
3 y% Z/ Q2 y& w1 Rb) compare each line of code
: y( U1 o/ w! _1 L* Jc) print out the lines that are the same
5 ^4 ~4 h/ ~7 i8 `5 e/ c5 ud) count the number of lines compared / lines the same
7 Q5 c! b! I( _- A% AThe AuthorisedUsers class: (Total maximum 20 marks available)( s5 }( Q- z9 }  c
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)4 `/ p% J7 b, V0 I. h
4. Provide methods to:% \. G& @5 @9 o; W, L
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
4 L+ h$ T4 o) s* N& |% \/ Rb) return the name of the authorised user
* ^+ Z. e) I: rc) return the name of the department of the authorised user
# t  F9 m/ \7 V% U% g. dIndividual Data (Maximum 20 marks available), L" H: l) T* ~% @
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.8 ?' C* y! Q$ W$ n! C
Documentation (Maximum 10 marks available)
/ X) E- t7 y, R0 w# L6. 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.' C& C: K" H4 W8 \
BSA104 Business Programming – 2007: Assignment 2! w( a* K- R" t0 n6 G* \! u8 L
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
9 q1 n6 C$ ^# c) d8 W不过你要翻JAVA的类库说明。你有下载没有?: Z* D$ t5 q0 u6 M+ l
查询关于对比的函数。貌似关键字是contrast,还有compare  [% G# K# s, v6 |' O0 b2 N
/ y# q& m3 O' U; e0 k1 v
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
$ r( Q% r: }8 X& z; }; |$ w* C% n可以下载到的 是 jdk-1_X_0-doc
7 G$ A* U. a+ o6 B2 H' l
, h5 n' y% |8 F2 ]  S[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-27 05:33

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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