找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1349|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 / h* W$ V6 L; ^7 K) f % n# d1 O) r" 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 | 显示全部楼层
//*********************************************************************
' n4 b; A; m% w6 q6 s//  ProgramCompare.java         Provided by: DRS
  U( D, [: X4 k1 [# P//& Z  Y. v- W3 P; c. E
//  Program shell for Assignment 2+ U; k9 A$ V, H) h. @7 k7 y
//5 Z" }! T6 ]  m- }
//  Compares two text files line by line
* z2 M# M9 u( o$ u$ S//*********************************************************************
5 M) _1 s! u: q% R/ \3 Q
0 ~! D# N( `/ e* ]- r3 T; @import java.io.*;
# q9 l8 T6 q3 k5 g* M: Z$ S( C4 g$ e+ L& |- m+ H, @4 x
public class ProgramCompare
' a" I$ Z+ V! E- K0 B{4 ?9 w" Y1 q! ^, |1 E8 m* i
        //-----------------------------------------------------------------8 J8 C9 B+ m3 \
        // Constructor% W! o2 ~( S' p2 W
        //-----------------------------------------------------------------
: W# J$ g8 K4 R/ |        public ProgramCompare()
% n& H% A0 p. ]8 o3 e        {
7 K/ B- l4 f9 K( e3 K/ \3 s. s        }
3 K; W9 L& f" u2 x) P" F6 s
9 S3 f4 b$ ^: r: f: Y8 e  D        //-----------------------------------------------------------------
" q' ?1 X# q* @$ U8 D        // Method for testing that class has been reached3 `9 ~3 S& R+ X1 ~8 l
        //-----------------------------------------------------------------       
" |3 s9 o7 r9 q: r! q& L, z" U& ~
        public boolean ProgramCompareReached()        
+ M' \4 A2 u, p        {
+ H. F! j' O; I- q: A# M9 M6 T% ~* i      try " R0 F/ F4 x: V, E+ p& u
   {        
! V$ ^$ x* ~0 H                        , K0 \  Z4 \0 P5 N, O6 ~8 W( J
                //********************************************************************  M5 Y, Z; T' L; Q! R# ^
                // Try-Catch Statement is used to handle exceptions - such as file not found
- U2 \" Q) l2 m+ v( o% C                // Reading the files will need to be placed inside a Try-Catch - just like this one!
/ A+ |( H( |# S$ r5 N" F5 H7 h                // For more information see page 534 of the textbook) C! c0 F0 }) Y2 H' M8 q; [
                //********************************************************************- P5 p& Z/ p; V  M  D* m. _5 y1 K
                    
6 [1 B( E% F  y5 g: c9 [6 e# C        }
9 m4 `# q( H: R& `. |, `( B  I             catch (Exception ex) // Exception caught here and message displayed to the screen % s' Z8 A" A1 ^5 s- z& q% J& b
          {
2 @+ m& w( }4 x6 b, ^3 ^5 k                    ex.printStackTrace (System.err);
8 u( @/ A4 |- G           System.out.println ("Error message goes here"); // Replace this error message with your own         
- x8 t, ~. a$ J6 d' O+ ^* E. n3 v9 s        }; N" Y& [1 b9 v. T' `, R
                return true;
5 t% f7 N4 H7 P1 U6 D9 H        }- N9 ~7 o' y! |* Z8 v* l0 O

1 a2 T' [, p2 a) h7 s  ?8 _} // end of class ProgramCompare$ U9 b) r, S5 y2 F
, Y5 v8 U+ {, B9 g
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************0 Y) D; }# U! ]" e3 J. J8 |
//  ProgramCompareMenu.java    Provided by: DRS
  w" k3 o( y) ^//  p* z. e# C* j* H9 K0 A/ K
//  Calls AuthorisedUsers.java and ProgramCompare.java
  h% i% u, n' R# o//, T. e# \. \( s  Y* w0 \  c, I4 T+ d
//  Driver shell for Assignment 2.0 R7 `' f' d) x; m  x- ~
//********************************************************************
% w4 a; K5 [3 C$ l+ T
1 O3 O( q4 k* k' ^2 f% jclass ProgramCompareMenu" b( M7 {# ~+ ?, Y$ o) @
{$ I) w0 s* c$ N# w! Y8 @
    public static void main (String[] args)" w7 ~4 _/ Z% C' X/ V+ e
            {+ G  h' Q, _# l+ f) f3 I
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable8 R4 w4 o* Z. i
                ProgramCompare reached1 = new ProgramCompare();
( m' j7 e) Y; v' t3 E# Z                AuthorisedUsers reached2 = new AuthorisedUsers();        7 Y5 l) O3 o0 z- H2 I" X
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());) y9 A% K$ n5 ?, H5 [
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        / L- c9 m; \2 v9 u  v+ M
        }
# t5 C) n& f! {  @$ l% l( N}// end of class ProgramCompareMenu3 I0 C" V% B" Q8 A) \3 h
9 F7 B2 z. n" a6 t* b
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************! o  Z' R: b1 h: ?
//          AuthorisedUsers.java          Provided by: DRS
' A" h3 Y) v# y& V  B: a//                $ D( C7 d$ U0 a& ~! I
//         Program shell for Assignment 28 S1 a$ I) v2 d# O8 C( L  o
//
# L7 [" I0 x0 U( Y+ A4 y4 y6 W//         Represents facts about an AuthorisedUser8 o& c; w! j% U5 r- T5 G. s! N  C
//********************************************************************& r0 E/ D- r2 _; ?% m9 `
+ B' n9 p! ?' A# G% H
public class AuthorisedUsers
" K6 s. |; D- Q0 ?    {
# i1 Z. u3 q0 j) ]6 y
: s% Z/ H- K: W+ r% L+ s        //-----------------------------------------------------------------
6 ~4 |3 V( A# j* E# N7 h; v        // Constructor
  C" _5 L' w; r" c& b& g        //-----------------------------------------------------------------  \! j9 X5 e" o  x

6 {$ M3 }. W9 N* Z" J; f        public AuthorisedUsers()4 i: d& Q1 G( l7 C
                {4 }/ I* R3 w. \; J& ^6 V! U7 ^
                }( T9 @! J- P7 d0 y8 p1 O( @
; y) S/ H" t  S5 l2 |# {
        //-----------------------------------------------------------------! y1 F. A) c2 \+ y) `( v, H
        // Method for testing that class has been reached
5 ~4 a& i8 I/ m8 p, m( s. @        //-----------------------------------------------------------------       
$ u- V1 Y- @* Y' S; E        public boolean AuthorisedUsersReached()
1 ?4 x( V9 x" O' q( z7 j                {% f4 t$ G4 g! a
                        return true;                        $ }! G% b& z/ ^6 j3 y2 e
                }
, c# \3 ?; {, R" r; k% {1 ?1 L' _                ' l/ w  x  c" a1 _9 F8 }: v
    } // end of class AuthorisedUsers
0 n4 m, p% t0 _% }1 @//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
/ q* }$ `6 N* ~4 o! |Shanghai - 20070 c- k+ u9 }1 v' N& ]9 S, J4 J3 R
Assignment 2
$ B' O- f1 m. c2 p- V/ d' O0 X" bDeadline 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), b/ `9 {# M  `! b
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.  x$ }' d) J, O
The staff must be able to:
3 z; U* y) @' P! L" I Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **./ \) K4 }% r; O- o8 A. h* l3 B* x
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.
% R/ T/ u1 G, f+ K' q. n. J. ] The interface should provide a menu so that the staff can:
. A  L; s! W+ p: {. f+ x. la) Enter the names of the two Java program files to be compared; ]- c) Y" {7 ^3 Y  }% o& X# C% ?
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
0 c. C6 F! r) S4 s# b2 y** 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).
5 Z( p" X) U5 @- l# `- [BSA104 Business Programming – 2007: Assignment 2
( o9 D0 K& N' d0 O& V3 QPage 2 of 5
9 O# E' H6 T9 l. K! Qb) Print out to the screen all the lines of code that are the same
* I2 A3 u: K/ }$ T- {+ ^- z0 d Include the name of the file and the line number of the code being printed for each of the two files
# W  K' {- J$ _. l* nc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared" r2 q0 r- k1 u, N1 d" \
 the name, username and department of the user
  i, S) I4 J0 N the statistics of the comparison
& ?8 y( Q# V7 H; }$ t- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different/ \+ }- U; ~) Y/ L
 the recommendation for further checking* Y- j/ u( ^/ d! ^2 P
- 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 closely9 p) {8 V4 o; d' z9 X& `0 T0 Q
 the names of the two files compared
; j. G4 V$ E7 s. s4 a9 K. Zd) Leave the program (exit): ?# U' e4 m8 Z  Q( F0 ?
The ProgramCompare class: (Total maximum 20 marks available)
" }- }2 z8 W5 H) ~" Q2. 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)
" n# g9 z# e) l# X  @a) provide an error message if the files are not found or there is a problem opening them
' g) S5 d% e# i5 E7 q- Ab) compare each line of code
6 \2 \- x( Q* @" A& oc) print out the lines that are the same
9 o; i% B6 {( O6 Dd) count the number of lines compared / lines the same& D7 u# H$ ~9 X
The AuthorisedUsers class: (Total maximum 20 marks available)
( {* D4 }" S) x- B( 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)
0 s& U( e: j7 y/ W+ f6 X( i4. Provide methods to:
" X  g- t: }$ l9 e$ V* na) 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 A$ @$ B2 d4 z0 |: S& L$ s
b) return the name of the authorised user
# s" {3 C* Z& s7 ^c) return the name of the department of the authorised user7 n  S2 s( M" z: o2 e3 T' F
Individual Data (Maximum 20 marks available)
. s$ P3 U' R7 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 \1 n+ B" h$ a" p# mDocumentation (Maximum 10 marks available)  V* S- C' q( y0 \) l. c- z
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.
/ u5 N9 o. j1 U) o, {4 lBSA104 Business Programming – 2007: Assignment 2; N) ^8 }" t( g3 q1 w. Q
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
! C, Y* c! L+ }- z- U1 f. \2 P不过你要翻JAVA的类库说明。你有下载没有?$ g% n& {  q& A& [/ p' H; P
查询关于对比的函数。貌似关键字是contrast,还有compare
" o+ X" w. y- ~( S: k$ s- h; L$ p# N) w8 p3 Y8 t; K4 `; H( e
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -' B) l+ q% E7 J8 x) Z" J( u( K8 C
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。% d% |1 f' J/ c$ L) H- I
可以下载到的 是 jdk-1_X_0-doc
' r/ ?3 Y5 \2 w. H, ?- J) l. p- |; v, d- P! i
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-4 15:54

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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