找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1666|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 * W* Z/ p5 G+ B8 p# _ 4 S- Z, F9 J+ a, }4 w' `4 J7 I
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************' F! ?5 r% l- L8 T1 o) W. {$ |* ~
//  ProgramCompare.java         Provided by: DRS
. w% f$ R) m7 w, v7 l# K//7 q! K# g, x+ u6 U3 U, q7 r0 g
//  Program shell for Assignment 2
  S4 R" V  J: Q! u6 m//
- |  j2 S6 }2 {, K, f: ?% C//  Compares two text files line by line* W8 e- G! W. U
//*********************************************************************
8 i! q4 ~/ w0 @" v! Z: V8 z8 K' H. }1 J7 ]' H
import java.io.*;, A2 X1 q2 X$ y, R3 c- e( [
7 }* R8 O8 D' o8 P* v
public class ProgramCompare. |, m6 g+ k, Z+ |7 \( ^" p
{& E9 W# Y8 i) o7 @
        //------------------------------------------------------------------ j5 h. n5 V2 m# n. P5 s) |
        // Constructor4 ?- \& o" \4 X' h* p( f
        //-----------------------------------------------------------------' u( ^( W' W9 }0 o/ ^! M8 T
        public ProgramCompare()
5 r* ?. f. N: _# h; e5 q        {
" y' `) O& A1 k8 G/ N        }
( Y* V8 y9 d7 ~$ t8 `
# i0 s. D7 U/ D& C. f        //-----------------------------------------------------------------
6 B( t% c' n* F        // Method for testing that class has been reached1 \. g; j, v/ X: a$ ]3 Q
        //-----------------------------------------------------------------       
+ a% C9 P3 u, d' t* `5 F: w% i- u8 X+ o; `% G6 e
        public boolean ProgramCompareReached()         , g1 S  B, g, A
        {4 k9 F5 @( c. c
      try
: L( G& T) b: A! ^- Q# D9 t: _   {         % q! j2 X. A( o7 U7 B
                        : c3 _  M1 m$ e7 ~5 ?# _+ s
                //********************************************************************
2 W- c" z  k3 r8 ]! c3 X, H  K                // Try-Catch Statement is used to handle exceptions - such as file not found 4 z* C# `6 B% \0 r" D* m
                // Reading the files will need to be placed inside a Try-Catch - just like this one!" X; V. k) B0 P4 @3 N
                // For more information see page 534 of the textbook
% }& v% I2 {6 g( m                //********************************************************************. G: o; N7 T) y. M/ g2 K
                    
. D) g4 A" l! P* R6 m" C& U. n        }
' y2 m9 n, T0 v9 u             catch (Exception ex) // Exception caught here and message displayed to the screen
3 A& X& N! b# M, K6 |3 \# Q' I7 F9 B          {
! f' Z, L9 u! k! o+ e9 N* n" u                    ex.printStackTrace (System.err);
1 f$ S: D9 @' u+ }" u9 d9 ?           System.out.println ("Error message goes here"); // Replace this error message with your own          " L. o4 |$ u; O/ N8 X
        }4 i# I9 T* c0 k
                return true;, R; q, }6 b9 v, Y
        }
0 E/ m% E3 @6 c! V: V9 r4 X
! j1 G+ h6 B  G! l8 z2 s4 X} // end of class ProgramCompare
! Z* U% z( H0 B6 U
& f4 o) F3 ?  S# c/ B" L' k8 j//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
1 _2 ^1 ~6 K4 l- ~" t//  ProgramCompareMenu.java    Provided by: DRS
( @2 X' F# J. i9 F+ |/ ]( b/ v# R//0 ^& B8 x' |5 r$ P9 W3 {; ^" [
//  Calls AuthorisedUsers.java and ProgramCompare.java
% K0 R  f4 L" _  H' d1 c//
/ I# v, t; v+ q  [' Q- @4 Y//  Driver shell for Assignment 2.
$ r3 ?' C+ |# \, f* O5 z//********************************************************************
7 i7 N- p8 e+ |+ ]5 B" s9 [3 v# y6 f' ?: |4 {9 f
class ProgramCompareMenu9 M4 }/ o/ C- a7 }+ a
{
2 X3 s6 i2 Z0 K    public static void main (String[] args)% C! J3 d$ ]8 d( \  D* [0 q3 Y
            {/ n$ A7 {7 H3 w7 u! y; _; H, r
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
7 B2 ~! _) B& x( M: b                ProgramCompare reached1 = new ProgramCompare(); / n" ^0 i( J7 G/ X
                AuthorisedUsers reached2 = new AuthorisedUsers();       
) n% J1 w* ^% E/ H5 H+ b% `4 F                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());9 v2 x0 k( Y* z5 w1 j) H
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
. I. X+ x* B8 F* c3 X9 F% S        }
2 z$ n3 p. l* o. ~; Z& r}// end of class ProgramCompareMenu
9 p' N) ?, O% N, H8 ^
5 \+ F3 x& f$ E% e" \//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************& @5 w: x2 n- j: Q
//          AuthorisedUsers.java          Provided by: DRS
0 d4 z  k. @1 I//               
& s/ V7 a- `! I% ^: ^//         Program shell for Assignment 2
. c' n$ j  y: s, A4 A4 G3 h" x//
3 e+ \3 c4 k6 E3 e" g' t% a//         Represents facts about an AuthorisedUser
9 g1 z  }0 r% p) A' Y$ ?2 L, j//********************************************************************
9 S$ j- h! e- P2 v. {1 W( v7 `8 o& z+ ]# J0 @4 u( h5 \* m* b; b
public class AuthorisedUsers
# q& k3 S: D, K  c5 L. b    {$ X7 D; k# l, g8 c$ O
% \5 Y# q; `  v6 L- b5 j# l
        //-----------------------------------------------------------------
' c" J' B6 J5 q5 {        // Constructor
) }  P) |+ {! R% z        //-----------------------------------------------------------------" _1 {/ q; w1 k4 _/ [3 _5 _9 d! G9 \
( O4 p7 P" s$ P9 k; m: }; Z( h
        public AuthorisedUsers()
6 H0 Y, R) \& J( i0 `                {
: B+ V5 }" O5 `" D  k                }& u/ h) @9 B& E* ^
1 [7 h/ P/ t6 m4 @+ g
        //-----------------------------------------------------------------
$ [0 y. W) d# d  o* o) o' U5 f; F& N        // Method for testing that class has been reached
$ l  a% X' h1 J- |' G        //-----------------------------------------------------------------       
3 a0 u4 M+ s. w3 o) r( v& P        public boolean AuthorisedUsersReached()
( ?* ?# J# c" e                {0 i& ^$ f' M# c$ N7 {
                        return true;                       
  O7 x* T& z$ I, K( F1 H/ N. A                }% E! e- z( X2 B; N- n5 P; X3 _
               
5 ^2 T6 e  n! l    } // end of class AuthorisedUsers
8 Y- c# r/ K' b# e8 w2 U//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
  i$ F4 l2 _, l" ?+ nShanghai - 20076 m. r- ]9 ~: b1 d$ o* K
Assignment 2
* C% A" M6 z$ B4 u; {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)
: C% j6 z( w9 {' P1. 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./ @+ N0 E& @( X% M8 h9 a4 T+ I
The staff must be able to:
* W1 F2 ~& Z* \% ~; W& O Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.7 X' J! L3 m* w" P% @& k( m
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.# S# T. Y* M) p/ q
 The interface should provide a menu so that the staff can:
, o* K; f- C, ?% d9 z3 ba) Enter the names of the two Java program files to be compared
. R3 \- `: p/ T* j' L( m  O, Y5 z; s For this assignment, it will be assumed that the two Java program files are in the same folder as your program.- |2 h) s+ W. a  D# i
** 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).
7 |3 P( X: m6 f/ {6 n7 ?BSA104 Business Programming – 2007: Assignment 2. x: C; J' C: m( Q1 k- Z
Page 2 of 5! f& F  F& l7 F( X0 E/ `6 ?
b) Print out to the screen all the lines of code that are the same
- l' S" ^* @; f Include the name of the file and the line number of the code being printed for each of the two files
2 t2 V# W  ^* ^" x( ic) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared. s  ^# ]# \6 g9 d; X0 A4 T4 J& v
 the name, username and department of the user- W6 Z( D4 v. r; a  T4 H* g
 the statistics of the comparison) x- c/ j) y' u; J# ]. G
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
4 Z  i8 w0 a0 ^3 W9 F" Z. B the recommendation for further checking
+ d3 N8 f, F+ M: y& ?. X) i- 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; }3 X$ ]" K) @, ~
 the names of the two files compared6 p* _0 Z! Z7 b% T( t/ _
d) Leave the program (exit)& K8 w/ G* M1 A; g* Y7 v! k$ {
The ProgramCompare class: (Total maximum 20 marks available): C2 K4 n# \9 x, c/ k* }
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)* @* i: S1 r( J0 `) G2 }. |
a) provide an error message if the files are not found or there is a problem opening them
! ?- m% C6 J3 c, ab) compare each line of code
7 f; V+ q, B) Gc) print out the lines that are the same1 y# a6 v# e) o0 D: ?
d) count the number of lines compared / lines the same* [2 N1 N% V2 \6 r7 ?
The AuthorisedUsers class: (Total maximum 20 marks available)1 D/ K+ f( U4 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)
! [4 }# z+ K1 ~. w$ J, D4. Provide methods to:
) v' E) y& T: y9 _- f% ha) compare the stored username and PIN with the one entered by the user - return a value that indicates whether they match or do not match5 U- e6 R/ ^# Q! S, N- r
b) return the name of the authorised user
2 S4 p. O+ D. Q( vc) return the name of the department of the authorised user
$ S( v+ s5 p* g) C0 jIndividual Data (Maximum 20 marks available)5 k$ X. H6 M( X8 V/ p) t8 d) b
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.  @# C- n% B8 E2 D
Documentation (Maximum 10 marks available)
- v! |1 d8 u8 J0 _8 a" h% K6. 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.
5 }# G3 @% b8 V- cBSA104 Business Programming – 2007: Assignment 2
( ^# D0 @  g  T+ }: ~7 Q1 E' ~Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
( [! k5 s8 ^4 m* V: J, I不过你要翻JAVA的类库说明。你有下载没有?- P' v/ d$ L, I8 l
查询关于对比的函数。貌似关键字是contrast,还有compare# Z1 e1 T5 t, m2 F) g9 w) X0 \

+ D! \0 s0 [8 i) z[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -/ i( G% h6 n$ ]7 I
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
3 S+ G: ?! q. `$ j- q可以下载到的 是 jdk-1_X_0-doc
# c2 f1 `6 s" {1 E( {
/ W" h2 k: u  b2 [2 ~6 K0 Y8 x[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-24 17:57

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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