找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1248|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 , R( Y* v! Z, F, @( c3 @ 4 n; i K; b) c4 m6 j5 a& d" [
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
5 A% v. C3 s0 w: M/ K* o//  ProgramCompare.java         Provided by: DRS5 h( Y3 l) X1 ^% j9 B& q5 Q. c, K
//
# Z- j6 M  H9 e3 j/ q+ Q//  Program shell for Assignment 2
3 \3 e5 C$ c# i  n//
2 O* z& K5 \0 J7 k! ^! U3 W//  Compares two text files line by line+ I. Q* r- d$ s5 e1 _
//*********************************************************************
1 b$ I( B2 G: R- D& A. b" [8 z" l% h7 j( M
import java.io.*;. B! F: x6 t4 M$ }3 J. N
4 I1 F! ~/ _- P7 c; R' {! F: U
public class ProgramCompare
( ?- U  R* J, l* x5 P$ q1 V) u( x{
& k3 ^. M  t) [7 D        //-----------------------------------------------------------------/ D5 ?9 n" F- G, m9 k) ^7 R
        // Constructor
3 {( X3 X1 Q7 n5 G" _/ j2 Z6 l        //-----------------------------------------------------------------
# r, E: F' ]# |* W        public ProgramCompare()
- C8 v5 z" I. @4 }& e9 l        {
( K* g4 }* _( _5 U  w5 J        }2 X8 N8 W' A0 w$ |7 _

& X! ^$ N7 w0 [% l; i        //-----------------------------------------------------------------
: R# z: R3 z' n: n# p5 }6 p+ E$ F        // Method for testing that class has been reached$ |& d) g" c+ Y
        //-----------------------------------------------------------------       
/ s5 o5 W: h% U& B* ?' C5 k5 [  C4 N2 @4 l, z$ X( W) q1 _
        public boolean ProgramCompareReached()         2 f1 a% _9 j* u
        {
- k: L9 x0 l3 s8 ~5 ~0 C+ R1 l      try
0 M) }% Z2 A$ Z/ _* |- @. L   {        
: e' K; D) s) m+ r                        . p& I8 n* H, O' o% m
                //********************************************************************8 [- a) R4 e" v
                // Try-Catch Statement is used to handle exceptions - such as file not found % X8 p, U  W. H( c
                // Reading the files will need to be placed inside a Try-Catch - just like this one!& P) l1 L4 g7 G3 Y* R$ ]
                // For more information see page 534 of the textbook
- }+ D& O5 @8 `4 C* I' w                //********************************************************************
$ g, v" W! F( v* g/ S                     * L# q- y2 c4 h! A: ^
        }5 R$ V) U7 Z' E. S
             catch (Exception ex) // Exception caught here and message displayed to the screen 7 |" V0 Q- o7 r" [
          {
& ^' d1 g) N7 T* o                    ex.printStackTrace (System.err);
0 y4 G$ P# M, S* b$ ]           System.out.println ("Error message goes here"); // Replace this error message with your own          1 V6 a9 B- H5 O% q
        }6 v/ _9 X0 F4 h
                return true;
3 d: v% I% V+ M6 P/ p( r! _' P        }; X! @5 A" U. i: |" A+ f2 r3 C

/ f7 I6 M1 w" O} // end of class ProgramCompare
8 u, Y  r0 h0 ?6 f2 s/ Z/ t) ?4 P; ?" w. A8 i
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
" @- x1 F7 l) Q. N//  ProgramCompareMenu.java    Provided by: DRS) r3 d4 i3 Q- e
//
8 ?3 x! T( E2 w+ f5 x& E  m+ |) i//  Calls AuthorisedUsers.java and ProgramCompare.java
. E" i$ q- r# |0 O//+ O9 P8 e& F6 A# A
//  Driver shell for Assignment 2.  D$ k, d4 k% A6 j  Y
//********************************************************************
* v( |+ {! J4 F' v
# N+ ^% G  d# h2 D( yclass ProgramCompareMenu
- {# s6 j3 ]0 o5 @# w# [{
: h3 C' z3 z  \& n. o% W$ m    public static void main (String[] args)
' Y- c: O0 [2 V5 R% k3 G7 V            {* [  w! i. Q' Q8 e. c
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
& @- k4 B# Q7 |                ProgramCompare reached1 = new ProgramCompare();
* A. C0 x, s4 t; f! g3 @                AuthorisedUsers reached2 = new AuthorisedUsers();        + |9 E- T; C3 a8 |3 @# P" y) @" g0 w) k
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
, Q+ D& t) z* H: M8 a. M                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
6 L# g! o! ~+ U( d6 O& q% O        }# }! n3 B6 X* e) r
}// end of class ProgramCompareMenu
  H2 L+ k- s/ C9 e8 Z
& W) l% X% {: d% J. K//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
; V5 [5 O7 \$ U7 W) n//          AuthorisedUsers.java          Provided by: DRS4 E* T  B- N: X* d
//                + f5 H$ ?. S4 Q2 o" Z
//         Program shell for Assignment 2: S1 _2 `! {1 F/ Z
//
. e+ y' Z: r! v/ o, B) O9 d//         Represents facts about an AuthorisedUser! M/ P8 s0 w, d- S: t4 C9 c; {% h
//********************************************************************
6 n4 |7 Y- M% b/ j1 D
) E9 }+ G* U: C. f' E) h3 q% D- Zpublic class AuthorisedUsers
6 S; {9 n6 T3 w6 i    {
& ]% T( L4 ]" d
5 \/ ]( U% |! c0 ^( i. K9 K        //-----------------------------------------------------------------0 S0 S: K/ l# O1 K2 H7 d9 a
        // Constructor
/ e; p% A# o0 x3 c) w* G! g        //-----------------------------------------------------------------
8 {( V* j/ a$ l1 x+ a- N" [8 F( s' s9 q  S( {$ K- ~% C
        public AuthorisedUsers()! |0 ^' Q0 X* r0 y5 _0 Z/ [0 I
                {3 V' J, |9 x- u8 |( b4 B5 |
                }
  l$ h& D+ Y. R. `' A$ s. K
( x1 N. v3 b, F& q6 s2 J# Y        //------------------------------------------------------------------ M2 A  e: `2 I- k) O
        // Method for testing that class has been reached# K" v) A! C( F  n
        //-----------------------------------------------------------------       
3 ~" o) A3 n0 C/ ~# {        public boolean AuthorisedUsersReached()
7 J  p( w" r  U4 r% L                {
! @- s4 t- J$ F$ a                        return true;                        & Q) R# A% r# f% Q1 h2 n  `
                }6 m6 J4 n, B3 n1 u* d
                / p, s3 q$ m# I0 F9 F
    } // end of class AuthorisedUsers
% ~7 R& S& D% B0 ^0 F* s//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming% g2 V" g9 Y& d  B9 n  D
Shanghai - 2007
8 v# z7 J/ w- g2 ?% e* l- tAssignment 2
# |' K6 ~- l" g  Q; g: B' ]6 E. R  fDeadline 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)
0 K/ I8 F( a& \  [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.$ {( i# ~0 u, [* G, G- u6 M( B
The staff must be able to:1 R5 W  c5 J; s- @# @: F3 D9 l
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
' f8 t( ^3 k0 h1 V1. 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.
: K3 T* ^5 j/ O' L The interface should provide a menu so that the staff can:
3 d( {* O! M0 ]: K  t4 ha) Enter the names of the two Java program files to be compared
  e) p, q8 \: \; }6 X; T2 `  R For this assignment, it will be assumed that the two Java program files are in the same folder as your program., f* b+ d: V- D( K" v  U
** 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).
" v0 K; _. z. ]1 \* R1 IBSA104 Business Programming – 2007: Assignment 2
  Q% l, S$ d, \* [9 aPage 2 of 5. U; ?# x8 y& t5 L  s& B
b) Print out to the screen all the lines of code that are the same
/ a9 m0 V5 E3 O% @: ^  \9 ] Include the name of the file and the line number of the code being printed for each of the two files
, X! [8 C7 w7 n9 r: q1 V4 hc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared! `+ b' f0 L. p2 P# o
 the name, username and department of the user: c2 ~- T7 k5 U1 A/ ?
 the statistics of the comparison# @9 G7 Y+ Q" S- h# g8 b
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
4 \' H7 E# j( l! l the recommendation for further checking
$ }. L( d& M" E2 R8 i2 t9 _- 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
- y6 m, R( g. m the names of the two files compared
$ [. h0 l  W6 [+ |, nd) Leave the program (exit)
* |" ]8 ]/ r( j  B9 Q& zThe ProgramCompare class: (Total maximum 20 marks available)% D) h& y6 \4 u! v3 Z
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 Q( Q- m7 [% L+ J  N; Ua) provide an error message if the files are not found or there is a problem opening them- z3 d( Y5 k8 X) S
b) compare each line of code( J1 g" Z$ a2 I+ v, |5 }
c) print out the lines that are the same, C+ T/ e$ ]3 N/ `; A
d) count the number of lines compared / lines the same1 w6 r1 f3 A" t# x  {
The AuthorisedUsers class: (Total maximum 20 marks available)6 S7 D0 y9 I' M6 n; k+ h% [. l$ f
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)
8 e7 n$ V) @' A  [. Z: X: O1 x4. Provide methods to:
$ J+ {6 r* [8 [' H# I$ m, l. ?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 match
* S& W. R! }) X4 E0 f8 pb) return the name of the authorised user# O3 a0 Y. t' ?& i4 o
c) return the name of the department of the authorised user
8 Z, ~3 |' N: |. o- c7 uIndividual Data (Maximum 20 marks available)) ]4 ?3 C3 S0 ?2 o0 [1 J0 e# f9 C
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.4 l3 a, w0 t5 E% ~$ D4 p* x* t% n
Documentation (Maximum 10 marks available)9 @' |9 S/ H2 E% B
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.
/ V6 M, H8 I7 mBSA104 Business Programming – 2007: Assignment 2' O* @9 H/ I: P
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
) E3 v  J* t4 E. z5 w2 h不过你要翻JAVA的类库说明。你有下载没有?
! M$ J+ d$ V6 m3 y0 R$ ^7 }) P' O7 B查询关于对比的函数。貌似关键字是contrast,还有compare1 V- M: c5 L4 P. a! c4 Q

# }4 R, s7 s% p0 `[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
- y0 E& ]8 W& o痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
! B% K1 S1 D7 J* k  \3 r可以下载到的 是 jdk-1_X_0-doc+ F4 l, s) |6 J3 X3 `
( C7 y7 ~! V! Z# c% H& ^
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-7 02:59

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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