找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1052|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急+ C/ j' L" n6 l% R1 l * G8 L0 b3 n$ k) ~7 X
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
9 Y& H) }9 o% f1 p. q2 N% E//  ProgramCompare.java         Provided by: DRS5 j$ ?' v: R8 ?  X1 z
//
0 ~, n  l2 z; ]3 B; A' J' m//  Program shell for Assignment 2
/ N: s- B/ |5 j//4 ?2 l* V; J+ m9 f5 Z
//  Compares two text files line by line& Y! \6 }9 R3 z2 [
//*********************************************************************
, b0 q- o3 N, o, t% ?
" v5 ?  p: N% A; j& W8 Limport java.io.*;" V/ q% A; u2 f; b6 F# h5 U

' f7 t7 m  O  n  k& L4 R; B- ^/ lpublic class ProgramCompare7 B0 @& @& n% N; i" |
{
. p' R9 f' u( l) K' [0 k        //-----------------------------------------------------------------/ `: u. W! d; P% W6 i
        // Constructor8 V/ o$ m2 d0 P( ]: h2 P5 J$ E
        //-----------------------------------------------------------------
* w5 T4 E1 |3 S+ x& Z: I        public ProgramCompare()
5 A8 e; K6 }% q+ @; {        {7 U$ E* B5 O4 T& Y1 B' P2 t+ e
        }
# P- X$ ]" @( @$ T/ M( I/ T
7 j+ i$ N, a: ~" `& d7 F        //-----------------------------------------------------------------* Z+ A- a5 d% P. |5 |
        // Method for testing that class has been reached
( e% H" ]! @  y) i! P        //-----------------------------------------------------------------       
6 h- h+ l; @& _+ ]% R$ |" y6 e+ K2 |- i3 a; u
        public boolean ProgramCompareReached()         . U6 ]  \: t& z: ^; _
        {
0 g( e) D3 b2 m3 b3 o- \/ y9 X      try 2 y- J: |( g5 s( X9 U- r& J
   {         ' S0 P- V% @; t+ r
                        5 I0 a& }0 `2 D- ?, `
                //********************************************************************! ~6 U$ {0 a& O- D. t* R" `; M6 n- e
                // Try-Catch Statement is used to handle exceptions - such as file not found
1 P6 y8 |, m2 a) |) L                // Reading the files will need to be placed inside a Try-Catch - just like this one!
  G* @9 i3 d, ^                // For more information see page 534 of the textbook
- E' @5 ~2 h2 k                //********************************************************************9 B4 [" X; U4 {4 N0 Q( r) u! A
                    
' p2 a/ u- Y/ T# e/ i' U/ @        }9 e# X9 x$ }1 L! d/ F2 d
             catch (Exception ex) // Exception caught here and message displayed to the screen
) J4 V: Q) w& v% h/ }          {* m. L+ F/ P+ o- |/ S) G" R) G; l
                    ex.printStackTrace (System.err);
, S/ g  d7 B: Q" g           System.out.println ("Error message goes here"); // Replace this error message with your own          ( h; a( C# A. t2 K2 U/ i( f
        }
' W/ e7 X. B  T                return true;' O7 L4 ]9 o; `, @
        }
+ N, A4 \" E) k5 H' H+ p, e; ]! W, `
} // end of class ProgramCompare- s( c0 e9 J* |5 X

" U" k& m+ c) ]% J//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
( x+ r+ z. ^& j, t  v8 p# r+ H//  ProgramCompareMenu.java    Provided by: DRS
, F6 z/ m7 L; n//
1 V6 ?, p; l1 o* b3 ~//  Calls AuthorisedUsers.java and ProgramCompare.java
5 F8 D% U) ~7 s+ R% u//
! a2 Z6 I. `3 C1 d7 ~- I9 ]//  Driver shell for Assignment 2.
4 G4 h& b  n! a" E; N" N3 R; E//********************************************************************. X- o3 I( X" M7 M
, T7 j: R5 H& W7 {
class ProgramCompareMenu: p: X1 {$ S$ k
{# E4 U  R  ~% Z" p" u% A! W
    public static void main (String[] args); @! b: l4 h6 D8 Z& T8 t. d8 |$ C
            {
3 F2 Q5 E) Z# b) N& H$ S1 Z6 C                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
: e# m7 K" B, q9 v. J5 ?4 ]                ProgramCompare reached1 = new ProgramCompare(); , f1 k& D) f" k  Q$ o4 c" O
                AuthorisedUsers reached2 = new AuthorisedUsers();        : v* ~' L$ J) X0 ^9 N. H
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
; D1 B  z+ d' J, a5 w: o- e                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
# r1 t6 t/ \6 ?        }0 g& U  I9 w# M
}// end of class ProgramCompareMenu
# u1 R4 |1 C3 \  {7 [- i5 B6 |
4 ^" F) [0 g/ c4 j5 ?//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************" O" y8 Y. a/ z8 V( t, j
//          AuthorisedUsers.java          Provided by: DRS  j: i" S6 G+ [: B
//               
" p9 M& e/ z5 p+ Z) p4 ]7 F7 }* K//         Program shell for Assignment 22 B0 t( p" O# T. A3 |' c4 I
//, G0 q1 w$ A/ o
//         Represents facts about an AuthorisedUser
+ t  t" J9 \6 p8 Y; A5 I, ^4 }//********************************************************************
) j8 j: |! r7 X$ [3 M8 L1 F+ ^
, r9 T% l$ f- Ypublic class AuthorisedUsers
2 c- V/ `- q3 h9 O3 l* R/ r& I4 ~    {
4 P! s; M; ^2 T* l! `- b+ N3 `) E- [; k
        //-----------------------------------------------------------------1 m0 u7 }$ ~+ N2 Q  X
        // Constructor
' m7 o8 }3 s3 p9 r) k% P( U        //-----------------------------------------------------------------
) P; ^5 @( e1 O) f, I* e5 C5 b! {1 M" g: g  F$ m
        public AuthorisedUsers()
3 u( @5 l0 I) n1 K7 N                {2 ~! i$ _7 c! j+ G6 n8 i, w+ x
                }) {7 ]% c* \# i- z, z9 |* e# N- _. C

/ C4 b% A5 l. A7 P        //-----------------------------------------------------------------; T% _- B% N! b$ c2 a
        // Method for testing that class has been reached4 n2 b- v) a: x( {
        //-----------------------------------------------------------------        # V8 D) a$ v7 T5 \8 f& H4 T7 c
        public boolean AuthorisedUsersReached()( f/ r1 z- Y: ]4 |; j. Q! D7 I
                {
$ E5 u4 J9 G7 w6 u                        return true;                        % R- G4 q! {( t
                }
- K$ p9 t$ v! {& u, Y               
% x% V" _2 J  x  V) x. {3 U    } // end of class AuthorisedUsers. m7 u% M1 D$ v# ^  A- E$ ]" k
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming, K  y  l  v8 g( c8 h8 f
Shanghai - 2007
  n# I8 l7 {2 o* Y* J. cAssignment 23 `1 h. G# N  L) e# }" a1 Z
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)1 v0 B8 f3 V6 s3 v$ z& g) R- N
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.9 X& [/ D: t0 `) u* b
The staff must be able to:
/ D2 |* W; A( K; r Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
5 s: ]4 J$ o1 _7 b' R1. 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.
. o1 s5 V$ {! a6 c3 c2 v: [+ j+ `8 s* D The interface should provide a menu so that the staff can:
/ w7 \/ r' w3 `: B1 V& s1 Aa) Enter the names of the two Java program files to be compared1 g, S2 B7 d; V4 e
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
: ]. C3 _# E3 _; S7 x** 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).
" N/ b2 F9 n9 U5 p2 j& E: o+ A2 K# `. PBSA104 Business Programming – 2007: Assignment 2( {8 M+ ^0 H4 M" H& s( \- K# `
Page 2 of 53 g5 p) B8 [& w
b) Print out to the screen all the lines of code that are the same
" a6 z$ T( e8 O) c' R1 _ Include the name of the file and the line number of the code being printed for each of the two files$ c( H' h. g! ?, K: t& ?+ g
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
; v0 `, G$ \: j; |7 A5 _: U the name, username and department of the user
3 _1 s7 ^* B1 P1 S5 K& Z4 V9 O3 j* S the statistics of the comparison
/ n# g4 [4 e( t  K1 }- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different$ g. e- q  {9 x9 b" ^/ b
 the recommendation for further checking
& W% ^( {& L1 ^  ]0 n% I- 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# ]% q4 k+ w. }# s
 the names of the two files compared+ l3 f1 J! U' c- L
d) Leave the program (exit)
& I$ ]' p+ M' E+ m. ~The ProgramCompare class: (Total maximum 20 marks available)* i  ]; h! N! f1 t( D. M
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)
% d. ?: a$ E2 ^# Fa) provide an error message if the files are not found or there is a problem opening them
. p3 B; i: x7 pb) compare each line of code
9 v; h7 V( h4 }c) print out the lines that are the same4 ]& t2 ]* d0 i; W& W
d) count the number of lines compared / lines the same
/ O7 v+ I% d, V2 i5 \: a4 Q" uThe AuthorisedUsers class: (Total maximum 20 marks available)
  {+ ]7 L9 Y2 S/ T* y% y3. 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)
2 W- Q) |" w4 H$ h1 O; a8 d4. Provide methods to:
9 F, D5 f+ U: d2 D0 q+ [& Oa) 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
& c: c& L! }/ a1 D$ s9 |1 l  Z1 Zb) return the name of the authorised user4 u' @% F3 a9 g. t' g
c) return the name of the department of the authorised user
( U: \* b$ P+ jIndividual Data (Maximum 20 marks available)$ O0 ?% k0 S1 ]* M3 i- [/ M/ o
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.1 j! _: Z: C( P' H- H1 X" z  b" h
Documentation (Maximum 10 marks available)
$ l& A+ Q. l% B* S& I. N2 r+ y6. 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.9 v, l1 }; d' J% f
BSA104 Business Programming – 2007: Assignment 2. Z" [$ ?) j3 ]+ J. B1 K
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了  n6 n. N( X+ t- |+ l: P/ B
不过你要翻JAVA的类库说明。你有下载没有?- \$ V) u0 G8 l( d- x) ~
查询关于对比的函数。貌似关键字是contrast,还有compare' {5 p& _1 J9 L( A8 a. M# L

  X  D" Z3 {* [) z[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -3 V* B' _5 Q4 N1 g
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。) `! w5 k. {, Q8 w$ n& V7 I9 B  p$ L6 e
可以下载到的 是 jdk-1_X_0-doc4 {$ o/ K0 C0 ]5 A8 C. u+ ~( p6 w# J7 v

9 L3 ^4 [! U4 z[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-15 06:09

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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