找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1227|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急6 u; j5 p2 M) v x: M7 G+ d6 f) Z* d , _* k3 t5 e1 M7 p t- @! T
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************, d1 U3 o* U% g
//  ProgramCompare.java         Provided by: DRS: C# o7 B/ }. t9 U3 S  A- i" v' O
//
( |; ^8 c. @6 r% B/ A//  Program shell for Assignment 2
! `3 R4 }* m8 n) ^7 O7 D//5 i4 A; b. Z9 Y, U
//  Compares two text files line by line
. p4 q) h4 E: y% z4 @- D//*********************************************************************
2 G  h/ V) P$ ~& Q# ~
9 Y% s3 b7 C! t# Jimport java.io.*;
2 t% p: \3 g0 R1 P1 g/ @3 X
9 B1 ~& Z' m7 \0 c" ypublic class ProgramCompare' O! s/ l+ J# Z' T; r* o$ g' O
{
, [6 j) r8 Y9 I+ S0 s- i        //-----------------------------------------------------------------0 B7 J! J" w0 y" K4 N
        // Constructor1 a, W% w* g; `1 `% y* ?: P
        //-----------------------------------------------------------------
) e4 `8 n- q2 q: \2 Q. R        public ProgramCompare()  i% n1 V$ s) |% h- x
        {: q# a( z5 i3 f/ b/ A* n
        }. b4 h4 ]: f5 b/ {: o
3 y# T* D# z$ s: `! M# k, Q* a( x' F
        //-----------------------------------------------------------------8 ?' w# P( V. c! A
        // Method for testing that class has been reached% K+ A4 U3 ~# f) {) I" {
        //-----------------------------------------------------------------        ( |' ^& [9 k! i. K

$ ]3 Q/ S7 f2 S0 q2 b        public boolean ProgramCompareReached()        
2 [' l8 T2 V8 ^3 T        {
* \" {0 y* v/ B' K% T4 z      try . J1 g& e' }: _* ?  ]# I* P
   {        
+ T3 O# S! m, y0 R                        * l+ S6 H4 m' i! i7 s
                //********************************************************************# [- g& |6 W9 i8 U
                // Try-Catch Statement is used to handle exceptions - such as file not found
' p; e" h, P9 V9 s                // Reading the files will need to be placed inside a Try-Catch - just like this one!
9 ?: z1 A3 P- T# ]2 M4 O# I/ W                // For more information see page 534 of the textbook
$ d0 G, Z$ ?  p                //********************************************************************
2 @$ K* _$ ^' s: g" {' n' y                    
$ S( P6 V2 a! l5 b' ~        }
. f1 [3 D, ~2 f& `% `1 H' `             catch (Exception ex) // Exception caught here and message displayed to the screen
' ]+ S/ [* q/ f' b: c( _          {
. ^  ^. v1 v  M6 h7 @                    ex.printStackTrace (System.err);. i$ d$ R2 [5 H8 D/ m* x
           System.out.println ("Error message goes here"); // Replace this error message with your own          & H; i! G7 w; s- X& D& L1 C
        }
" M9 U; c8 F7 l( a# I# {                return true;- \7 N8 h0 t1 ~' ^6 J# v4 v/ ~
        }. @2 ~. n5 f. a( u' e
6 R. {1 `# F" c" K3 X9 g) k9 o# y
} // end of class ProgramCompare/ K7 |0 h) l/ b
: V4 R4 U$ \* p/ L& Q
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************! U+ w( K& r/ f4 s
//  ProgramCompareMenu.java    Provided by: DRS% s1 k' g. Y9 F
//
# r1 P, A2 G8 y+ |" ?, f//  Calls AuthorisedUsers.java and ProgramCompare.java
) a" K. ~: }5 S, S, T//0 [8 ~. m8 ^4 U/ b* x) r
//  Driver shell for Assignment 2.
" s9 ]  }# @+ z& T//********************************************************************9 N& C- }7 l& E  a9 J
- N" D+ P' P# I2 i9 v6 M8 w+ x
class ProgramCompareMenu$ }/ G% d& R+ n* o3 D+ A
{
* A; G8 U% W$ i# z    public static void main (String[] args). |$ |  T# ^+ N# L, Y. ]' v7 s" V
            {9 R( {" a2 y& x  l6 X( o* T
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable: a' q6 g% `; S, [3 g. I5 L
                ProgramCompare reached1 = new ProgramCompare(); % B) a  X$ c: ?" ~- a  \0 y6 ~
                AuthorisedUsers reached2 = new AuthorisedUsers();       
( i4 B2 ^8 f* l. l% i6 V  k                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
4 d& P+ H) h7 k0 u  F) x                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        4 T7 t' b# _% f: F* d+ D
        }7 A/ c- P, M3 o
}// end of class ProgramCompareMenu
$ k2 |8 u& w( n4 @
4 T# B. c/ a( ]" i/ o//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
  f- ?* k2 A! Y//          AuthorisedUsers.java          Provided by: DRS
  ?" f9 j+ f! b7 V% E//                - ^6 {! b; D$ h
//         Program shell for Assignment 25 m; `* [! X& w1 m- z" f- B$ U
//
9 X- M  G9 U+ ]" d! g//         Represents facts about an AuthorisedUser3 {. }5 t* Q, N! a7 p& u
//********************************************************************$ q. m0 E- O# d1 R
2 P6 ]" e. X8 ]  u( \
public class AuthorisedUsers
( O7 g* B# R' f$ f4 q# {  x    {4 M# z8 J' @7 B0 @6 o. J: n8 i
' w8 H6 Y6 w$ k, I. h, N4 k
        //-----------------------------------------------------------------5 `% V3 A, B0 m8 i' R8 H! `
        // Constructor
# \- c4 ?3 v" V! \" ~1 |5 Z        //-----------------------------------------------------------------
: N7 m! a6 o0 ^$ u0 I  n0 u, O: b! _: R5 d$ X  n
        public AuthorisedUsers()  y$ U/ T8 y$ i, V7 f+ A1 O2 Z
                {2 {( C% d  P6 z! e  r, r
                }
( |# I7 r8 C7 C
6 ]/ ^8 c5 |9 t: Q- v# O  ~3 _6 [        //-----------------------------------------------------------------
! c: o+ M& Y4 X) R1 `        // Method for testing that class has been reached
% W9 Q8 Q$ p/ x/ R; |3 i' N" k        //-----------------------------------------------------------------       
4 v! Y3 z/ y; C8 I2 \2 s8 y! {5 I        public boolean AuthorisedUsersReached()
1 M3 f, E, I( y) J0 p% B. s                {
+ K# s# t- |4 E) W) B2 v                        return true;                       
7 x& j9 n4 v3 `" A$ F( r! U                }
8 y9 D7 {6 e% g- Q4 v               
6 j4 C( p+ g9 L! t" P    } // end of class AuthorisedUsers
" c* A6 K% D1 v5 M+ M//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming2 T# a3 q( \5 P8 a2 p
Shanghai - 2007- O# k2 W* J1 u; G3 S
Assignment 2
8 H% v, C/ k4 aDeadline 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)
" a6 v( \! B0 y0 I, w6 d# n1. 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.: v8 Q3 x4 C  f
The staff must be able to:  I' Y& n0 N; ^
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
0 J2 G( Q9 b0 A8 h8 V0 {" H2 A1. 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.6 O( t0 Q: w8 f& y0 l
 The interface should provide a menu so that the staff can:  v- J- q! J/ G' ?! s: ?7 z
a) Enter the names of the two Java program files to be compared. ]1 q% Z8 R. ~' i
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
  o, ~: H! {: N5 t7 T** 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).
# U& [% M% n( J( x" ~# oBSA104 Business Programming – 2007: Assignment 2
  Q2 }  c2 H0 d$ ?) ?0 kPage 2 of 5
. |! _! N7 \* nb) Print out to the screen all the lines of code that are the same; ]6 u7 F0 l8 f* Z+ R9 D
 Include the name of the file and the line number of the code being printed for each of the two files, |! u7 ?  A* a2 q) a
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared9 m9 p! H0 U6 j1 g
 the name, username and department of the user' i% G1 n! p: _2 q, _# \. x
 the statistics of the comparison
8 u& d( C) \9 x) T- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different, p9 ?3 C+ i! c4 W8 P$ |* R! d
 the recommendation for further checking
8 }% n$ ]- T+ s6 p8 R3 F; ~6 ~- 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
: p% h8 @* ]6 J: ` the names of the two files compared
8 g3 n) M- K* j: r4 Rd) Leave the program (exit)$ L9 M2 ]- h# z4 W: ?$ @# g
The ProgramCompare class: (Total maximum 20 marks available): P" \; M! M$ H- g% g$ B
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)3 v+ p  y8 J0 q. U6 Z& B9 `
a) provide an error message if the files are not found or there is a problem opening them
: u9 t5 ^% Z1 h& o) Q9 ib) compare each line of code
* f' n7 F% |8 s4 B0 k: Wc) print out the lines that are the same$ |* T; Y* g' p" q+ r( {( O
d) count the number of lines compared / lines the same
- ~- |$ R( e; e5 `+ ]4 iThe AuthorisedUsers class: (Total maximum 20 marks available)
! e6 d( E3 S. k9 Q; m3. 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)
9 f1 M" o. M1 A2 B8 ?3 T) h5 t4. Provide methods to:
) ^  _5 U; n9 n( M' ]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) O6 p5 {0 z; p+ J' B
b) return the name of the authorised user
7 B/ J* l! ~) D% p7 V5 Mc) return the name of the department of the authorised user
6 N" X- o7 D4 M6 g) Q* f8 VIndividual Data (Maximum 20 marks available)
1 r3 c% W+ u% b5. 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.
6 ^, L3 [) Q5 C9 aDocumentation (Maximum 10 marks available)
- T- H. n" Y6 `6 O6. 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.7 ^5 W2 p& ^! }) |7 s3 N
BSA104 Business Programming – 2007: Assignment 2+ U  X8 D0 p0 |2 ~0 |: W( Z% m
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
$ ?7 n! s3 k  D$ N* ~! g不过你要翻JAVA的类库说明。你有下载没有?
7 a3 e- J: k- J* H9 w, _查询关于对比的函数。貌似关键字是contrast,还有compare
1 \( c0 H' ^& S2 C) [8 ]
. F8 D! K# j+ q: x' o- f$ j6 U1 q8 ~  |[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -9 d: T; Y' m( M( _4 V. Q
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。, ^# E3 _' R, ^/ ?- C
可以下载到的 是 jdk-1_X_0-doc
7 `7 \9 g9 g/ {4 X* p0 J2 h. R3 X
& ]: R8 }$ \$ a/ G6 c4 e( ?[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-22 10:35

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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