找回密码
 注册

QQ登录

只需一步,快速开始

查看: 985|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急* y* e2 B$ O7 A' I/ k& [; _ ! c. U/ s! j0 u/ [
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************/ j) [. D2 z! C$ G8 U" C
//  ProgramCompare.java         Provided by: DRS
9 J7 ?: M! C; [* Y8 U. D//0 P) @9 v0 K  o7 [( w! O- C- i. P4 t
//  Program shell for Assignment 2
0 A: c, W+ l6 i//7 v$ @; O  [7 y8 p7 t' b: M* S+ p
//  Compares two text files line by line
- ]8 _- `- R/ o2 l  y//*********************************************************************
' _0 i. S4 e3 z: p! G
0 A" P2 Z# j9 ?7 |9 fimport java.io.*;
& z# E' Y3 m7 o- e* r7 {+ n. K4 r
public class ProgramCompare2 s) f- a6 u5 w. D- ?% o$ ^
{( Z5 z* q' g  J7 [6 x
        //-----------------------------------------------------------------
7 \: {- G9 [8 j. Z* [$ K        // Constructor! j  u/ s2 m3 k7 L
        //-----------------------------------------------------------------
# D2 m- Z: K% h0 ^" Z        public ProgramCompare()" y& U/ ]" s& O( l' F& d
        {5 s5 \3 m3 U6 U5 Q$ I- b+ j3 i
        }
0 |" g- x8 K6 Q7 `( i
0 f1 i9 g1 v! L% W. P  ^5 S0 F        //-----------------------------------------------------------------+ K2 s1 X: v6 s5 A9 b! l4 h1 ?
        // Method for testing that class has been reached: N  M0 p! [+ R% j) D
        //-----------------------------------------------------------------        ; u. R& E4 I+ D' `/ v+ T

8 f  n9 U/ j# a$ c* X# N9 R        public boolean ProgramCompareReached()         8 r9 {: D& ^0 a7 r8 F
        {
$ ~, {6 v( w) B* C% B) i      try ' u8 U, Y; H) X$ W3 l( H9 n; F, R
   {        
1 F1 G, y3 s& L# [' N                       
  W+ z5 A. w% f                //********************************************************************& d5 X% B: [( h  i9 O9 g5 L
                // Try-Catch Statement is used to handle exceptions - such as file not found
6 n. e9 a  |: z, @/ y% u" Y                // Reading the files will need to be placed inside a Try-Catch - just like this one!1 ~3 n! N9 ~8 T& w& T0 ]
                // For more information see page 534 of the textbook
6 s# Q9 |( {) w9 B7 f9 |- x4 g                //********************************************************************" G2 W  q5 y2 V: C- }' o- y
                    
4 T- @4 S9 o0 i4 c$ x        }
; L' |7 J8 V5 M+ N& L2 j) v- }             catch (Exception ex) // Exception caught here and message displayed to the screen
% ]- S! d, {+ U& [) o          {0 i1 j2 p' {" o( q  ^
                    ex.printStackTrace (System.err);* J3 G$ i- s1 V4 _+ g" D2 s* X" H
           System.out.println ("Error message goes here"); // Replace this error message with your own         
  z+ S  G7 |( @7 Z+ I/ I1 l5 B        }8 X# R4 s8 ^/ C. p+ |; a
                return true;: e5 L  m4 e" g
        }
( O3 j, V/ i% m9 K' s. Y" x# F# d7 M: g; _7 A# x9 I5 P* Y
} // end of class ProgramCompare# g$ f: L9 M( P$ B
3 y3 c7 g- v$ y# U$ E+ \
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************* \2 _  J" L% z, w# b
//  ProgramCompareMenu.java    Provided by: DRS. z: G" c: ~* b3 p% V2 ^+ g. }
//
3 Y8 D3 F* ]. ~  p& \- n//  Calls AuthorisedUsers.java and ProgramCompare.java$ z! o/ @' f+ p$ o" ^% |
//
8 A9 f. e* A! ~: ^& m8 ]; a//  Driver shell for Assignment 2.6 i+ J4 D6 r  F" t$ M/ f
//********************************************************************, o+ o, P  c! r
7 A8 H! ?% y7 x
class ProgramCompareMenu
/ o- L. ~( L5 _# e/ ?1 j{, w$ G" o6 s* Q8 z, H
    public static void main (String[] args)
$ P2 ]* T# K. e6 j& ~- J, D: w4 b            {
! n- b' d* \# L  c, a                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
, `$ Z5 X4 c! W7 h' }                ProgramCompare reached1 = new ProgramCompare(); ' _) [% x1 ]9 g' P
                AuthorisedUsers reached2 = new AuthorisedUsers();        & D4 x$ }8 N0 B
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
, i' i8 L/ w0 G% A                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
( E( R6 i; [! i5 n% v, P        }/ e' S8 Z$ s, d# C  I
}// end of class ProgramCompareMenu$ A2 q% x: _+ B9 U) }7 _
8 u/ h  ^) p" D: o
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************2 n2 s6 I3 K) l
//          AuthorisedUsers.java          Provided by: DRS: Z# M( i/ Y) L. F" o
//               
' I* f* [( s; x5 ~5 S( S5 R//         Program shell for Assignment 2* `! n4 {& `# W6 _5 A
//
" F! P- a* K5 s6 w) r! K* r//         Represents facts about an AuthorisedUser
& ~. o' T9 A/ T+ `5 T//********************************************************************* m3 V. _" `8 s9 X

5 V- z/ H: f' C4 Wpublic class AuthorisedUsers
% S' q7 H0 l3 h& a7 l) q    {2 \' i0 u1 C- [' J* D
( `8 R) [' I: B2 y) d8 ]( P
        //-----------------------------------------------------------------
9 \  A$ f* k0 H: ]; z- G& C        // Constructor
0 c- j1 A2 |+ G  S/ V) k        //-----------------------------------------------------------------4 p* @! M+ X; B" @
8 y9 `- M8 U7 M  |; Q- o
        public AuthorisedUsers()
1 C- q: h* Q2 {4 u                {
  Q% D! T; e6 S                }
. e) x; L6 G* u! K9 n, X
1 s; |, i5 ^! O0 c        //-----------------------------------------------------------------
- l/ n! b" _5 c* _        // Method for testing that class has been reached$ q1 _* u/ j9 d+ ?* m
        //-----------------------------------------------------------------        ! f4 S; }$ k5 x/ \
        public boolean AuthorisedUsersReached()! p* h& }8 w- q' V
                {7 k; \- |9 d1 H  R+ H
                        return true;                       
* c4 O' `) f1 Y5 d4 d                }! l% W( ]# }$ B
                7 F: s. f% C7 W9 R' B1 c8 q9 [
    } // end of class AuthorisedUsers2 n% T0 X& e! R0 C- i
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming2 V2 {0 i* c4 ?& d
Shanghai - 2007; q2 n. P# V/ L7 `) S: k
Assignment 2
5 i$ C5 P( S( h' eDeadline 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)$ R! b* p5 x% x) @
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.
" I0 R+ _+ C4 ~, Y& n. m  A4 Z) q2 SThe staff must be able to:
4 N0 k0 W7 N$ m+ z' S" w) @ Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.2 ?& ~* e2 c5 d" v' 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.
5 F0 A! d% I, E& p. ^5 _1 e The interface should provide a menu so that the staff can:
  z# r- p* s8 o* v' ga) Enter the names of the two Java program files to be compared, q# v% O: G$ z7 I
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.7 K8 n2 d9 l! k% v# {& V' r. H
** 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).
9 e+ h, i, [- j, |# n$ U) lBSA104 Business Programming – 2007: Assignment 2
5 z0 h5 X' H' H9 k- v9 TPage 2 of 5
3 T; W7 [8 d* b: G4 {b) Print out to the screen all the lines of code that are the same
0 ?+ m7 D0 d/ O* M4 ~ Include the name of the file and the line number of the code being printed for each of the two files
- F/ }8 R+ |: j' V; kc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
2 a# @1 M2 V" q; t/ w the name, username and department of the user5 y, O9 Q6 f1 s2 G* h
 the statistics of the comparison
; t9 I* d- {- W( X- B- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different: ]2 H2 c) r/ ?& [5 R. I1 |
 the recommendation for further checking
9 \. D* F- r' H( a% G! L2 a- q. \1 T- 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/ K, w: G4 @; W* J
 the names of the two files compared5 [4 c) U' c9 q- B( d) h% A
d) Leave the program (exit)
* I, V( e/ A& Q7 SThe ProgramCompare class: (Total maximum 20 marks available)( o% i+ Q. R) \0 ?4 f* e
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)
/ L% u3 K0 C- l7 k0 Aa) provide an error message if the files are not found or there is a problem opening them
# i3 r$ `  S1 R; Nb) compare each line of code
( }. _/ ^4 \, M# I: Xc) print out the lines that are the same( |: h: b! t; J8 A$ g
d) count the number of lines compared / lines the same, s; Q# k" P7 M" B7 }
The AuthorisedUsers class: (Total maximum 20 marks available)6 V" s  p4 ^' w$ v: k# z# S( ^
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)% a+ u7 H5 p' _$ N2 e- F1 u9 E
4. Provide methods to:
! }9 n7 [2 [5 R  Xa) 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 N/ t$ Z7 q. }b) return the name of the authorised user6 g; b% m/ n, W
c) return the name of the department of the authorised user) v% G6 A3 P) ^. a1 w) e4 b& U
Individual Data (Maximum 20 marks available)5 C1 F% V. a6 ]& L% s% r/ s
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.3 h* G# G! G' ?2 G+ K' }
Documentation (Maximum 10 marks available)" e- K# s6 G  g1 e, u* ]/ T5 M  S
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.
" I6 V" c3 }3 _; a2 q; e: z1 p. FBSA104 Business Programming – 2007: Assignment 2
: @) A4 w* h3 |0 O: H$ S$ `Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了/ ~: L, s" x5 w) V/ L3 o
不过你要翻JAVA的类库说明。你有下载没有?
6 F% Q/ {; ]6 k! j% O* s/ K查询关于对比的函数。貌似关键字是contrast,还有compare
5 F9 k0 u% t0 v* x# V2 q/ }! |0 U" `) `1 G7 D& S
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
/ \: ]* c5 {: E( A4 m! S' o可以下载到的 是 jdk-1_X_0-doc# }& Q+ `! `+ Q& T4 d
$ P8 _9 `2 z' t- H
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-31 23:01

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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