找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1833|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ( P3 H- I8 V4 I2 N2 \ ( D1 [9 H6 {2 e0 C9 M7 W( a
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************' K7 m% D: M# X$ ^1 Y* T8 a
//  ProgramCompare.java         Provided by: DRS
1 ^' L3 q% ~6 H' t$ T7 S//9 E4 p! I/ X. c* o! o
//  Program shell for Assignment 2
. b1 \5 M( i4 z. D- @6 c; h$ l$ {//
" N2 [- X6 b5 A! u, E' ?: z//  Compares two text files line by line+ c6 Q5 I) E3 x: B$ q$ ]# {
//*********************************************************************
; \" Z& b; \0 q' A" _. c$ m1 \" ~: l4 O! G
import java.io.*;# R8 p7 @% R! D
6 [2 v: T$ d- {; o( Q5 o/ I
public class ProgramCompare; `( U, w; g: _! O8 j5 Y% r% r
{
$ g/ c% C, B8 R: g( s% j) q2 g        //-----------------------------------------------------------------
% {% v9 E+ C+ G/ F3 }0 w' K        // Constructor- w! y# B! p2 a% m, m; A
        //-----------------------------------------------------------------
* x0 A+ s) f, _; k- K        public ProgramCompare()1 x8 b7 d# \9 m0 U1 o2 g. r; X, b
        {
" ?5 k/ |, z8 d$ @% `        }
+ \- l% G2 i* b1 x$ w% u* s/ j7 l8 D; X% h$ W1 D" C
        //-----------------------------------------------------------------  w& J' q- M0 D: U$ K$ `
        // Method for testing that class has been reached
& a" r: F' d, S0 g        //-----------------------------------------------------------------        & |- B  t4 [( C: J. `' O6 k6 q; g

1 m: W  I% ~5 L% i% @1 {; g) Y* L- i        public boolean ProgramCompareReached()        
/ _7 S% q1 @/ V1 K5 T0 z- ^        {8 A! h1 E, x+ U; L3 L
      try
' m0 g5 V0 N- F, Q& X   {         % N; E1 w* H7 i
                        6 {* r2 T/ ~: Z0 M" |
                //********************************************************************- [' R# b  |, {8 [( \$ L" t* `
                // Try-Catch Statement is used to handle exceptions - such as file not found & U. J0 i- w$ \, C6 ]% U
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
9 S; G6 C7 o2 V$ ]                // For more information see page 534 of the textbook
- l5 l" o" k* W, x- N                //********************************************************************
; U! H) r8 T% ?: O3 v# d* X' q7 L- C                    
9 A: J6 e1 d+ [1 d0 P2 t3 z) j        }
6 j& i- ^0 t% C             catch (Exception ex) // Exception caught here and message displayed to the screen
$ ^% G5 f* }9 i; u8 ?2 n$ L          {- l- }  i# E- s( `' a( V1 H
                    ex.printStackTrace (System.err);; U' Q3 C. v  e2 m- w
           System.out.println ("Error message goes here"); // Replace this error message with your own         
% x2 m9 w/ j0 m$ j- S- a3 T        }
; z  Q: r& U# x: J                return true;
# t7 |' A/ A; H- K' G; e        }
9 y2 Z& R3 \4 _5 E
" n. k8 c8 U8 n( y% w) T6 L9 C} // end of class ProgramCompare* h0 Z( v. Q& _$ x9 b) F3 D
  T( t; [0 J- c) g0 o) T
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************& T! [1 g/ d7 O+ [
//  ProgramCompareMenu.java    Provided by: DRS7 Y& u8 u* L. d9 S% Z
//; m* F  Y7 H  ]( y4 d  `1 J
//  Calls AuthorisedUsers.java and ProgramCompare.java
& `0 x! }0 e; B# w" |; c& M//
" A6 L: f$ N7 m) J' q1 K# Q! N//  Driver shell for Assignment 2.9 H6 `6 S3 s7 \! L/ C$ V
//********************************************************************$ |: E# k0 f8 J& k" |4 y

& U0 [) e8 @1 O& [0 Qclass ProgramCompareMenu
6 N" T$ ]! K2 q# F+ m* L: u{: y0 e. b( B9 h1 ^- [) H
    public static void main (String[] args)- T( n% O7 r5 _; [! |8 y
            {
$ H' S3 M' `* L, j' s                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
, u& t' c5 y' R  z. j$ g  \                ProgramCompare reached1 = new ProgramCompare();
% |5 H; p- Q) F  x                AuthorisedUsers reached2 = new AuthorisedUsers();       
5 ~: [) j% H, b' g0 F( Z( Q                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());# u) S- v4 A7 u" ?- J, j
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
- v7 t' h' c8 n; K, r9 Y        }
8 Y! l$ [& ?: z& ?6 z3 E}// end of class ProgramCompareMenu
$ W0 W( V4 T  K9 V) V8 t# z
" S5 c9 S' R. S: B  C, y% L//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
! D; g9 P; n: M6 z//          AuthorisedUsers.java          Provided by: DRS1 v" b( T) {, S# k' O
//                ; l8 ?8 {0 \  y( o# Q! P2 ~
//         Program shell for Assignment 2! B+ c% `2 {  P' [) j# ?
//
1 H! s/ U0 W2 R! J# |) r9 j//         Represents facts about an AuthorisedUser
# G0 [1 \, U' @, ]//********************************************************************
5 P, |! `- }7 X$ X6 I
" n  }' I2 G: M- g" ?( F/ mpublic class AuthorisedUsers
9 E6 M$ L* H( _" e0 G; E( B" @    {5 ]1 ^' I5 T6 q% h
, a# M* U9 e1 l8 B
        //-----------------------------------------------------------------
  \# b; q4 v0 B+ p* Q7 \        // Constructor
4 q4 o  G6 [8 M, s        //-----------------------------------------------------------------
' Q$ o& T" Y0 X3 s
7 g1 p9 M- h4 C: U, b+ ?! ?) }6 _; K' I        public AuthorisedUsers()
! G5 r- X0 D6 P- ]                {
8 L( r/ E; k3 l) O! l                }3 F8 [- D7 S- r4 \4 g. i0 M
  v- q9 f; C% N1 ^1 `
        //-----------------------------------------------------------------  x; y7 s  @0 F7 `
        // Method for testing that class has been reached
. u8 N! G# x" G9 C& G" u        //-----------------------------------------------------------------       
9 [7 y, O9 ?* Z0 ?        public boolean AuthorisedUsersReached()
# g  _4 x# V/ R) E& m6 M                {
/ M4 O/ U/ C; d% A6 F; |                        return true;                        * H# R3 }% P: m- _' X3 a
                }
! r1 O9 b$ T  s               
- n" b. V7 {. ~& x0 d8 L    } // end of class AuthorisedUsers
# z5 Z: S/ k( O4 ?//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming9 J6 a( @9 q5 ~$ T2 o
Shanghai - 20079 i" o0 J; @& r) x4 ?& `5 W
Assignment 28 ]2 U) B) @# U- T% n
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)
$ V4 O5 E( ^( G  |% r, X4 N8 p4 e/ p1. 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.
% u3 |( ~' S* Q; y. }- {) s6 [* WThe staff must be able to:2 Z2 u; R1 d* x2 f
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **., l& w" p$ I+ t/ j- n) O
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.
' ]3 e$ P$ H  c, Y The interface should provide a menu so that the staff can:
: u9 n, Q7 f/ b4 s/ v8 Y6 Ka) Enter the names of the two Java program files to be compared$ j  h$ E, @- B4 B$ g) O0 d4 C
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.8 h9 @+ D9 R. K8 Z8 d9 ]9 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).
3 w+ _) q3 b; W  }: m6 n# d& N5 QBSA104 Business Programming – 2007: Assignment 2( }2 d9 U+ q, Q* P, S, p! e
Page 2 of 58 N+ i/ D' v/ v% c& t" N( I; [
b) Print out to the screen all the lines of code that are the same
# W! l; \2 u* O, V4 k9 o& \7 X Include the name of the file and the line number of the code being printed for each of the two files  i8 h. s: F& b6 m  h
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared! D  l1 j! N" B; v0 ]
 the name, username and department of the user
: p. o/ ^9 G+ H the statistics of the comparison
  B' R  q" g7 [. f7 E9 ~# |# {9 y4 e- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
+ h% }3 V3 N) ~$ N the recommendation for further checking
3 F( B% p, G% r% |9 u$ I) N- 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- @5 N, \) G# @: h
 the names of the two files compared
4 a6 F& q, p8 \" O. ?! V: Ld) Leave the program (exit)
3 m4 B8 u  C8 |$ KThe ProgramCompare class: (Total maximum 20 marks available)
6 ^( n7 m8 u; a  a1 U2. 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)
, k7 O) q+ B9 h: |' ^a) provide an error message if the files are not found or there is a problem opening them* f1 h" q( r. q& Z
b) compare each line of code9 k! e; v, y% C1 j4 R4 z0 j/ p+ \- `
c) print out the lines that are the same
" H3 E& A1 K# q/ y$ t/ S1 {d) count the number of lines compared / lines the same
, T$ }. o7 B  C" \4 S" HThe AuthorisedUsers class: (Total maximum 20 marks available)
0 k& |0 M3 b: Q1 R9 i3. 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 t& J! k& C1 ^' D
4. Provide methods to:, _2 q7 a0 b. u4 a
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 match4 i/ t5 M( m) N: F. `$ {
b) return the name of the authorised user
, v, B- R$ Z' A/ Ec) return the name of the department of the authorised user5 a& D& V+ S& F" i- v* o, i
Individual Data (Maximum 20 marks available)2 b) r* e7 m. E0 u- s. w
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 F, f6 ^+ d- X  l7 Q1 A/ u5 `, U
Documentation (Maximum 10 marks available)
5 M( P, \% B8 x6. 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./ L% f6 L! c0 C* P! f8 n# S8 a
BSA104 Business Programming – 2007: Assignment 2/ }" X) [- ]1 j
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了. X% v8 D, a1 A" ^
不过你要翻JAVA的类库说明。你有下载没有?
8 O: j1 w. E  k. [8 t  O  ?查询关于对比的函数。貌似关键字是contrast,还有compare
' S8 }$ U. y) n6 G( ]8 w
: W. z5 h* f4 \, y3 `[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -7 E+ [; K3 }. V% d& y8 l
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
. l: Q1 @" G/ v/ I8 r可以下载到的 是 jdk-1_X_0-doc7 w$ Q' G* |% ~0 q- F0 w  V
# d9 H# U+ g& S( o* a+ D
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-16 11:14

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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