找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1493|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 0 x% l0 m6 s6 n- z; O2 t: g6 g" j9 {8 Q7 n5 D: v9 o1 `
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
% r# G! z: _' D2 B8 d. A//  ProgramCompare.java         Provided by: DRS
4 U* e8 G2 A! s' v# l8 n//
' B% d: v( {4 D8 R3 b//  Program shell for Assignment 20 ^9 S2 {  T: }! S
//) d2 n( [+ V- U1 M& S. ]% n* F
//  Compares two text files line by line
: b1 ?; p$ j7 y  f; R* [! z$ y6 M* s//*********************************************************************
( r8 }) C- J, j! k. A
9 ~; v+ Y3 }( j, ]$ V% Y2 qimport java.io.*;
) Z' g4 Z6 e  w# D( B$ Y, d8 U' f+ @6 h9 ~7 ?
public class ProgramCompare
4 ?* s+ I, N! y7 t{
1 E, p$ x* ]1 |        //-----------------------------------------------------------------* C9 A' ?4 H2 V* B% C
        // Constructor
0 V% x2 M6 _. v2 F0 I! A8 b8 _! \2 _        //-----------------------------------------------------------------
5 L) U( \2 \, X" m' O$ Q        public ProgramCompare(), ?& L5 r+ G9 e. `3 \, C
        {9 y- ?( t& I# K9 F/ |% L
        }
* b5 o8 p% ^0 f; ]' w; p, c2 m: g
$ c0 V. P: A$ j/ s2 Z# W        //-----------------------------------------------------------------
$ N3 V% a' N0 p& o  a        // Method for testing that class has been reached
! Q% \2 Q( j  a& o        //-----------------------------------------------------------------        % D3 f* Z. b7 v0 t% }% c
: B8 Q/ _+ C9 t, s& ^- C
        public boolean ProgramCompareReached()         - E/ q) W# S5 z: s5 \; g3 @
        {6 N$ b  m4 h8 I; S* |9 r9 L
      try . D9 q  o0 i* T2 t
   {        
5 |' T. }# |" g6 a" x, l2 _& V8 h                        ! _( ^0 T* Q: s/ ^
                //********************************************************************) O. y8 `0 u6 p' e
                // Try-Catch Statement is used to handle exceptions - such as file not found
  F! m: Q5 ]7 Y7 `( m$ v: @% b  r                // Reading the files will need to be placed inside a Try-Catch - just like this one!
# O' S8 R7 q4 J; F# W+ V" C2 v                // For more information see page 534 of the textbook
( {9 I" D8 H' g. [                //********************************************************************
2 j. {$ w( Q" w( ?                    
$ r5 u) E: T( A3 p/ q& I0 t( w        }
# M' Z) \! R* o9 \6 R; l1 {/ ?             catch (Exception ex) // Exception caught here and message displayed to the screen
5 R  ^: X0 _( n9 V* _0 v          {
# }: X# P" d3 o4 c3 G                    ex.printStackTrace (System.err);
* I, i$ V3 w% C/ ?           System.out.println ("Error message goes here"); // Replace this error message with your own          % U  a( @5 }) y, v. L
        }$ t1 i, R; W8 g+ z- j- w: U9 |5 d# ~' c: `
                return true;
3 z2 g# [% X+ i% P        }" g3 T* O, q$ k: K) ^+ [7 Y% m
& k4 o. [9 E+ r$ \7 _! _
} // end of class ProgramCompare
, l: O% U9 O0 U; j3 t
3 s8 N( |0 F% F3 q! t5 x//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************& s3 D' Z3 L+ K. U9 g* W
//  ProgramCompareMenu.java    Provided by: DRS
0 ?, s8 a( J2 I- s" h7 k2 f* g# O//
# A8 x" G: E! g8 [- m//  Calls AuthorisedUsers.java and ProgramCompare.java# q% `) |( f. y' v  _
//
9 V: V) h# t1 X& W; L//  Driver shell for Assignment 2., I6 U2 A% L( }4 z
//********************************************************************
* X8 q" ?* Q& N* D* W$ ^8 k  r) Q+ ~- V" Z* z+ A4 I
class ProgramCompareMenu
, |9 I, }; X& f{
& o, {) @7 v0 W    public static void main (String[] args)
1 }2 x$ z* F( r1 v2 h4 ]! x' r            {  q& o) {3 A: p" P: W2 x
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable* C4 I) D/ m0 N$ i
                ProgramCompare reached1 = new ProgramCompare(); % N" S) v/ F! s8 U+ B% F
                AuthorisedUsers reached2 = new AuthorisedUsers();        $ m9 O" p, A1 E
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());1 A. _8 f4 C6 t+ r# F7 N1 S: H( a
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        2 w) ~+ `: [% e9 Y& U4 {7 @, v
        }
: d: P5 q2 j2 ^) a$ b+ e}// end of class ProgramCompareMenu
% d" C' b  S/ r# H+ M) I" ?2 I7 k9 G- }2 L
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
! {; G" i' f2 e- I: P+ Q//          AuthorisedUsers.java          Provided by: DRS
  [: w# x; k9 B8 O# t+ [//               
/ a1 h" \3 n! y6 n//         Program shell for Assignment 2& t8 b- {! q# s" v# G
//' W: Q) l* \2 [! {( n& K
//         Represents facts about an AuthorisedUser
! H3 F7 ]2 @/ }* R1 W, ?//********************************************************************2 O' t: |+ c, w$ `! T- z! W# ^! T
2 C: |3 Z0 R; f
public class AuthorisedUsers3 B$ b( b. F% E) @9 T
    {5 O4 {/ K9 y) S) b* u' D
( d% R- N. n1 O0 ^0 K4 Z
        //-----------------------------------------------------------------0 X1 D( p2 j9 k$ |7 o) B- r  Z( d
        // Constructor
8 s! h' e7 I9 _  {+ J% `        //-----------------------------------------------------------------
6 K9 c1 g- S, @& Z6 t3 E; m4 l  O- k5 `( m5 ]& r
        public AuthorisedUsers()8 A+ D1 S2 L" n
                {
5 `% D& K+ M2 h( b. v                }6 Y# x( \  C6 e+ p

$ B7 N: I/ @- \9 g, y# L# v        //-----------------------------------------------------------------9 v- B) U/ y7 H( {- r  M5 d
        // Method for testing that class has been reached
  t3 ~! `$ F/ o# f8 Z: A+ ?" z        //-----------------------------------------------------------------       
' S) O. F  _( n3 F, E( y* t3 U        public boolean AuthorisedUsersReached()  f9 t2 J# D; N
                {& T- S0 m! c4 J" A, B; R
                        return true;                        2 m6 X, J( y4 m' }* A
                }
# G5 U  e& p& y0 Q( o0 B  }                0 \! d# y* M& Y* l* Z
    } // end of class AuthorisedUsers
7 q$ e9 e2 y, v8 H% f% k//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
5 a& Y. A  [! U5 y- |' K, T8 rShanghai - 2007
8 F1 a, s, G! t2 A% pAssignment 24 b+ Q( n! D  O  R4 a
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). v* X) W: ]  C2 ]+ l
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.! g$ X5 A. g0 E+ _$ ~% z
The staff must be able to:: s; ^. L8 O2 q" S9 m
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.+ |1 E& y5 b8 p1 u( a2 V
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.: N1 m) z' _, }  h* N  e
 The interface should provide a menu so that the staff can:+ }+ n+ c# i/ a5 W$ d+ \
a) Enter the names of the two Java program files to be compared
2 \; N2 |! S# q' N' {1 e& \ For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
2 o* f9 r3 J7 d** 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).
. T2 D1 N' k6 E& a; T" p1 ^BSA104 Business Programming – 2007: Assignment 2" w' [) @) P) y+ n/ ?* I
Page 2 of 5
$ h+ S1 P& ^5 i' z! sb) Print out to the screen all the lines of code that are the same
! V5 X# U9 V6 ^3 d* |* e9 B Include the name of the file and the line number of the code being printed for each of the two files
9 P% H' V3 y. m$ C. {1 w2 q3 H5 Cc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
. z1 H2 Z+ V6 u$ T  @/ [ the name, username and department of the user, r+ R! q2 K" c6 N2 M
 the statistics of the comparison
; [! ?! X) v" N0 F- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
* B. Y) J9 [7 X5 V0 l the recommendation for further checking
; n; Q# s/ d, g2 T; Q- 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: M* m& G0 t9 ]6 A5 U( x1 Q8 U6 |
 the names of the two files compared
8 ]+ ~, ^! a( N# ]! c& zd) Leave the program (exit)$ u7 a, [0 ~( g- h
The ProgramCompare class: (Total maximum 20 marks available)' Y$ u# o0 T0 w- J. k" Z' ^& g0 @
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 T, ^$ W% F: @+ J+ x3 r
a) provide an error message if the files are not found or there is a problem opening them
$ F. M4 |/ q+ H8 u, u5 Ub) compare each line of code4 b9 ^8 W/ `' Z" l: L; Z5 z, h
c) print out the lines that are the same
" n# Z2 [) M9 ud) count the number of lines compared / lines the same/ k0 s7 t( r% A- k6 F
The AuthorisedUsers class: (Total maximum 20 marks available)
; _1 _# K) {' m+ x  j3. 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)5 B+ ~1 h5 E. X% }
4. Provide methods to:
# L& n6 q$ z" @1 ba) 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
7 G$ p" v- }+ Kb) return the name of the authorised user/ H, Y+ P9 Q% j" s5 K
c) return the name of the department of the authorised user9 ~- |1 n! F8 Y/ u( O$ F
Individual Data (Maximum 20 marks available)
% m5 @/ m( e7 y; Y1 T8 ~3 @; ~' Y5. 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.
6 W# p! X& ?. U3 S) W- ]Documentation (Maximum 10 marks available)+ o* \4 ]1 E6 ~
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.% c- r0 J8 i% G: h: D$ s1 Q
BSA104 Business Programming – 2007: Assignment 2: G; R8 w9 g( y1 K$ L+ j+ J6 `7 ?
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了" F% r" k: A4 S- b- ?( N$ u- |
不过你要翻JAVA的类库说明。你有下载没有?' ]: S3 j. ~; e( k0 ]* D
查询关于对比的函数。貌似关键字是contrast,还有compare
5 e) {) u- K5 }( \( p/ s6 l1 [  n; w' A4 g2 {2 J; q& T: M
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -+ W' j3 k# n4 j: c1 X
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。' W1 F- j$ w4 O6 V! {
可以下载到的 是 jdk-1_X_0-doc6 m" L/ m& I2 w/ T) R& e0 W# M

$ U, y- Z0 m0 w0 }. S[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-26 17:06

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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