找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1159|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 8 u0 P9 l% P7 j+ n" M + ^# u: Z) {) v% g: C- c' Z J9 h
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************' \% y. U: a8 h' J/ X" z+ O
//  ProgramCompare.java         Provided by: DRS
$ n" l% ?- Z: `  L//
9 @& s% ^: V' g//  Program shell for Assignment 2
, x/ K* c/ N+ |: T  q# \4 P& a//% y7 d$ S* H+ [/ d, ^
//  Compares two text files line by line) m0 n; ?& r( T% h0 `. `
//*********************************************************************6 a! o' e- J4 L, X, C1 h6 Z

4 ]' {* a4 @9 G5 n8 E3 g5 Fimport java.io.*;
) D; h% B) U( c/ C2 c' y( [* G; t1 U& C7 c% c! r$ y5 y
public class ProgramCompare
: V; O: M* t, Z" D{
; y4 g; x- B& Y- Q- Q4 f8 G. y        //-----------------------------------------------------------------* _0 ~3 X8 F# W+ Y! W' D
        // Constructor
9 H  r: b; H+ c. f9 z- l        //-----------------------------------------------------------------4 O5 G  O5 z+ b9 t
        public ProgramCompare()4 q; L! g/ y6 v/ O4 [
        {
- g* ~" y6 j" l9 W        }
# s5 F2 P. P3 P% a
/ W) ^- S9 V# b6 X        //-----------------------------------------------------------------
) W5 T' g' S2 `# ?" q        // Method for testing that class has been reached
# b( l% h% B. c4 g) e        //-----------------------------------------------------------------        3 W6 u6 O$ L1 W, T- j* {
1 O! [5 i+ ^. ]
        public boolean ProgramCompareReached()        
- l: @2 k3 q/ h9 F        {
! I& o! s7 M4 e      try 3 c2 F5 m& l5 y  {2 t
   {         ( B% e0 i4 R( M2 o
                        9 Y. p% v4 T; H, y; r
                //********************************************************************
/ `$ I2 u4 P: S2 N' c; y                // Try-Catch Statement is used to handle exceptions - such as file not found
0 ]3 @8 G0 x. ?8 F/ M! r  j                // Reading the files will need to be placed inside a Try-Catch - just like this one!3 X* t! m/ c2 i9 V+ a: s9 q" h
                // For more information see page 534 of the textbook
' O1 v6 f0 l8 Y$ f9 \; z6 S                //********************************************************************7 c* T5 P3 k/ X. [
                    
8 K; s5 S1 o4 R1 a+ Y# ~! D7 D        }
; I! H% x; Y/ L$ |             catch (Exception ex) // Exception caught here and message displayed to the screen # }7 {1 b; A9 L: c
          {+ B/ @) a+ D- d% K7 g6 `: o1 ^, u
                    ex.printStackTrace (System.err);" h' ^7 H3 J% d7 F
           System.out.println ("Error message goes here"); // Replace this error message with your own         
- c1 t3 w. V& B; t& b5 t        }
; {2 C! d, P9 y$ o1 O" E+ I                return true;
; A% c% @) _4 s: ~0 j        }! `. S) k5 n" r
2 }, l" h! j& ?' d
} // end of class ProgramCompare
/ z0 X$ I$ }7 x+ \- e/ ?- t( G1 O2 x( {  `7 p% N
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************, i' z3 K# L& [2 D* b" M
//  ProgramCompareMenu.java    Provided by: DRS/ H: }; ?) ~. m! N
//7 W2 v- L# @/ K; I. n& W- k; t
//  Calls AuthorisedUsers.java and ProgramCompare.java
# Z/ k3 w& T8 M* c//
) j, {/ G3 J* W3 F2 U3 t//  Driver shell for Assignment 2.3 i) B! p" B4 X& b
//********************************************************************
0 Q, a" M7 p% r5 Y$ T+ N6 O/ u! @0 v& l+ C8 d8 `* w
class ProgramCompareMenu) v( L  Y( ~# p
{8 L; y4 A/ m! R; b0 p/ Y
    public static void main (String[] args)
1 T# q8 o8 _9 @0 {4 w( [            {+ g' c6 i$ G' M( _( O* j
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable* e& P' ]  k( Z3 L# o' k) l+ x
                ProgramCompare reached1 = new ProgramCompare();
& X  T5 J  x4 ]8 n/ ]                AuthorisedUsers reached2 = new AuthorisedUsers();       
4 i. `; N$ z; x                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
* O3 M5 q- J6 c& `# e                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
4 Q& w4 R0 A* q7 l6 h! H& X8 I, n        }  L0 ^; [$ F) ]) r2 i# A
}// end of class ProgramCompareMenu
5 T# w! Z% O, C, t
% c- T" i& a/ |) Z7 m//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************, T3 I( J9 N' s  z4 ^, y
//          AuthorisedUsers.java          Provided by: DRS
) x6 U! k7 A* M! W, x//                1 ^" a4 a, x' q* M* ~1 o0 K
//         Program shell for Assignment 2
! N6 W* F- y8 E2 r! _" n+ r) w//! F. o8 e0 A4 P% l9 D
//         Represents facts about an AuthorisedUser: ?- T8 {3 F" I* r( F4 g* K& L  v4 w
//********************************************************************2 v* A* q/ Q9 z4 Y7 {& j7 R, `

( y# t2 }1 }- u' R0 v' Hpublic class AuthorisedUsers
$ x- W# g4 b0 Q! M' v1 H    {
/ V4 Q2 o0 X4 ~
, Y3 q! s+ V! v% ]' ^  v/ E        //-----------------------------------------------------------------
7 j+ w0 w: O( q        // Constructor) e+ {6 ^% @  Z% F/ `9 t4 ]
        //-----------------------------------------------------------------" L3 y( V1 U/ X: }
0 x+ u: H- t' v( b, J  _1 d+ E& v
        public AuthorisedUsers()5 U! ?$ f  W, H3 p" j! H' |
                {9 O5 A4 {1 T5 O# v6 e3 a& B
                }
4 Z- e* i2 u9 L: K0 D; G  }! a& v5 B- Q4 E
        //-----------------------------------------------------------------
2 O5 o7 d) e5 Y; @) e& I% i0 w        // Method for testing that class has been reached2 r# y) |: q. _: _
        //-----------------------------------------------------------------       
$ d& w1 T0 L* q& w/ V$ _5 K        public boolean AuthorisedUsersReached()
9 `- v2 U! u6 F- h                {
) x: b  d, g; c) h$ N                        return true;                       
! I) G3 L4 A! J                }
9 K  P7 Y5 v" L1 T                ; T& z2 X& w6 T3 Z8 K8 z. h$ ^
    } // end of class AuthorisedUsers& e6 K7 Y- Q8 n  s
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming8 ]  I" [7 i& B* p- s% k. P
Shanghai - 2007
- `, }% u- H7 b, s* }* vAssignment 2  Y' c# j3 W- S" G. o: M
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)
; q& b& d- m5 C  h$ \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.
) T9 k! F2 R1 i, uThe staff must be able to:& A) q5 i0 G8 v+ w: W( _
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.4 R( z# c* ~: n& Y* Z
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.8 M/ b3 W4 W* D: m3 f
 The interface should provide a menu so that the staff can:
9 e2 q+ |4 x9 y. d6 m0 Va) Enter the names of the two Java program files to be compared$ I) {3 X# U3 t8 U* B- E# G& e
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.% n4 F2 o& G% z6 U, f! `- A
** 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 I6 N7 k6 j6 X! wBSA104 Business Programming – 2007: Assignment 2
; N  Y% O# U, XPage 2 of 5; A1 Q4 q' p7 m4 _+ h. o; [0 _
b) Print out to the screen all the lines of code that are the same, r5 u/ @. s0 J* c; ~4 O
 Include the name of the file and the line number of the code being printed for each of the two files
4 S* D6 t, z3 Z: F% g) e5 fc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared  P7 ?1 r/ i. G7 t( j  {6 F
 the name, username and department of the user. c% R1 _" G" E  v4 |' u7 A4 A+ N
 the statistics of the comparison
' Q  m' F7 p+ T  @% d4 \- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
1 a( \& J; P# `6 }9 p the recommendation for further checking
4 P) ?3 @2 a: H0 m- 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
4 ~; {" u5 v" \% X/ v" Z& l0 W the names of the two files compared" B3 Y7 t1 d- m5 I2 f+ z( Z& n# Y
d) Leave the program (exit)' K. {# k% y% J/ \) G$ X4 n7 r
The ProgramCompare class: (Total maximum 20 marks available)) U3 G4 e. v) d% K8 _9 S! A
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)
/ K' w3 ?: n3 H4 M: Ua) provide an error message if the files are not found or there is a problem opening them( ]% U2 u0 S2 y) L1 u! p" d
b) compare each line of code: t- T  N9 j1 k8 n' @7 Y
c) print out the lines that are the same8 ]" y+ Q4 x6 t6 y
d) count the number of lines compared / lines the same3 e* r# X' t# H
The AuthorisedUsers class: (Total maximum 20 marks available)
5 N2 u: q4 w, w, g3. 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)
+ S  u) t  o' z; n' K* W+ S4. Provide methods to:! x# Y# N: p0 W  {' E
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 ~% I' |: g! d- J0 Hb) return the name of the authorised user6 E* J7 f3 B" a/ S
c) return the name of the department of the authorised user( ~* i" D; B" W
Individual Data (Maximum 20 marks available)
( J/ B" \) ?' g+ ]% f' @. ?4 H# B9 _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.4 @0 r% c( G- J* G
Documentation (Maximum 10 marks available). @" k% g. {5 s3 x* p4 F
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.- A) s; K  d1 j0 p7 a' @1 b
BSA104 Business Programming – 2007: Assignment 2* T. G# B0 s1 E9 h3 ]& [7 p4 g
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
/ Z- K3 ~% R- d) K不过你要翻JAVA的类库说明。你有下载没有?5 h+ D. Q# F. @$ G
查询关于对比的函数。貌似关键字是contrast,还有compare* O6 S3 Q6 l; v, D" x( C% b# u3 b
8 A, U" u2 u8 y5 ?- @
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
& b* f, B! K: ^& i8 M痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
% f) S( E9 M9 M0 ~可以下载到的 是 jdk-1_X_0-doc
; ]: m4 f4 o8 r8 u4 n; C* N* Y& Z' g" r: H  k3 u7 G# L0 F
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-5 22:19

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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