找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1025|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 $ C/ N6 u4 F1 G7 j( l; [" T4 G+ g5 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 | 显示全部楼层
//*********************************************************************3 U) K+ n: m4 K& |9 k
//  ProgramCompare.java         Provided by: DRS1 t' c/ r9 B1 G
//
) Q6 U" \! U- n1 P//  Program shell for Assignment 21 ^+ u' Y) t  I2 `  L9 O
//0 w1 H1 w+ A/ N8 ]) g% B! H
//  Compares two text files line by line. I4 ~0 @! x% i( e8 G* |
//*********************************************************************
2 A" u; V; k. H9 O1 o8 A; n( S* y, i% r: ]
import java.io.*;
4 c! h  Q7 [8 C# d, P* H6 s& @9 H) M! u0 N& a* g4 t# g; n+ u+ O
public class ProgramCompare
8 G7 i) C4 w/ q- x! |{5 h  R3 Z7 T/ b, U  J  H; w% H
        //-----------------------------------------------------------------
5 g! I$ B) R% ^( M) F  e        // Constructor
" l; B7 ?  f  \        //-----------------------------------------------------------------$ t4 a$ _/ _3 ~& i6 @/ Q
        public ProgramCompare()
3 m/ `8 Y. X9 Y6 ~0 ~        {
0 }; k( Z3 j! t$ y        }
4 }! Q& D$ y) y# |: ^
: X: K7 x/ A2 o* A4 |9 ]% P& V        //-----------------------------------------------------------------9 ?# b  O  v' p3 l
        // Method for testing that class has been reached  W2 P) R4 S. j1 Y3 a! d
        //-----------------------------------------------------------------       
2 N' [9 t! h1 G, d4 s! D, k: _5 [! x5 S1 E- {6 {7 Z! X: v, m
        public boolean ProgramCompareReached()         / k6 d( |9 T" e) ~
        {
1 [: d3 j& [; q* m2 `$ m2 M& p. d      try
3 Y( m2 `$ V  Y3 h7 M! P   {         7 `6 g$ A. d6 K/ }0 M; S
                        * D* Y0 R2 d; b1 Q% Y
                //********************************************************************4 Z9 U/ u1 E& F4 b6 J$ ?, G
                // Try-Catch Statement is used to handle exceptions - such as file not found - a; Y" ^0 z5 e; C7 ^
                // Reading the files will need to be placed inside a Try-Catch - just like this one!0 ?, T2 F$ F) Q9 [& e
                // For more information see page 534 of the textbook* c& f4 |/ S6 T- I; D: G; E
                //********************************************************************, X% _" W5 u- _# Q
                    
" _1 s( Z/ E: a' T9 j        }: s/ s- g4 Q0 I
             catch (Exception ex) // Exception caught here and message displayed to the screen
0 ^4 I. [5 Q; F8 ~          {9 Q$ i) p( m5 }1 x3 Q7 p+ }
                    ex.printStackTrace (System.err);
! E. [! L( y) L, n7 ~           System.out.println ("Error message goes here"); // Replace this error message with your own          6 J0 m( i/ z0 u- W$ e2 ^
        }
9 R) J3 Q$ J- c$ W' @. l* Y; P6 a                return true;+ {) y5 f! i. r$ K3 {7 q& j
        }1 E3 R, Q, R" H  I
+ u$ h2 D; G* Z- ?
} // end of class ProgramCompare/ w$ C7 g6 ?& h: j
. W8 N; k3 J$ |& h; i& O5 b. H
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************3 q/ d4 F0 s+ T4 ^
//  ProgramCompareMenu.java    Provided by: DRS2 y) w+ K4 o, d2 A' e
//
0 m- B: |, j! R//  Calls AuthorisedUsers.java and ProgramCompare.java
/ j3 C$ \( \3 t- {//
# K  s5 G0 z$ N//  Driver shell for Assignment 2.
, }' P$ o, P3 q: R1 A//********************************************************************7 t. r# v' V- A1 z7 i+ t: \+ c
6 |1 J/ }0 [( y/ d# P, w  l
class ProgramCompareMenu
; |& o2 b1 K) i: W( y% U{0 n6 ^1 ]) i2 ^( I# }7 ?3 L: }
    public static void main (String[] args)4 B+ K2 T8 T" g, s& T. v0 w
            {% X( |$ c$ t% C7 O
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable# d0 K' C1 W% b
                ProgramCompare reached1 = new ProgramCompare();
! r$ D( o& A  A8 i. U                AuthorisedUsers reached2 = new AuthorisedUsers();        3 i& h3 H! h. j2 t. f; i
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());) e2 v5 n; t/ B6 V  J+ L' l* u; O
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
/ @/ u, I1 ~' h9 N& n3 c        }
3 D- _- f  K9 M; r( f/ Y}// end of class ProgramCompareMenu
8 P4 y# c" U& Z- n- x/ D: v1 p4 E/ D6 z$ ?  b# Q, [' c
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
* a/ X- U+ l# F- K//          AuthorisedUsers.java          Provided by: DRS' w, _1 @$ {+ G+ ~. L7 r, I
//               
) X- D/ U0 ^, I//         Program shell for Assignment 2
4 D- H/ s4 q6 K. n% p+ U+ w# D//2 a; k# t& V/ b
//         Represents facts about an AuthorisedUser  I3 N) Y) ^8 N% X5 h5 O: H" U
//********************************************************************
! ~( f# F" d, Y! m6 ~$ l( b$ s* w/ V8 K/ w" A4 g. f
public class AuthorisedUsers( w2 C, Z, `( b4 v" p
    {
& ^, A' ?: l. U# r. x
# T! E  c. _2 j) w        //-----------------------------------------------------------------
; f# j/ g1 \8 j/ \& Z6 X        // Constructor' }0 }9 U. n; J' [
        //-----------------------------------------------------------------
8 e! @) c. ~! c* j# i8 Q3 y9 A; l6 u- s  l
        public AuthorisedUsers()+ ^- X: k; l. e4 L/ \$ N
                {7 k5 [; h2 E0 B8 [
                }
8 S* I6 B) I1 I' L0 p
1 f% @( ]% N4 J: Z* E        //-----------------------------------------------------------------9 b2 t3 j0 Z7 z6 n
        // Method for testing that class has been reached
7 p  ?, ~' K6 w* }! T" K- G" X& g        //-----------------------------------------------------------------       
0 y4 F# O+ s- ?. n2 v6 Q3 \' l/ Y6 f' q# x        public boolean AuthorisedUsersReached()
* ?  e- }- T) P* D2 E                {: P, D- N: l: a5 F8 i" C& b3 h
                        return true;                        4 K8 I; l# L+ a, Z' U
                }' y& H$ E( r2 N) A2 H! N
               
! N& G) n# Z. h# ^    } // end of class AuthorisedUsers
# `$ A: Y/ G" p5 ], l. {//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
& b, J( e& g( F* oShanghai - 2007
& Y  c! ^7 V/ H; m' r1 M  I; YAssignment 2
8 l* s7 l0 f. L7 m5 NDeadline 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)
; v3 R" p/ V0 B& u2 q# \9 K1. 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) a& E$ I9 r# y; D# o
The staff must be able to:
4 j: m; d7 D8 k" o; M Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
6 O% I: o" Y( v1 f8 d$ @) Z1. 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.
( T2 |+ ~. T9 J5 q* U# n$ w3 F. X The interface should provide a menu so that the staff can:
6 ]1 ?! I0 e; E4 W. i8 T6 Ra) Enter the names of the two Java program files to be compared0 x. g$ G& ^" O: U& \; ?
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.- i, a: D; P4 k
** 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).
# @" R& p; f9 Y+ F4 \BSA104 Business Programming – 2007: Assignment 2+ i1 t9 L8 S3 ?2 f( A
Page 2 of 5% J9 n2 V  Q8 w- N8 m6 e2 |0 i) M  _
b) Print out to the screen all the lines of code that are the same7 |. q% V- S% ]) {6 O) V
 Include the name of the file and the line number of the code being printed for each of the two files
- C7 p8 o4 f- u7 m2 w4 |0 Zc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared: w/ m" r* E/ g  a( H
 the name, username and department of the user
( C8 W. u9 T2 y! [: C the statistics of the comparison" m7 `8 e8 u" v+ |* K
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different- C. F2 l, E% U! n
 the recommendation for further checking8 a' ^* Y' _8 y7 P2 `# t. u
- 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 closely2 e! W! W; K4 P) A$ n
 the names of the two files compared
! p3 B6 Y8 K4 Kd) Leave the program (exit)  u3 h- P; s4 i/ K# b# F- K
The ProgramCompare class: (Total maximum 20 marks available)
+ Z, L+ Q+ e5 b- C) R1 _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)
2 a. b) N+ c" Z( qa) provide an error message if the files are not found or there is a problem opening them
& W% k, I2 b) ~& F1 E, O3 b) @" x! w! vb) compare each line of code
/ {! f: }  a! Ic) print out the lines that are the same
2 ]' b$ o. h# u% f7 ~* Z6 t' t9 bd) count the number of lines compared / lines the same
, a3 z4 `% i* ~8 H5 R3 \: z. SThe AuthorisedUsers class: (Total maximum 20 marks available)7 P* E& g7 h0 j3 A" J
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); d% b0 X" g+ H) h( K$ {
4. Provide methods to:7 r' K) O$ w, U0 v1 x9 J
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
* F# }. F9 R, ^; x" [# K9 `) H( Tb) return the name of the authorised user) e) r, k; E0 N. O# d6 {) H
c) return the name of the department of the authorised user/ u- O& P# h+ p- f5 \; n  s
Individual Data (Maximum 20 marks available)
- W) j. H3 a+ i/ q5. 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., e! k# n6 n9 {
Documentation (Maximum 10 marks available)0 A$ Q" `7 t6 p4 o9 j! A" m
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.& g5 R8 d3 K4 `1 V# g' c1 v4 e5 }8 @
BSA104 Business Programming – 2007: Assignment 2% b# C4 I* G: x$ S
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
; _- X  r. \& S( a3 ~2 t; p: f$ o不过你要翻JAVA的类库说明。你有下载没有?/ b4 {, Z! |9 C( e
查询关于对比的函数。貌似关键字是contrast,还有compare
. l5 T5 e2 l; ~" ]+ ]3 P% {% B" F. g+ y. w
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
- S! X% R* A9 D! S7 Y; J" j痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
4 x$ B/ K$ b+ {# ?1 I( F$ r7 h3 x: {  b4 f可以下载到的 是 jdk-1_X_0-doc
. _( e# C. L) ^5 ]
" z  n# \" [6 S8 T1 I6 k4 S6 s  G[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-9 03:27

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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