找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1629|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急+ i1 d, `# }: U. H9 j! ?$ v1 L " |# s& S/ W7 ^! v/ A" |) b5 Y- A
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//********************************************************************** H$ _7 E% r' w  k( ^- \
//  ProgramCompare.java         Provided by: DRS5 P% t$ P$ j0 d/ k+ i9 b- U
//
1 ~3 z+ k3 f2 r//  Program shell for Assignment 2" I7 i; v. u' {# A5 K! K
//
4 z! K* K8 }1 G//  Compares two text files line by line2 `% c. L2 R* K! A, I$ b! J
//*********************************************************************+ w' B# M# j& H& C) L: c

7 ^# d3 g. E5 H, T# _, K2 s! timport java.io.*;) N! k4 z) j- w3 S8 t  G
5 _8 Y5 L% n1 h1 L  D# }
public class ProgramCompare, x2 J* v1 @5 j+ |2 i% x& N2 u( Q  N
{+ c# \2 X; L+ t1 X; W
        //-----------------------------------------------------------------2 @  m- u/ ^( H  C. J5 U9 r
        // Constructor
3 e' X/ }4 V* ]! l+ @! s/ j        //-----------------------------------------------------------------
% `+ v/ ], `8 M2 T* ^5 Z        public ProgramCompare()
3 b" z) z5 P" ~  X9 _) g7 Z/ I. v        {5 T, Z& Z+ g& Q( }6 b8 W0 r4 N
        }
! I7 K+ }0 }0 m5 R! R0 b; w. @# {& V9 M! r7 |
        //-----------------------------------------------------------------
& b) R% N% x( T, @$ s& Q        // Method for testing that class has been reached  M: Y' F7 n5 d% G' H) T
        //-----------------------------------------------------------------        2 P0 i1 S9 q3 s

( h( I$ h$ `1 X+ g2 j        public boolean ProgramCompareReached()        
4 ?" ~" R2 {" [4 ]: D8 s        {
1 f4 W- o& v; V& N* |/ L6 j0 w- I% L1 s      try
% ?2 @" j# J, E1 r) a   {         / j7 w! P# I$ T4 m0 ]& X0 ^* X
                        8 t/ D9 V$ s, P7 H
                //********************************************************************
5 K/ c6 _  Y! i                // Try-Catch Statement is used to handle exceptions - such as file not found 8 v9 d0 F+ h& R* `9 L9 J! Y
                // Reading the files will need to be placed inside a Try-Catch - just like this one!$ |4 w0 X" P  t$ K6 i1 R) k6 s$ i5 W  {
                // For more information see page 534 of the textbook
. Z0 N7 t, t5 G9 ?$ ]                //********************************************************************
6 }+ n5 A7 E( A! J                     9 C. @. L5 K+ n0 w1 A4 h  E8 S4 s
        }
$ x7 ?! @7 l/ _             catch (Exception ex) // Exception caught here and message displayed to the screen + v8 y, A6 l: y- e( K8 ?$ t$ R& Z9 W
          {
6 i. g( q: g/ @6 H$ ~3 h9 y                    ex.printStackTrace (System.err);- h  p+ D  [: o0 D$ d
           System.out.println ("Error message goes here"); // Replace this error message with your own          * ]  O0 a$ |  @# T7 b6 r
        }
# a0 I0 P/ z. m5 N                return true;
: T8 s9 {: o8 C2 C$ j8 c2 g" p3 R        }1 p' L/ h- g! n% B

; p, y8 y5 P. D- M0 s  }9 B} // end of class ProgramCompare  u* E9 _, b; k* ~" [4 U
5 J5 B, n3 z/ E2 B  B3 @
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************8 H, e) b- J- r1 S  G/ C, c
//  ProgramCompareMenu.java    Provided by: DRS/ z/ k! ~# _* G+ Z  s, |7 R& ?" C
//4 d5 _9 w+ W" m' n" Y5 Z+ @
//  Calls AuthorisedUsers.java and ProgramCompare.java* J2 F* z* |2 C7 n% J& B. t
//
1 H" x; [' P- Q//  Driver shell for Assignment 2.$ @! o! E: N& ~% b! z
//********************************************************************8 g! s7 e8 t0 C
+ V% G  e1 a0 S* D+ {
class ProgramCompareMenu4 d: i3 y( L$ D1 d% j
{0 F- [/ Y: g. q
    public static void main (String[] args)3 ^0 r- X$ c  z" R- b
            {
. i8 u; C9 l; J& E- X9 W                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable* s' C/ ?2 q4 \' J7 _
                ProgramCompare reached1 = new ProgramCompare(); 6 d: y3 w3 ^- g% O7 k' T
                AuthorisedUsers reached2 = new AuthorisedUsers();        & u# L8 O6 O% n1 k7 }, S* i+ s2 n- f
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
6 ^  J7 E/ F. g) j9 Y4 N                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        & L# e; Z' \1 m1 C
        }3 W% @9 _& {8 Z( F3 p+ C5 ^
}// end of class ProgramCompareMenu( G1 }0 z5 x3 {, G7 N
! t( t3 H% C* h  b9 N8 h0 @. e& @4 h
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
7 x& W2 v2 o) K% f; Y- S//          AuthorisedUsers.java          Provided by: DRS6 x. ^) ~6 Z$ p! g3 }
//               
4 |# O4 ^" ?% C//         Program shell for Assignment 23 m6 n3 }+ G. @
//6 r1 p8 c* t" z4 W/ L; D! \4 Y+ G
//         Represents facts about an AuthorisedUser' b' X, S- H& Q% a* d1 c- l' Q
//********************************************************************& j1 G& z8 Y0 t' H

1 F5 V2 C6 k' F7 A4 t( ~* h. Mpublic class AuthorisedUsers
- K+ @. S) j/ `3 U4 E    {
# L: f% Y8 m! l( d! a
3 j2 \2 k: |1 d% Z        //-----------------------------------------------------------------' c6 F  C+ E& B' e3 _0 M# }
        // Constructor; U! s# {! z( o
        //-----------------------------------------------------------------' J' Q% g+ e  }: A& a' I) Z
1 {; @& q& F9 p! R, h2 \
        public AuthorisedUsers(). @6 H4 V  F$ D% r- `) ~4 W' _" _9 j
                {% S$ j( r! [) j
                }1 X4 Y# h+ P2 C2 u
; L+ |. z; |3 e4 ]
        //-----------------------------------------------------------------
4 g5 H. M/ j- T: S* f        // Method for testing that class has been reached
) N3 Z: q8 B+ g$ ~/ @8 D# m        //-----------------------------------------------------------------       
$ \" f0 J: u: V! I        public boolean AuthorisedUsersReached()4 ^3 _& S* O- g0 K$ i
                {
+ Q4 ~4 E/ W  a" ^4 |                        return true;                       
+ b& y, l, S. q; b  `1 l# z6 r  w                }2 [" Q" @$ n) S, e
                2 o) W7 Y7 e9 q6 o. I
    } // end of class AuthorisedUsers
3 R) B* X8 l0 Z/ v, J//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
, Z7 v/ L* C) W! D" G6 oShanghai - 20070 x  ?, Y! G* e8 a6 w& `& P- }& a
Assignment 22 N, `9 ~( A* }" a( m: _' u8 D
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)
% ^. x4 y1 p2 c" g5 g6 D1. 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.5 A; `9 Y! E6 p# K7 `4 M* S
The staff must be able to:, A, V" X! u7 q* Q0 E$ s2 f  z
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.$ i4 o- E/ L' h+ K1 H
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.
6 N. p) g. t& }, t The interface should provide a menu so that the staff can:3 x/ R" w3 W- C; a3 U5 H
a) Enter the names of the two Java program files to be compared
8 K  e7 T) H1 f0 ~ For this assignment, it will be assumed that the two Java program files are in the same folder as your program.1 a6 ^4 n0 D$ a& O) X, i! Y" {
** 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).9 z- p" `/ H, g, n, |" W/ H
BSA104 Business Programming – 2007: Assignment 2
: w- |$ O5 O/ j% L9 [# aPage 2 of 5
# |' N7 K) w$ @* V& @1 T0 Nb) Print out to the screen all the lines of code that are the same
+ u4 O& _# ]& r7 i Include the name of the file and the line number of the code being printed for each of the two files
; e' `: l( e, v7 q0 W( kc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
4 w+ C$ s9 I2 x& [4 a+ c& u) g the name, username and department of the user6 m) A. h8 G1 H; I( ~0 q% b
 the statistics of the comparison
/ u1 g- X: }1 }3 n- H9 v- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
. }# Q4 G2 ]  Z/ k, g7 e% K the recommendation for further checking- S. _- k4 w% y: Z+ O6 F
- 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, b( }' S9 l# P/ f3 R
 the names of the two files compared& S* j) Z2 D1 D
d) Leave the program (exit)
! _4 ~/ E* j' @The ProgramCompare class: (Total maximum 20 marks available)' H, \1 O0 t* ]
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)
8 O8 k& j7 l* m( b- h* ]6 z2 La) provide an error message if the files are not found or there is a problem opening them
( Q8 K2 t2 L" M0 o4 e7 S6 fb) compare each line of code
3 M" H5 K1 W1 d' k$ {: o6 mc) print out the lines that are the same
, _3 t0 ~; O7 {  o) _) f  |. ?* [d) count the number of lines compared / lines the same
' @" N6 l4 O9 v+ bThe AuthorisedUsers class: (Total maximum 20 marks available)
* l6 O0 F' n0 m" M/ G& Y9 S3. 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 @3 _) Y  e! }# k2 s' X1 @
4. Provide methods to:5 O& |6 b+ y$ W" a! C/ p
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 v) T+ K( V6 i% _+ l9 m5 f' rb) return the name of the authorised user
5 i2 Q3 V" s5 S; y. J+ l( ^: z0 ac) return the name of the department of the authorised user+ R  Q7 I2 L) ?* i" y) D" d
Individual Data (Maximum 20 marks available)
5 W; }( ~: Z- R2 f9 P3 o/ J5. 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., M: q; W, U$ R7 K
Documentation (Maximum 10 marks available)6 s0 n3 W+ V* @! r" X% g% Q7 w
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.3 ]& l  O! i$ M* r6 L0 e
BSA104 Business Programming – 2007: Assignment 2' O3 H2 n$ h! i, u0 g* o
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了/ B$ N! J. j) p" o+ @/ W
不过你要翻JAVA的类库说明。你有下载没有?( n0 r# Y# i! E
查询关于对比的函数。貌似关键字是contrast,还有compare: @, P2 \: p# e

1 o9 i( |8 G4 H3 Q+ v8 \$ G[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
# H3 e- h$ t, u- h7 B痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
, Y  O$ z& ^2 S1 \+ \可以下载到的 是 jdk-1_X_0-doc+ o1 ~) \! O0 B( q7 |+ W4 O9 p2 g% S

% U3 n$ `& J1 ?1 _. ~# `7 H/ Y[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-15 06:47

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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