找回密码
 注册

QQ登录

只需一步,快速开始

查看: 978|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 * U v/ B8 u# ]- f. _" V ' Z% B1 N1 \ R, B2 [, Z3 g
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
" S$ R8 o3 s" K) X) g//  ProgramCompare.java         Provided by: DRS: o1 m$ G8 e6 D: i- {
//3 B  n  t" f$ s
//  Program shell for Assignment 2: O! v- h! H/ `) J+ X3 ]  a! ^
//
1 O. E1 d; D1 t  ]: Y; r//  Compares two text files line by line
  l5 n1 f$ F- |) i//*********************************************************************$ p3 O5 S1 ~4 c" t+ E) f

) @: s- S; `! O9 n: J+ }import java.io.*;
8 d/ J; W9 d, o, E  H' E/ o0 ~3 M' c5 Q  F! A9 v) c1 p" m
public class ProgramCompare+ A# E! c$ U* G- t  ]
{/ X- [( o1 r9 {& Z6 G0 S- K/ f
        //-----------------------------------------------------------------7 G3 R; p. P6 V5 N* N. t. Q( N
        // Constructor
. L' g; H( u" I' z- s        //-----------------------------------------------------------------8 f& X, [6 F9 _7 y
        public ProgramCompare()
) v% Z( x1 ]& k7 `        {
& e: p1 l. ~7 C9 ?; {" j  _+ h1 B+ p! Y        }
% I, j; J! Q4 m$ k, j) W2 x) i. r( s4 g& y# D; l6 h
        //-----------------------------------------------------------------7 R, o2 r. b/ C7 _8 S) y8 H
        // Method for testing that class has been reached! \9 B/ e7 @% p
        //-----------------------------------------------------------------        - p* z9 \: h  e. g. g" [4 u( ^
  I" L, l3 R& g6 i
        public boolean ProgramCompareReached()        
/ j+ {9 k% a$ `" B- v% d# I        {2 q; `, l0 @8 L9 R
      try   y5 M0 l: B! |
   {        
$ g* C% W" X$ x* X                       
: [8 x% p% Y) B1 [; q5 S                //********************************************************************
/ J5 \- \3 |- l  c7 C                // Try-Catch Statement is used to handle exceptions - such as file not found $ G! A/ @" R* G6 P+ p
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
2 e4 Z1 N( e2 S) M, w4 t' ?7 g                // For more information see page 534 of the textbook
7 c) x+ i4 F2 s7 m5 ~                //********************************************************************
+ @* q" R$ r- ?6 o3 P- f" i                       D! \! }- H4 _+ p
        }
6 F+ c' c* \# Q' k4 y- M/ b             catch (Exception ex) // Exception caught here and message displayed to the screen
. ?, ^) ^0 m1 F" ?9 }; t$ `          {$ [0 w3 {' N6 o% w
                    ex.printStackTrace (System.err);
. j( F2 \7 u- V$ k+ B2 b           System.out.println ("Error message goes here"); // Replace this error message with your own          9 t8 I9 W* o; w& V$ R
        }
* k8 l  E* t7 U1 u5 B3 |                return true;. i( `" \" H; b4 s6 q3 d  \1 u7 {
        }
# v! l" _3 }5 H+ @0 d" j  ~
2 V' e; D7 v; o1 S, O' @' t' `} // end of class ProgramCompare
2 A% x5 d1 @3 I. F* W* h6 d
- L6 h8 a1 |) e/ ^# Y8 A//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
9 ~1 Y! U& }5 C; s5 R( Q//  ProgramCompareMenu.java    Provided by: DRS
6 `& i) x8 w( s8 ^; [7 _5 \//
. n) _* _% Y* I* Z' w/ A//  Calls AuthorisedUsers.java and ProgramCompare.java
. K  [  [3 E  A( Z//* ~! |7 r! S4 X3 ~* ~6 c
//  Driver shell for Assignment 2.
- p. u  w& W2 Z//********************************************************************1 }" ^' p: [) g4 V" \* ~' [
( |' x% o5 |4 q/ ]. E
class ProgramCompareMenu
. y% ]" i' L/ p+ @4 K* B{) |: W2 G' k" [/ J, e* A0 b: ^; u+ }
    public static void main (String[] args)
" F; {$ ^0 s& N" b            {
2 H: E; N8 J4 v/ I                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
7 _( N/ Y0 ~0 Q; m7 s                ProgramCompare reached1 = new ProgramCompare(); # p$ p! L* }9 }' z; `6 q0 q4 r. E( R
                AuthorisedUsers reached2 = new AuthorisedUsers();        5 X1 ~! R* {  A3 A, _% f' l
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());) G% I4 J7 n& L( G! e
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        " y( v1 ^! p, x8 L% ^. U) v: C/ q% B; s
        }9 I2 _' p; j& b, T4 p, W2 |
}// end of class ProgramCompareMenu
  R7 ~& {3 i( a2 Y8 [# w" j( F+ P3 t& B4 c: A
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************# }( q0 ^3 @6 M) m* }
//          AuthorisedUsers.java          Provided by: DRS
. w4 q0 Y, H$ p8 z//               
, I: w' B5 N1 i//         Program shell for Assignment 21 j8 J# b1 [% _6 T, ]# m
//
- L5 @2 V/ `6 R" v% C" i. {9 |//         Represents facts about an AuthorisedUser, d+ v& {4 a7 a2 S& d% P
//********************************************************************6 v9 E/ `7 G4 G3 C8 \% L
0 l* C. t) K( V  B1 t7 d
public class AuthorisedUsers( p, K' K7 q9 Y1 f& G( n- U! i
    {! S" j: S7 v. \; X9 P
  f. i: @4 w- Q0 |
        //-----------------------------------------------------------------
9 [6 l% w+ s/ b8 R% D& X        // Constructor
" Q; }) t) u6 H) V! J$ ^8 I        //-----------------------------------------------------------------
( v5 `. u5 f% Y5 h( [# x; w" c
  ~' h( d# t; X$ \% u* w: i6 N        public AuthorisedUsers()
; G! R$ a8 D; j! L% i0 e9 M                {& y0 B) P2 e/ I' v. X7 S
                }, {! o* k, A1 l' J5 v2 g8 s

5 F0 I5 H4 T& y- [  j        //-----------------------------------------------------------------
; X( B1 b4 O: _/ r1 p5 ~5 G3 a' c        // Method for testing that class has been reached8 u# e' }; _" W
        //-----------------------------------------------------------------       
# `, U) e- O* B& @: W3 W$ l        public boolean AuthorisedUsersReached()8 h5 |5 M. w8 [3 K, Q+ F
                {
1 ^& b  u. f) e% E' c                        return true;                        # E5 U4 f! Y8 h. _/ T) e' z/ h' T/ _
                }: i8 Q+ n! e$ G1 C& `, g* n
               
$ Z/ f: g* f* Z- a5 {3 J! Q    } // end of class AuthorisedUsers
% a4 |0 R& j+ z& e7 t$ r//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming! R9 @& J; T( [  r+ r$ o' s
Shanghai - 2007* \1 F: P8 f7 F' q: q
Assignment 2, F* m# f/ v0 V
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)* R& _1 A  J, I: {" j5 }: |
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.5 {9 j) X# ]- Q. c: V0 r8 E
The staff must be able to:
3 g7 d9 X8 ]) k# g8 x Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.. x/ T/ `# H- s0 i9 w9 R
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.
% o' B6 I3 |6 y& {+ R1 @9 N The interface should provide a menu so that the staff can:  N6 i) n& x( g
a) Enter the names of the two Java program files to be compared" _1 U: d8 m2 [6 R
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
' K; e( R8 ^. I. Y: k, S" b( e** 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).3 F  P. F, X  N% M& T$ v3 d: h; _
BSA104 Business Programming – 2007: Assignment 2
# m7 h- c2 n) a+ s9 F0 D7 E) HPage 2 of 5$ [0 e1 [# X' X. g1 e# `
b) Print out to the screen all the lines of code that are the same
) o+ U6 }) O! M1 T' ]  @# l Include the name of the file and the line number of the code being printed for each of the two files9 q! h& Y4 o# w& Z2 R0 X
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
# L# E, o! R$ T3 V6 q9 ~. H the name, username and department of the user' p+ N- V* A/ x0 ^7 M- J8 K9 l
 the statistics of the comparison# r9 e( V* s0 i% f& s3 U+ O7 n
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
) H+ m. `$ Q0 @, h$ ] the recommendation for further checking1 D/ V- i  M0 q$ I: i# E8 f
- 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
; w- U+ e: `4 V7 _: d& { the names of the two files compared4 C" L! a( C3 T* M% Z
d) Leave the program (exit)
2 A3 R7 E" H. u9 zThe ProgramCompare class: (Total maximum 20 marks available)% q+ z& A; b' G* m2 v
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)5 y5 p+ |: M8 G; N* W
a) provide an error message if the files are not found or there is a problem opening them) o$ R& G% }' U0 m& I
b) compare each line of code
* [+ g1 `$ ]" ]c) print out the lines that are the same
: a7 t) b2 ~2 ~1 L  nd) count the number of lines compared / lines the same
- N( ^) C/ e9 j6 c5 PThe AuthorisedUsers class: (Total maximum 20 marks available), m" y7 s" Z( B" o" x3 l0 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)
% A1 A" R) }( m! j# h, Z4. Provide methods to:
! i& C# Q0 f5 k" v* Pa) 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  O7 \3 M: N" G( X
b) return the name of the authorised user/ D- U0 u7 b! N" [/ I
c) return the name of the department of the authorised user
' A0 E! T% K+ [3 N8 w5 [Individual Data (Maximum 20 marks available)0 @6 v7 G  N7 P
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.8 n" y4 d3 z8 ^( g0 m' @% F
Documentation (Maximum 10 marks available)6 B* G, {/ L7 e3 B7 q8 [% `$ ?
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.# e4 \4 s) |0 J: h" o
BSA104 Business Programming – 2007: Assignment 22 n; Q( T; q+ G
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
, d4 w; f+ \% I/ ]不过你要翻JAVA的类库说明。你有下载没有?5 r3 \5 }' {6 ^5 U9 i) D) `
查询关于对比的函数。貌似关键字是contrast,还有compare
- b0 U0 Q1 V( Q& {6 H7 g9 v( ^5 f( V6 v# L5 v$ R
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
6 Y4 E, U7 A% h) z7 ~8 z9 ~痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。9 Z- f7 v  A: b2 ~9 T1 G
可以下载到的 是 jdk-1_X_0-doc
: f* H: t$ B3 k% ]. m: M- P
4 ?" S- a, ~# @' V% A1 ~. }+ T[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-30 06:33

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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