找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1197|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ' H# z1 V9 j& g1 J . u' e8 q ~3 k' q5 O* l
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
  r5 j) J5 H! [7 G! X//  ProgramCompare.java         Provided by: DRS
4 w4 ?( h- Q) A//4 Q# l: |; T% y& I$ K
//  Program shell for Assignment 2# R) ^& \, n/ }
//0 {3 w, B" e- N
//  Compares two text files line by line8 e: p+ F9 r% O
//*********************************************************************+ m6 \  o; M4 j. l4 N7 W" W9 P) j
/ m/ h/ @! r: O. i+ N, S! f( P% I
import java.io.*;
$ ?# f' p9 n5 D" O% q" O  B
0 z- U: C( G% f& m9 npublic class ProgramCompare5 A) E# G. O8 a
{
& `# s% |3 \& _" Y        //-----------------------------------------------------------------  _# y/ H) a  X7 S( Y- E$ S6 `
        // Constructor
$ S$ i; O( j7 b7 k0 H- @* T( G5 L4 f        //-----------------------------------------------------------------
) A/ U+ G& z( r* a        public ProgramCompare()% K3 c- H- F& P
        {( W( }! X/ s5 c
        }
3 X' R9 S  C% C, v6 [+ B; ~6 s6 R5 F; B1 V
        //-----------------------------------------------------------------" x, e& K: x: ~9 |2 N
        // Method for testing that class has been reached
" Q8 V4 ]1 E; Q4 z% e        //-----------------------------------------------------------------        6 K, q7 V7 C% J7 Y2 I' N8 J$ w
: w0 R. m$ f5 `/ e; g( ?9 A
        public boolean ProgramCompareReached()         0 [$ x! H- a* l9 \2 `/ ~6 z
        {
/ \4 c. V- [# O6 \% Q      try
, |6 F$ U% ~: ?3 I   {         9 X7 b' `) m  X" ~$ s# R7 b
                       
: U' V2 |& k: T, y) b/ j1 n- k8 s                //********************************************************************9 `' T6 T, W% `1 J  D) A
                // Try-Catch Statement is used to handle exceptions - such as file not found
, ]' Y4 y: S/ Z$ m& K) A                // Reading the files will need to be placed inside a Try-Catch - just like this one!
$ i7 G7 }3 W3 C                // For more information see page 534 of the textbook* N0 w6 E( y( ]7 o1 ^# v6 b  h
                //********************************************************************, B, t& S" {% \5 V
                     0 q) f) R" Y% X1 e" O0 s
        }+ h+ U' y, A, S) r- l) Y8 O7 N5 P
             catch (Exception ex) // Exception caught here and message displayed to the screen 6 p9 q$ P/ K- h
          {8 E6 A- [! g& r
                    ex.printStackTrace (System.err);7 S# q1 z3 u- Y! K
           System.out.println ("Error message goes here"); // Replace this error message with your own          3 O1 S3 }) N" V8 B7 k5 d+ ^3 y. }5 c
        }) `0 o7 C+ `2 K( R6 G. ]* o
                return true;6 Y) ^2 U! `. v# p" z1 a
        }5 o! B. W/ G" s1 S
2 a1 w0 F3 I# O' u8 ~; N# s. l
} // end of class ProgramCompare
6 V. }( l# v2 E! g* a, K% k$ s+ Y' R
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************& K. e$ m4 ~* e  b, C6 w/ x
//  ProgramCompareMenu.java    Provided by: DRS' O: o5 ~9 `6 O& s
//4 {# M5 L9 `: |  ^
//  Calls AuthorisedUsers.java and ProgramCompare.java8 O) H1 ~! p5 S+ S
//$ s; @' @6 n8 `3 O" G
//  Driver shell for Assignment 2.
4 ?5 k8 ?( D. y8 d: L) B9 e//********************************************************************( \3 }+ v- s0 b9 u  B9 }6 |

" u- D* d$ f. M; B9 e/ vclass ProgramCompareMenu
3 P1 I! D9 r* h" D: I4 B$ c7 f{/ s# d+ k7 @( ]+ S$ E7 Y, S
    public static void main (String[] args)+ ~8 [6 k: x# n3 w8 c0 j& \
            {
6 E: \8 T* \( c1 V                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable/ w: [/ f3 O9 Y- A9 Y
                ProgramCompare reached1 = new ProgramCompare(); ; x* F2 [( V; T
                AuthorisedUsers reached2 = new AuthorisedUsers();       
. \, B+ t! t: H* \" ~" [- [                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());: l) M* N* f6 Z. C! y# H5 E8 Y
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        0 \/ x0 \. M( Y6 O9 k5 O
        }+ k0 X( m' p: W' a) G1 Y, ?
}// end of class ProgramCompareMenu( z& C) O+ L$ ?* o/ R

7 c( u; Q* [: P//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************  r# ?4 A  ^5 X! a( h
//          AuthorisedUsers.java          Provided by: DRS
: H! }) t6 t3 W( v" j//                % d* W4 y, l3 V" w, w; |2 A% G
//         Program shell for Assignment 26 O6 Q& @( V- K' |( H4 p" y
//
8 {. Y! `" z. w* ~//         Represents facts about an AuthorisedUser. n, _  F+ _- y- Q  I# E
//********************************************************************
2 Y# w/ G4 \$ t% N
  b- O! @4 C0 L8 J$ ?9 z* a+ u( k: Qpublic class AuthorisedUsers
  Z, n6 i+ Y8 v- i- T    {
' @7 E2 K3 C+ w* c. o9 k( ^7 [, @9 \% F( J9 j/ \
        //-----------------------------------------------------------------
, i2 F6 W- |* X3 ]        // Constructor+ t0 K; A* e: [1 h) @3 q
        //-----------------------------------------------------------------
/ i) H& m6 _+ B+ _" p; w
/ j/ L$ H/ e9 ?8 R        public AuthorisedUsers(). L0 V% }* i& \4 F. J
                {  G8 s; o  i" a2 v
                }* k  ^2 d+ J! D3 w! e& [
  R2 M; v% a. Z! \
        //-----------------------------------------------------------------
! B& b, E9 b9 p" ^  c! {        // Method for testing that class has been reached
/ r/ p# f( `# S( `6 y% [' @        //-----------------------------------------------------------------       
7 f- S: o# P( J6 O/ X9 w        public boolean AuthorisedUsersReached()
7 x/ i) N* V- V. I                {. c& M4 E$ T9 c1 w
                        return true;                       
3 K7 O3 }, d7 j0 F                }0 _% J  f3 V+ k# b/ k) ^! I% {
                - b8 l1 X# N( b6 o( n" {" _* F
    } // end of class AuthorisedUsers
# ]9 C; a: F: G/ @- C' _//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
' R( ~: y! \9 T6 dShanghai - 20077 c; C8 E/ @/ u+ c) p+ t* f
Assignment 2
5 Z- @9 n& K( E, e* c( r, R4 d' mDeadline 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)
( o, q6 H7 F/ C/ N! B1. 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.
& t( ?# ]: v. u8 ?9 h! bThe staff must be able to:2 l/ @: D; V+ d
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.& \1 H4 }; G" J7 o6 N& J1 Z
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.
$ e$ X9 H* x3 t$ n- U( x6 K The interface should provide a menu so that the staff can:
; U% {' }! X$ d+ |0 X' B' va) Enter the names of the two Java program files to be compared* G2 w/ |* w, K4 l5 Q
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.: @5 x% W- _5 [  \6 F0 Z
** 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).
+ J3 q; ?. Z* kBSA104 Business Programming – 2007: Assignment 2
+ V7 n9 m( @. @- e4 Q" E1 vPage 2 of 5
/ |; D. Z( o* tb) Print out to the screen all the lines of code that are the same
2 `* @+ e3 s1 P/ h  s) {7 Y) b. n Include the name of the file and the line number of the code being printed for each of the two files9 b3 H1 U( c1 T/ M! K/ Y
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
. y, S: r/ S! S1 q  j! ]2 Z1 e& C the name, username and department of the user  z3 K0 p3 O1 _5 k2 ]
 the statistics of the comparison  z* n6 y( l+ Q" [( }& W& @% h
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different5 Z8 b4 L6 N: S* y1 Q7 o- `
 the recommendation for further checking
4 |* v; G  L7 e) l# b/ z5 _- 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; k- L, P4 s: R- k# u& s0 E
 the names of the two files compared
2 L& v$ a2 B0 E% \+ ^( k( Hd) Leave the program (exit)
, H% {$ h  e2 |. Y# c% J8 BThe ProgramCompare class: (Total maximum 20 marks available)
5 l, b0 u7 p8 H7 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)' B3 R& L* h& X6 Z4 _
a) provide an error message if the files are not found or there is a problem opening them
# p3 `2 x, D7 y* Q/ q  Qb) compare each line of code
8 H* C2 h* g0 k2 c6 T; bc) print out the lines that are the same; M9 l9 Q9 e1 @& q7 U
d) count the number of lines compared / lines the same
0 y1 F# [5 w8 [; Y  q9 \The AuthorisedUsers class: (Total maximum 20 marks available)8 Q* }7 p+ |, l5 K
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)7 R# g, P% q& E, H. h
4. Provide methods to:
0 k% m3 P1 Q5 M, F+ o6 Ja) 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
6 s* g( o3 g2 Ub) return the name of the authorised user
+ w( c, I$ \; _% r) b+ gc) return the name of the department of the authorised user: ?0 I2 y" T3 ?' t6 `
Individual Data (Maximum 20 marks available)
# `7 P2 {: d1 b7 k8 Q5. 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.
* F7 U: P. y, i6 k* u4 s- {Documentation (Maximum 10 marks available)2 y1 _/ N2 X7 ~- G  Y
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.
5 E* n/ {- N2 l( k3 g& F* Z5 ]BSA104 Business Programming – 2007: Assignment 28 ^5 U  l" u! W9 Y2 U+ q% O
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了% j1 [' V' F# w- |" E
不过你要翻JAVA的类库说明。你有下载没有?
/ _& z! ]+ D1 z$ N% a" `查询关于对比的函数。貌似关键字是contrast,还有compare
! ^  X3 y# D, a2 ]7 J7 I" j1 r
+ y3 d* ?4 w% r[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。7 e' ?$ {: ~8 W. M' `( E1 m
可以下载到的 是 jdk-1_X_0-doc
/ K+ d0 a; O! e" L7 C9 t3 S* _
: M) ?+ K( s/ `: M[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-16 01:52

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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