找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1089|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 0 V& ?) D; O7 l+ [- R+ s' R8 F8 d 0 e$ |' N' K8 `: w8 f0 c% O0 `) C
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************& j2 v0 q4 Z2 r6 r% ]
//  ProgramCompare.java         Provided by: DRS
0 b& ~# ~5 p; w2 y  C  \% E//5 W: U9 [7 A1 u
//  Program shell for Assignment 2  p$ }" t. N/ H
//! e5 n# ]* Y" L1 l7 K
//  Compares two text files line by line
+ B7 p& h: e' I9 v2 d% H//*********************************************************************
( H5 A  }; R- Y, U$ t+ H9 a5 c! R% Q  p4 G3 c( f( }4 y5 H( I9 u! l
import java.io.*;
- r( Z# v: e& X7 ]$ ?& ?! r3 _4 l7 k) {: R! b% B1 q
public class ProgramCompare, @+ n! _# j3 }$ d, h
{
: V) m% Q; F" K2 ]% k" [        //-----------------------------------------------------------------8 `0 a! o* k% c2 N& y3 D( B
        // Constructor' W& H$ A- d( f. |
        //-----------------------------------------------------------------
* R3 y! d/ q) J6 q: x4 s+ x. O" [        public ProgramCompare()
& n- ?9 ^( Z8 j( {        {
& `$ k$ I$ H/ J. }2 ]7 B* ^$ r3 B        }
8 Y0 d9 X" K  U8 B: e
+ ^- x8 h9 n* D        //-----------------------------------------------------------------$ S+ I1 g# J* ^* T  s  J$ k
        // Method for testing that class has been reached
' a0 ^, G: O* ~" M9 O, N        //-----------------------------------------------------------------        7 M8 A; G! o+ [& c5 R: }6 t5 \

: f8 V# N% j$ A2 ~: I" b: _        public boolean ProgramCompareReached()         6 [* X- u, f$ E  u+ P
        {
9 a" M9 E, r  o9 i      try
; @: T( v  H3 p$ N1 P; y   {        
8 [; D6 N' A2 b. [2 g                        & q! B" ]1 C/ D- v) A! x: L% R
                //********************************************************************- A  y9 I2 F0 h0 g8 s' n
                // Try-Catch Statement is used to handle exceptions - such as file not found ! {4 n# m4 w: ^4 d+ E0 E% O0 ], ?! D: I
                // Reading the files will need to be placed inside a Try-Catch - just like this one!3 }8 E  H% g) @/ g8 L
                // For more information see page 534 of the textbook
& k  t7 z' m* \/ s7 V! Z                //********************************************************************
8 b8 M" O6 l1 ?+ \                    
2 L( _6 F0 Z0 k4 j9 E        }& g! H2 b& W/ d0 D" O
             catch (Exception ex) // Exception caught here and message displayed to the screen
/ u9 _# O4 R. D7 Z+ i% o          {
* {+ R$ J# c- W$ T& U. v                    ex.printStackTrace (System.err);, w% k0 k  u4 D; z. V/ X, B
           System.out.println ("Error message goes here"); // Replace this error message with your own         
* A7 [5 a4 Q/ J        }# P" A: }, A9 `! U! `
                return true;" }0 m" B: b4 J' n% {
        }
8 W6 j2 y1 [9 L' a: f; H+ @# ~" I
} // end of class ProgramCompare( w6 X; C7 f- i6 {! S7 R" i
7 g( y% U( ]3 d, ]! v& Y# j
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************' O% b4 U0 g7 A& |; v; {+ V: R
//  ProgramCompareMenu.java    Provided by: DRS8 r0 F  v) k  a& f! q
//; k- ]+ o" H% E1 t3 ~
//  Calls AuthorisedUsers.java and ProgramCompare.java
$ X% }7 }: [8 h! g& l* R//
: E/ o  `' X$ A//  Driver shell for Assignment 2./ Z" [. I6 \) N/ D% H$ B* @
//********************************************************************* n# V, D5 L2 B- u2 f8 K
, W9 m- {2 j9 q
class ProgramCompareMenu
1 h5 I+ F* z/ `% K7 |+ C" k{
1 [  k2 W; b$ }3 Y! I1 E  k( o5 [    public static void main (String[] args)0 _; Z1 e0 O/ _8 m
            {
, G3 L  b6 N9 {                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable: ?2 u5 g6 K( T* D
                ProgramCompare reached1 = new ProgramCompare();
- a; ~: K9 G8 n$ d0 j7 e/ I% k9 X7 e                AuthorisedUsers reached2 = new AuthorisedUsers();       
; D5 t8 _9 p; Z. p1 T9 h1 B                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());$ q. G1 I# X& B9 `- D% I5 t, y0 y
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        - E7 @1 s1 y% Y% y7 V. `; C
        }$ D6 H9 }! k! O& ?0 r7 h
}// end of class ProgramCompareMenu
, c1 I8 H8 K6 _' ~3 r% T8 z( C: }3 ]
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
7 `6 M5 I. i0 c' J) q; J! H& Y+ f//          AuthorisedUsers.java          Provided by: DRS
2 Q% d$ c# w: V. m//                : ^  ^& m/ H2 r4 E. Q
//         Program shell for Assignment 25 A9 |2 b6 O* e' w: R; o
//8 Z! d, O* o/ O6 {: O
//         Represents facts about an AuthorisedUser
9 {' K& g- b0 @//********************************************************************$ \! f" ?9 i1 O. x
; b4 H4 a0 L& q2 P" n5 l
public class AuthorisedUsers5 {, D3 |0 X4 l6 |2 f+ R
    {0 t  G/ C; b- ^" E& t

* }! \  x+ I+ C  c( s1 O        //-----------------------------------------------------------------, p. s' m) H& u6 k( _' F5 X7 U/ r, l/ q
        // Constructor
: B0 O: a; x6 B/ S        //-----------------------------------------------------------------" ~4 o. i" F! m
. [  L3 X5 Z. g6 r$ m
        public AuthorisedUsers()" I$ K, @# U( a  @! Z! a* O# ~' {
                {0 P  a# E% b$ U* j! p' @
                }" R: \* H' X1 s$ W
9 g" H$ w9 [! h% K5 h& Q- r
        //-----------------------------------------------------------------9 x! b, A) @7 {5 f$ r  W( f
        // Method for testing that class has been reached
0 v1 e* ^0 v0 `& R1 c1 I& a$ p        //-----------------------------------------------------------------       
( X( D* c' g1 V: p" C( o  L! b9 }5 X        public boolean AuthorisedUsersReached()$ u/ i, o- U! E8 r' `
                {6 i- E5 Z8 S+ {* |# A
                        return true;                        1 G5 A3 h) f! b* o
                }
+ Q6 C! w2 _/ n' j1 X6 |                2 O6 b7 T$ u9 v( y1 X/ P% {, \
    } // end of class AuthorisedUsers
" A0 p: C( \' C9 y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
0 ~; P3 E. A! D+ S* x. |5 AShanghai - 2007% r$ Q! V; A$ r& f6 g+ c
Assignment 2) n9 `$ h2 U3 t, w
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)0 `) c- P, k# P+ y0 ^5 K' I- \$ C
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.1 F: |( N1 e8 O4 I) W/ x  \1 e; _+ o" v
The staff must be able to:9 Q: J+ w1 _7 l* r
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **., D8 `' m" Q  ?1 `: F; B6 u
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.) }7 B% R* V  K- j5 Y) G
 The interface should provide a menu so that the staff can:
# V5 u! i& T/ P/ [' I8 Xa) Enter the names of the two Java program files to be compared
4 s$ P( U" S! c$ e3 s8 x* ~ For this assignment, it will be assumed that the two Java program files are in the same folder as your program.6 q; l# h4 f) S, k. K/ x) ?
** 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 ^, w4 o; O7 v! ?: y8 ?BSA104 Business Programming – 2007: Assignment 28 U' s9 z; l& U8 E& D, J2 \  V
Page 2 of 5
# f& T5 O1 i5 F& v4 p& sb) Print out to the screen all the lines of code that are the same' M; D6 l  N# c' i
 Include the name of the file and the line number of the code being printed for each of the two files
: [/ l3 C# e0 i. F! G$ Cc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
8 D  Q( L5 u7 R7 D* Q8 c( w8 K the name, username and department of the user0 n! k" t( |9 b$ D1 s
 the statistics of the comparison
# o0 T2 {) g8 ^- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
, Z" b' r* E3 P5 a5 n# D the recommendation for further checking7 N6 ?9 `, b. X' e
- 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 S: K2 {) W& [/ |7 c
 the names of the two files compared
- r( ?3 W1 M3 X. s- d* Zd) Leave the program (exit)
. w8 e& B9 W4 _, z+ J. GThe ProgramCompare class: (Total maximum 20 marks available)" _- a* |$ o# d" d# L6 d) c
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)
4 I5 I# E$ k0 ^# Ga) provide an error message if the files are not found or there is a problem opening them
" Z* B) y. ^4 ?: Db) compare each line of code" Z" j+ ]! Q. g" d9 Z+ U# e
c) print out the lines that are the same
4 {0 E9 F# w5 z1 h7 dd) count the number of lines compared / lines the same5 f6 b2 f# D0 F, M3 G* t
The AuthorisedUsers class: (Total maximum 20 marks available)# Y# J# U% d# i: ~6 M* _$ 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)
4 d+ w0 y0 M8 Q3 p7 z" |% P4. Provide methods to:" A9 L7 }; g  \7 W
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 match9 c' Y# L/ v/ L8 R; u: ]
b) return the name of the authorised user
2 e2 f, s' Q( l4 [4 Ac) return the name of the department of the authorised user
0 `+ i4 o' o' j$ K# SIndividual Data (Maximum 20 marks available)
* `* u2 N$ L: f& V5 X5 K9 {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.+ r4 M- s8 |  O: I& o6 T$ k
Documentation (Maximum 10 marks available)) d1 a. n: A2 x4 p1 |
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.. L" N8 n, @/ K# o! u# e5 [9 q
BSA104 Business Programming – 2007: Assignment 2
* Y  l4 w* W' B3 K  T) _: \1 FPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
# ~2 X4 o, K5 p6 `# S; O: j# o2 w不过你要翻JAVA的类库说明。你有下载没有?& D# U* v. Y) e6 V  P1 o* S+ Q
查询关于对比的函数。貌似关键字是contrast,还有compare# q6 Q  j% N+ w

% I% r" e$ i( f  ^& H  r3 P[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -5 q* J: v3 q6 r" m- ~
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。: ~7 ~9 b7 ]! v- Z0 a" z1 v
可以下载到的 是 jdk-1_X_0-doc  {+ [( M2 ]% k  H. ?, X4 G

% z) l7 d) ~* i9 l- F- z) b[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-3-3 03:32

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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