找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1838|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急+ n( c7 d* [0 Y. e5 z0 v4 q& ^ 8 P" P6 A: o* i% Q6 t
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************: |: l& ]: I  T; h% ?+ I+ O" s
//  ProgramCompare.java         Provided by: DRS
  Y- g4 u1 T) W0 t//. e0 H7 W2 l1 O7 ]' m
//  Program shell for Assignment 2
2 m+ c. P, |, t0 E$ G/// D' T: o& w6 \9 l" r; C0 `
//  Compares two text files line by line* \. I& ~3 p/ |& j, q
//*********************************************************************
& ^4 c4 D# l5 f6 ]4 `2 _  V) ^" W) G# ?+ U; F
import java.io.*;0 ]6 K0 J; x0 d7 w. q

0 P$ F# U: J# u. D5 jpublic class ProgramCompare
* t* s/ P0 O' J8 G* g{8 `# u4 O3 K8 P  p4 v
        //-----------------------------------------------------------------4 t* G! q- S+ v6 S- ~
        // Constructor" m3 W8 g8 p8 ]3 r& Z3 X
        //-----------------------------------------------------------------1 S/ ]* o- j9 w* b; o. a
        public ProgramCompare(); ]' m/ b/ i7 H0 O4 V0 h% o1 w2 [7 G
        {
1 e+ ~! P1 ?3 y4 [        }# ^( K/ o  S7 N- G" D5 b
+ ?/ b. ]% @* i3 p& B, h
        //-----------------------------------------------------------------7 l7 L5 r  A% s" B% k6 j
        // Method for testing that class has been reached8 J: |; P0 T; U, v( p4 `3 Y
        //-----------------------------------------------------------------        6 M. R$ B" {" h: U' j# O! G1 }
+ X% {* R$ ~& j$ r* `
        public boolean ProgramCompareReached()        
; k  u9 y7 ]4 Z0 d* N# R- ^% N        {+ f/ R! f# D( {" ^, F8 o2 n
      try
: J2 [7 Q; [  f2 M, l; ~   {        
" Y: W& q  J1 [! m. j, r                        9 k5 M3 K# |6 G6 x
                //********************************************************************! {* a* W4 C0 ]6 F4 W3 u; O1 k
                // Try-Catch Statement is used to handle exceptions - such as file not found * k* _4 u9 e: a. f
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
. g2 C5 {2 ~% V9 W3 ?/ {4 e' V                // For more information see page 534 of the textbook" O8 }+ b7 Z8 @# B
                //********************************************************************
1 A" z3 P7 O: Y0 e% W# I                    
  [: t) H% q6 u- k, [& }+ c5 P        }7 o, ~8 i" ]) T* I
             catch (Exception ex) // Exception caught here and message displayed to the screen 1 @3 i/ s! l; c3 g6 m: J
          {' p& D- N  O) Z3 U0 e+ i: K
                    ex.printStackTrace (System.err);
$ \" A7 m1 {7 }           System.out.println ("Error message goes here"); // Replace this error message with your own         
$ D+ H# A! k) _* _0 X9 h2 ~        }
( G# S/ i/ P) _# B' |# `                return true;
, c- U0 N( T% v        }
7 y& f  p1 S" V0 C$ m! X9 ]# K2 \1 ]4 Q. R2 w8 f# s) v; z
} // end of class ProgramCompare
" g% C# K5 j7 t5 X( Q5 @* P8 z& X( @: r  O& M+ U) q% V: C
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
* b0 T/ a5 o3 m' z//  ProgramCompareMenu.java    Provided by: DRS  y1 X8 c+ x/ q' c. u
//% m. H! g! J& |$ m  ~
//  Calls AuthorisedUsers.java and ProgramCompare.java) m; }/ c9 x1 A& S( @
//
/ j- [. E1 V' C3 Q//  Driver shell for Assignment 2.0 I* W  ]8 k* n7 v/ v
//********************************************************************" J9 T6 C, R4 v' E8 n2 I+ S8 z
* O4 c+ d# I; j# e& x" U
class ProgramCompareMenu
1 _% P+ Z5 e  w: A{
0 [; w1 L( Z/ ~2 ?' ]0 N    public static void main (String[] args)
$ ~; k) ?% Q) B( ^0 l% D            {. r/ b2 q& X# L, @7 W( r1 Q, f2 ?% |
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable1 E' N$ @) C! i
                ProgramCompare reached1 = new ProgramCompare();
) ?" v7 ]: u: D5 f: ^2 p- X- {                AuthorisedUsers reached2 = new AuthorisedUsers();       
" Y( E2 ^* B& K9 l7 O: F                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
2 v% n3 ^) O, E8 Y) b                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
- S) R" H" S. W1 j% M- l        }6 ?% V. g7 d: s2 h$ }( }
}// end of class ProgramCompareMenu( U0 H1 d5 A. o+ L7 {& k

) Z! v5 [5 X- Q  N8 y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************. Q2 N0 }9 u. |
//          AuthorisedUsers.java          Provided by: DRS9 g6 [) x$ l& h6 r
//                " L, r1 c' w  j, X- {7 q6 q+ d
//         Program shell for Assignment 2
% d+ A& Y$ d9 N; h//
4 R' R) g2 p3 [5 c& g//         Represents facts about an AuthorisedUser) ]3 W/ @* u) D  N* X
//********************************************************************: z+ |* p" v$ z; m
1 I' E: |9 E# c. T1 A
public class AuthorisedUsers( b0 w2 ?7 Y' C  e7 H1 h
    {; T2 B0 E" x$ r& x4 x
1 j* B  v( S2 Z2 v: x0 |
        //-----------------------------------------------------------------
; |3 k& E* A! P4 @5 ]8 p        // Constructor
$ U7 j8 L" i- Q        //------------------------------------------------------------------ S; @* V& g- {# ?# r& Z/ w
$ o2 Y6 c8 U3 v0 w- e/ C0 r7 R
        public AuthorisedUsers()7 j: S  z: W7 }) D
                {
8 c4 e, m3 k2 Q% |$ a$ K3 S                }/ m1 n0 g0 ^, _- o

  I" Q3 w. I2 H( g        //-----------------------------------------------------------------9 m. ]( H. T: T  e, y5 E
        // Method for testing that class has been reached) x: f& [, a/ R" z
        //-----------------------------------------------------------------       
" ~9 }2 b0 W, H) I# i        public boolean AuthorisedUsersReached()
/ R" l5 j6 e6 o/ E: Q5 s$ q. h                {/ K+ Q1 m9 e& H" k4 l* p: y
                        return true;                          B  D2 m$ C' d# _4 H- T9 ?
                }
0 N6 Q: q1 r( n7 P( K5 l  m, ^5 I               
5 `4 W9 ], s/ E7 M) y6 ^- v' a' s    } // end of class AuthorisedUsers
0 G; `7 v  b9 ~. N1 v//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming0 F/ a9 ^, Y, Z, k6 _2 |
Shanghai - 2007
* b4 I' ?1 N8 H* N5 J/ ~: O/ H# kAssignment 2
% M) A$ S" ]2 HDeadline 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 Y3 A! H+ X0 o( j1. 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.
, c' v" _" k7 C& f9 i+ ~The staff must be able to:
& s0 \. B8 ?* \5 s Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.' P3 {5 |; b( |2 {# `
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.; L* ]1 H0 y8 O
 The interface should provide a menu so that the staff can:
& Z! E: \& h% w8 ya) Enter the names of the two Java program files to be compared
% {! L8 F& u( L* c& y  v For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
6 L0 Q. m) o5 z% r" V9 s** 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 ]- [- U4 ?( R; j* c& [( PBSA104 Business Programming – 2007: Assignment 2/ v9 Q; l% O& y1 |6 |( T& b
Page 2 of 5
, @, ]7 b0 k: Eb) Print out to the screen all the lines of code that are the same$ P2 q8 a  \* c2 R% Q/ `: T
 Include the name of the file and the line number of the code being printed for each of the two files
4 l* j1 U0 \" }6 Y7 xc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
, R) {% }& l" i& {* s the name, username and department of the user* i' b! {3 W% @6 @. `' K
 the statistics of the comparison" Q' L7 B3 f( V0 T  A. m
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
! s" z( p, _! s6 k the recommendation for further checking  n; N2 L0 o! Y- A: R: I. 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
  D% p( v1 {# U9 w the names of the two files compared
; Q. z7 o, H& E3 C" Gd) Leave the program (exit)
" A& A. y4 W) r8 z' A8 k- n. zThe ProgramCompare class: (Total maximum 20 marks available)% Q, t9 |! O% 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)1 S% I8 i4 S6 l: k/ t0 P% j& Y
a) provide an error message if the files are not found or there is a problem opening them
3 [* [7 r/ N. ~) ]b) compare each line of code
' m7 L9 `9 z2 \- U& I# _& Hc) print out the lines that are the same- N/ E% d' C3 J6 {, r
d) count the number of lines compared / lines the same
/ D1 r7 z  C9 V/ X7 jThe AuthorisedUsers class: (Total maximum 20 marks available). N+ ~, x8 s& h4 B, X
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). H& j, x0 v5 p, ]! @
4. Provide methods to:8 p5 |2 g& [$ M4 B
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
9 s. l* H" K0 ]" F$ n- zb) return the name of the authorised user* X/ z4 B' D5 q, i
c) return the name of the department of the authorised user  L2 T4 t: u1 J$ i1 t2 @3 t
Individual Data (Maximum 20 marks available)- f1 }+ b: C1 F$ n# j1 n
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.9 ]( g  Z: Q. \
Documentation (Maximum 10 marks available). A  _; O8 ]1 Y+ C
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.
/ o  S( a1 P; ]9 Y9 V5 bBSA104 Business Programming – 2007: Assignment 25 |1 ^" p) t  x  h) U. ^
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
( u& Z- s7 v" c3 |不过你要翻JAVA的类库说明。你有下载没有?
+ ?  M$ [  P, ]) Q" r7 h查询关于对比的函数。貌似关键字是contrast,还有compare8 ?7 f# U4 j9 |6 H  A

" H4 V* L2 _: O5 e5 `9 n/ q$ {[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -/ P' `  b9 _* |7 a7 k1 N
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
" v; z, u) U. R可以下载到的 是 jdk-1_X_0-doc6 N  ?8 d9 h( e4 }, [

9 Y! ^6 O, A' M5 _# y; i0 Z9 c/ Y[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-17 21:23

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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