找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1262|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急' A8 }5 T; \9 p# N- h0 P4 k + x Q/ b, e; _) j6 ~$ I6 g1 x! e
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************  z. p4 T9 o9 Q6 n. o, E6 _
//  ProgramCompare.java         Provided by: DRS$ F' A# Y2 x# d. g# r/ W' [5 }
//
+ S0 H+ T/ `7 q1 Q# M" m! ?9 `9 N//  Program shell for Assignment 2' U- _" B% u; l7 c6 s5 H0 R' o
//6 E6 \/ P# D6 l
//  Compares two text files line by line
, z, u0 x' u% w' g1 Y6 A//*********************************************************************
' Y, J# S# X2 G8 q) y) B6 h
9 v8 e: z) e! B! Qimport java.io.*;
4 v0 N6 T! R( P0 F: `; V6 P. t$ ~' t
public class ProgramCompare
0 a9 M; ~& O# J% j' k! \; @4 b' I  {4 P{6 z" }3 }5 L  c$ R9 ]! s7 N6 C
        //-----------------------------------------------------------------5 g# M. A! H+ E
        // Constructor, Y5 B$ T* T! |
        //-----------------------------------------------------------------8 E+ v* U7 a8 S6 h9 a# N" {. m9 A
        public ProgramCompare()
& Q' m% Y/ }3 Y& `# q        {
7 |6 N- L; C, w" b! W$ X3 B        }
8 Q3 s2 o+ U+ G. _8 x) h
% t( A, `, `* C) g5 E        //-----------------------------------------------------------------" A5 o. [4 u) N3 f7 F3 i  J( ~
        // Method for testing that class has been reached8 v/ l  g; K' i
        //-----------------------------------------------------------------       
( Q5 Z. u9 l+ {, d" `! ^1 A) @1 i: U  p+ A$ Q: @9 y
        public boolean ProgramCompareReached()        
2 b1 ~# y5 p. H& V2 r) o: [        {; S/ n4 T# S& p0 m
      try 1 [' |4 K5 |+ I" e$ L& \
   {        
8 p2 j% T6 [4 T                       
! f2 Q' K* f. N- R, ]                //********************************************************************
( s* I% l' p/ D8 W. T$ E                // Try-Catch Statement is used to handle exceptions - such as file not found ! I# i. L0 z. ]* k5 ^% A7 j- R
                // Reading the files will need to be placed inside a Try-Catch - just like this one!; {9 M$ x5 U8 }- n8 |+ |
                // For more information see page 534 of the textbook
0 D+ J% ~6 I; ?5 {% l                //********************************************************************
! L- e) v* t' o$ K  I                    
5 J. `) J; `- e5 R4 |; ?% |/ `        }
: o) `: J1 O3 R) O7 r" Q             catch (Exception ex) // Exception caught here and message displayed to the screen
7 I7 s! u2 g2 Z1 L" P5 O          {$ U8 g& N- _; _- v
                    ex.printStackTrace (System.err);
; m8 ^- I8 m* [1 F! U           System.out.println ("Error message goes here"); // Replace this error message with your own         
0 ^; z2 P8 v+ x5 x( h        }
9 @* k# {1 m5 z# A' n# i- O                return true;" G0 x# B6 ~9 P# w& ]$ r
        }5 W  ?. e2 S4 ~& y" n- a
1 R$ S* H; J* C5 ]# A" D
} // end of class ProgramCompare8 J/ n' i9 X, G! c) _, E8 s
8 G! c0 L4 H: r/ O* B6 l# Z
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************2 b5 u; o" S  a5 o5 s+ x
//  ProgramCompareMenu.java    Provided by: DRS8 }% T2 ^: c/ m- Y& s4 @4 B, |
//7 @/ {( u' F9 o2 V$ m2 O
//  Calls AuthorisedUsers.java and ProgramCompare.java( d, Y: @! d% W8 _8 o' U
//9 \: `/ e5 [- t2 y  B6 d. q, W1 y" V
//  Driver shell for Assignment 2.
5 x8 h8 f( w7 u3 U* j& D8 \5 M//********************************************************************# {, a+ |& C3 M# T4 c- V# A2 I. j+ f3 q

/ b4 v4 u' d9 L5 vclass ProgramCompareMenu
& Y' n. J. Y' s9 ^1 S  a{, @3 ]* a' F; \# Z1 w
    public static void main (String[] args)
! Y/ u- j! s: @3 ?            {; u: V% Z; _0 `. v
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
  S2 N& O& p  D/ [1 G" G                ProgramCompare reached1 = new ProgramCompare();
; i( H/ V6 O. U                AuthorisedUsers reached2 = new AuthorisedUsers();       
: n+ T7 o* X" j' m: L2 D+ z                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());: c2 x2 {/ v% _2 n  `9 t
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        # V4 e& u( }7 Q7 f* \% N
        }
+ `  k/ H! x- f}// end of class ProgramCompareMenu
! X$ x; |+ I/ q7 [2 L
( Y% l# [7 N0 ?; r$ b/ [//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
3 J' n8 F' }! i$ p7 s//          AuthorisedUsers.java          Provided by: DRS
+ O9 g3 j' w+ f. L! j//                4 B3 L4 s9 E$ ?0 E
//         Program shell for Assignment 2
4 y' c" f3 G6 N3 a! n//- @3 z" d! H7 `3 {: i
//         Represents facts about an AuthorisedUser
6 T4 s2 m  O' A- m. A/ R//********************************************************************) C% Z0 K) U8 {* D, n- U

, B- T, _5 E8 B! ]public class AuthorisedUsers
" p! X. j) t, R6 N; Y    {
5 {$ L6 E1 R" t% m; {& B! R  r" V* r- h0 @
        //-----------------------------------------------------------------$ o# D: h* w4 I$ f. v
        // Constructor
" n, P3 m" u4 N' K1 S8 b$ G  c        //-----------------------------------------------------------------; F9 I# n% v' C( Z

$ i4 z! X: O) j; N" |        public AuthorisedUsers()' m% i% h0 _; v4 ~/ T5 m
                {
& w# _: j1 T' w* H: r                }
' F+ X' I" b- \& p' U9 a5 j
. t0 F& j" [$ ?; a        //-----------------------------------------------------------------# \3 T  _; ^5 b  n! U( p% _' w) F
        // Method for testing that class has been reached
' b  ?% K) B: e3 w        //-----------------------------------------------------------------       
0 R8 |  i& u$ Q! S* V        public boolean AuthorisedUsersReached()
0 O0 c+ v" A( o) e9 a+ V$ c$ {9 q                {% y; s0 t; P4 b& A+ ]
                        return true;                        / C, N- s" I" q  X. q
                }
- D8 _7 a/ {' O3 p               
! Q2 t" @& k8 L    } // end of class AuthorisedUsers4 G6 `# d! L( X* r
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming! ]& z. u) H. V* |; a2 J/ N
Shanghai - 2007
# @4 Z$ p" k9 {3 M3 S) z. B3 C; OAssignment 2
2 R. U% g$ J5 N7 {6 r. aDeadline 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)
9 m$ X6 {! A1 C3 a# G$ }) K" l; K* p+ Z1. 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.
0 V) n. E& c) l  \. HThe staff must be able to:+ g: ^0 Y4 A  d1 X% |  ^' J
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.8 Q# J$ \% Y  m# q) @- Y
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.
- w% w. j; v) }4 ] The interface should provide a menu so that the staff can:
9 h$ d8 n7 w2 [1 E" p) X8 Z+ b: _& xa) Enter the names of the two Java program files to be compared. f: ?( S7 P4 D( j! t
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.* G+ v3 Y. o  T6 W$ o
** 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; V- ]% J* ?$ s" `- w  f3 ~2 H
BSA104 Business Programming – 2007: Assignment 2
+ M' x% c: l5 \8 J6 T2 K" k4 ~Page 2 of 5
9 Y* \1 \8 k3 l1 P$ Vb) Print out to the screen all the lines of code that are the same5 ~' Z" P0 J2 P
 Include the name of the file and the line number of the code being printed for each of the two files
: o$ }% x/ e4 D5 K3 D* [" H+ lc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
7 c1 V/ d, Y2 F7 R& R the name, username and department of the user
0 f5 M) f/ E* p7 s. j$ g. g the statistics of the comparison
  T7 B0 |4 c$ _. ^2 F- {/ K/ p- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
1 t. H) ]: j! h3 [5 X* s  p the recommendation for further checking
, K4 N$ {! v% `! ?+ i2 F" K, [- 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
: a; [' C! n# S2 Q$ F. ] the names of the two files compared
& g3 S: J# \8 Ud) Leave the program (exit)
, ^+ }! n& W2 _The ProgramCompare class: (Total maximum 20 marks available)
% N4 F; w+ `9 T. d* T2. 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)
7 R4 k/ ]* Z* \, J6 Z1 M1 qa) provide an error message if the files are not found or there is a problem opening them& b' n. X% t; Q, B) o
b) compare each line of code2 U# ^: G7 Z9 {, m% R; \( j
c) print out the lines that are the same1 \" N1 {' g; o/ M1 ^
d) count the number of lines compared / lines the same
" ^, \5 m3 a4 C1 l2 F: \The AuthorisedUsers class: (Total maximum 20 marks available)
6 h7 o! p- H0 t3. 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)6 [1 t2 a, g* R& i. K
4. Provide methods to:( n! m+ h$ n9 O8 D3 t% P+ g6 i3 F3 S
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 match5 b: {- _" @- Y. z
b) return the name of the authorised user
+ _1 I' [1 V; p! \9 e* Rc) return the name of the department of the authorised user% z( ~/ z  T0 {, r# Z5 I/ c  x* S
Individual Data (Maximum 20 marks available)( j8 V6 r7 ?. h! E
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.# L1 w, d" @9 }; r5 l0 E7 w0 j
Documentation (Maximum 10 marks available)
) g7 X3 X4 E4 I* o6. 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.. _& I$ n6 |& ~4 o
BSA104 Business Programming – 2007: Assignment 25 v6 F+ Q% W# b( t  I
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了/ J7 H! r& c5 |  O8 _; Z9 s* t
不过你要翻JAVA的类库说明。你有下载没有?# M/ [6 U+ ^5 t9 K5 w7 \) B
查询关于对比的函数。貌似关键字是contrast,还有compare
, X% F4 @6 u' \  N4 @# W% U+ D3 ?; ~  }0 u# {+ J
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
+ I* Z/ n% [/ S; @痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。3 [7 z; y3 ]! O( \% ]8 a# P
可以下载到的 是 jdk-1_X_0-doc* g. p- ?; s# `- q, L% t% ~
! B) R7 [4 h: W' e4 m
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-10 19:06

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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