找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1246|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急* V: ^2 ]' n6 a$ k ( b, {2 b; `8 I1 h2 T" W, N8 r2 P
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
- F) }2 k) y/ Y//  ProgramCompare.java         Provided by: DRS. i+ _% n" `5 R- Q% ?( O
//
; H1 u+ {4 Y! _, t9 ?) u" \//  Program shell for Assignment 2
  c0 R9 z2 c+ R5 q. R( O" L  }//7 n1 `, [& ~$ t( P- d
//  Compares two text files line by line
5 p( O. {; a2 E, v//*********************************************************************3 P, r5 q0 d' J- s; [' u

2 V+ J! E3 B  J2 C6 Himport java.io.*;+ i( l  W! v0 S# }: H' G0 L

: L8 H3 _2 O% N' ~* gpublic class ProgramCompare' U; t7 M; a. O2 x. R1 W( p  e
{% \3 h; ^% m8 l
        //-----------------------------------------------------------------
; [3 ~- x. t. k  K, s$ X7 H        // Constructor
6 Q; U5 R7 U& g" G. U' d% E6 k  |# h        //-----------------------------------------------------------------
9 ]1 g2 i7 c0 {& u& O        public ProgramCompare()
) {% C# v* n3 u  c" y( G0 G        {% f( X9 r. F: Q+ J: |3 r
        }
6 |' E) r; X5 [; G
) A; S2 {' E" m. g        //-----------------------------------------------------------------
' s. E. e2 o' m! K# \  d        // Method for testing that class has been reached0 [* X- ]3 q0 }5 `7 y7 e7 Q
        //-----------------------------------------------------------------        . {3 ?9 a& P3 T& G

5 E6 Z! w9 k$ ?/ ?* P        public boolean ProgramCompareReached()         ) {4 g  m/ F  X# L
        {
6 N5 P4 ~" v3 ^' u/ j9 r      try   w% W, }+ r& V5 ~6 b- }" N" u
   {         3 J8 R6 r! ?$ P
                        1 Z$ s9 M3 x' Y' c% ~2 Y- p' a
                //********************************************************************
  I  T8 l# J3 l! P0 [: u. s                // Try-Catch Statement is used to handle exceptions - such as file not found . V4 [$ h, R9 Q& X* D. g4 P4 p% m9 Q
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
2 W8 s) a, R0 n/ \# s- S4 L                // For more information see page 534 of the textbook# j/ K- r6 ]4 v" U+ [
                //********************************************************************2 @$ v' d' x( Q
                     8 I# u- C: J' o: k/ ^& R
        }$ S- T2 i3 F" k, G( N. w9 g9 E
             catch (Exception ex) // Exception caught here and message displayed to the screen ; _. z$ i) j" [1 q2 `5 L1 u" Z/ K1 ?
          {& {  ^2 L9 Q( f8 \! x; P
                    ex.printStackTrace (System.err);
# ?  C+ L9 G1 T) N" P/ ^           System.out.println ("Error message goes here"); // Replace this error message with your own         
: ]' E( d5 v& k! E3 C6 n5 g( K        }( D# t- R3 R+ k! T7 x
                return true;4 l+ W# s+ N; A& j. z0 D
        }. k# O# X+ c! I2 Q/ o- ~
  X- s) I' I# Z- r4 L: S
} // end of class ProgramCompare0 F0 s7 H- K- x: s% r
$ t9 `- f1 P6 l8 @3 K$ t
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
2 Q0 v) g" U" C6 w6 \/ i0 R2 f# Z//  ProgramCompareMenu.java    Provided by: DRS
- E3 @3 [1 j) G//, h9 A* k6 l2 z4 R
//  Calls AuthorisedUsers.java and ProgramCompare.java; C8 {5 E! J1 B& j' z& r
//
& M1 F: D' L% D* Z4 i: y//  Driver shell for Assignment 2.
8 O) z/ ~8 X9 b! g  s6 _//********************************************************************3 }5 Z$ ^' z# t" G6 ?9 ?% T( L. {

# i6 _7 G, F, H0 {class ProgramCompareMenu
# I" ^3 G- |( }. t9 w5 E' X! [{
; F  D  R9 Q& ~  j  _    public static void main (String[] args)
2 T# v. d+ d3 Z            {: d9 f- V$ v+ P9 i
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable8 V" f( b/ i% y" N. z% o
                ProgramCompare reached1 = new ProgramCompare(); + z, i2 F5 Q) l2 U! ~9 y* a
                AuthorisedUsers reached2 = new AuthorisedUsers();        ( a6 q7 ~* }5 u0 z
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
8 j/ I8 p$ p$ B" ?& c9 X) |                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        # X; x  ]; t& f3 p3 X# Z/ [
        }: M0 [. Q8 G0 C' p" o/ M+ Q
}// end of class ProgramCompareMenu+ s7 [4 z0 l2 N- ]4 [8 S7 K

" V' j/ t3 o" P! s2 g//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************; o- j6 O) }1 j! N6 {, D# ?' _; U
//          AuthorisedUsers.java          Provided by: DRS$ }# t* z  B/ a5 |7 W9 c) Z* g) z4 p
//               
( e! N5 O8 c$ p5 v/ @6 c) Y1 L- I//         Program shell for Assignment 2/ c" X" Q( O3 o  b/ u- a' L7 t  m2 G
//
+ `% \6 y( X# g% f6 O//         Represents facts about an AuthorisedUser& T, S4 C! F/ @
//********************************************************************
" _# E# k3 p& v; L( \
: v0 ]. X6 n$ B+ Ypublic class AuthorisedUsers
/ l8 m, w7 S7 r4 U    {' ?  i) X% L, s
3 l, d. b  @6 D, \! ^8 i3 y% b
        //-----------------------------------------------------------------$ H$ k% F/ V/ f) q, R
        // Constructor
* S& u5 R. Y' B3 o, Q6 D        //-----------------------------------------------------------------
% ~4 j& S3 B5 f  |& b0 i
8 @9 K9 d& a# i9 f. O# U  L  P' A        public AuthorisedUsers()
/ s4 Z- @' F, m" _" D( d                {& ~5 U9 M$ N' \: t
                }0 u7 o9 u2 k$ ?  N( a9 c+ r
- J: a% Q6 h4 u: s. l# b
        //-----------------------------------------------------------------, Z) B! `+ y9 m! f
        // Method for testing that class has been reached
+ ?6 f2 Y) j  ?3 k% I; @        //-----------------------------------------------------------------       
% f6 W$ B$ o1 c, g- ~$ t$ P, U        public boolean AuthorisedUsersReached()
3 D* Z% s5 x  L( R7 b                {
* x1 }* }) p" O9 B# G# p                        return true;                        * ^/ E8 B: y" m3 Z$ ?( E
                }
6 l, g$ {+ Y& r! \/ s# {! C1 Z               
/ T6 M8 H* m# J: W4 h& ]3 ~# a    } // end of class AuthorisedUsers
! t5 i4 Q4 ?9 Y8 b) f2 O//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming9 {% O9 p3 h: m6 H
Shanghai - 20078 ~+ Z5 j& R! I4 ]0 c' }6 x
Assignment 2, ^. U, F& L; P1 N1 G* e( @
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)
( V1 y; f! d% P8 N; b- K$ {% |" i1. 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.
- \; m3 W( x1 G& SThe staff must be able to:
3 T+ e$ p1 H0 [, x: G Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
! y" t8 z! v# P1. 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.' Q3 {: [, W% H/ ]; D: R1 n7 E3 `
 The interface should provide a menu so that the staff can:' Q2 W8 {7 Z. y+ F8 F: i$ n
a) Enter the names of the two Java program files to be compared
5 }6 `: I7 T& x" p+ T( E) I# B) P For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
$ }; ?/ v6 |( J$ O: c** 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).
7 a- e8 b8 Y6 l; o, ^$ W* T+ c) |BSA104 Business Programming – 2007: Assignment 2/ n* X+ R4 t$ q, j  @2 J
Page 2 of 5
+ z" I9 r6 m5 ?: I1 m  Ob) Print out to the screen all the lines of code that are the same
. Q1 s/ S4 H( Q8 |( i Include the name of the file and the line number of the code being printed for each of the two files8 I- }9 i9 C$ J4 N' V. Y0 V) `
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
; j. E6 \( `( s6 u7 u0 N  \ the name, username and department of the user. `/ f5 U5 e* T$ T9 p
 the statistics of the comparison/ N+ t8 w& M8 Z" N2 k0 j
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different2 J% P4 N  b! @: ?% k3 F- \3 e
 the recommendation for further checking  `  w* i# S- p( X7 Y" T/ u
- 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
. \. d/ H+ f$ _. E* E4 Q% B" ]; C. } the names of the two files compared: \* |% R& q4 @9 z& Y
d) Leave the program (exit)7 Y6 X- _, l4 K9 M
The ProgramCompare class: (Total maximum 20 marks available)
" l- c/ x7 j% w2. 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)  J0 e/ W5 ]* c9 `% |& a
a) provide an error message if the files are not found or there is a problem opening them3 R4 b2 B/ r+ p, L* _
b) compare each line of code# y( B/ e% D! w: K3 W
c) print out the lines that are the same/ ^9 }0 x( P" A, L8 E
d) count the number of lines compared / lines the same( t9 ]9 g& g6 Q; M
The AuthorisedUsers class: (Total maximum 20 marks available)
4 W/ s) m1 h% E( L5 F3. 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)
4 F) A; T$ D* ?& ^, o. Y4. Provide methods to:
( J( m/ u0 `) J0 w8 ?5 T2 ]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
2 e: r$ B: e% z3 B2 ab) return the name of the authorised user
7 i, T7 A8 P. A: Ec) return the name of the department of the authorised user  V! i0 k  X9 A9 p8 r- r6 }& m! ?
Individual Data (Maximum 20 marks available)" Q1 A5 T2 K8 m/ y
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.; N! C  X4 _! N& l& X
Documentation (Maximum 10 marks available)1 Z; g% `' s% z! D
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.
6 O& g6 C; u" F7 }( e. M& [BSA104 Business Programming – 2007: Assignment 2. k% k, J. z2 v9 [# y- i
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
# b2 t' Q& j7 l' P/ z) ^* l不过你要翻JAVA的类库说明。你有下载没有?- u; [* G  [6 ~$ W! P9 F
查询关于对比的函数。貌似关键字是contrast,还有compare* V7 o! W2 U3 @) P6 O' k. n
- A; }) g( R* w# z7 J2 F' s/ ]
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -7 v9 j' a. n. d" K0 ], g0 T* u
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
. w) g0 v/ k' d; W9 T5 `可以下载到的 是 jdk-1_X_0-doc
/ F" X- g& H9 \+ a0 d9 y
7 @" [% }) ~) a[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-3 02:39

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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