找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1420|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 8 s) b' b+ {9 ~- m. U/ u0 A- v5 u+ t9 a9 a5 r& t+ X" N# h
回复

使用道具 举报

 楼主| 发表于 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 l8 v) T3 ^* D8 F! M8 u$ p. n2 d1 N$ Y//  ProgramCompare.java         Provided by: DRS3 _0 q1 M6 G6 C2 n7 c( Z/ E1 f
//
8 ^( A& P9 M( O0 u//  Program shell for Assignment 2
4 i- H! y& {9 t! T+ C/ m% B//
. J! G4 O9 O3 `//  Compares two text files line by line
( g: O1 x6 m) T4 d//*********************************************************************! a: E% J- }. l+ _/ A* t
* W- ~! M( {9 A4 V/ X
import java.io.*;7 g6 G: P2 h) q

7 Z4 L1 g9 ]& M$ J/ jpublic class ProgramCompare
) O& f! S6 D: g1 I0 w0 f* ?{! j5 z- o) d7 B9 {  z% H, E
        //-----------------------------------------------------------------5 v' P5 ~. Y) [/ }, S
        // Constructor3 h6 y2 B/ z: r2 i8 v
        //-----------------------------------------------------------------$ x- D* u& l8 u% m. {. x
        public ProgramCompare()
. f  w& @' c- p3 k4 [: |1 G: o        {- b/ e8 N* v, C# P* U: G& _
        }4 `; }* J; A+ w
: o" X& O" D9 \! h$ H, J% w
        //-----------------------------------------------------------------/ ^+ F, r+ T& M
        // Method for testing that class has been reached
( B: f" U# Z: ]4 X9 x        //-----------------------------------------------------------------       
0 x0 A8 H2 Z4 Q) ]1 O4 J1 i) s* i) H( i7 g/ w  f
        public boolean ProgramCompareReached()         9 ^3 i! q" r! B6 |' D( s5 e
        {, A* ?9 L3 m! {7 m. N2 z* P
      try
1 z- ]! H' h6 C! l" }   {        
7 N# S- b  c' y" c! p# u                        % P  R0 A$ h. c: B) C5 v- {
                //********************************************************************
" ?- h; }/ s; u3 G; d# }. `+ d                // Try-Catch Statement is used to handle exceptions - such as file not found % r- V! Q5 d" n# i8 l- E7 n  W
                // Reading the files will need to be placed inside a Try-Catch - just like this one!" f$ C! L2 z- Q* R; a# j
                // For more information see page 534 of the textbook
" r1 ~4 T3 L' e0 f- }+ \                //********************************************************************+ \* ~: V3 \1 i. `
                    
3 o* y! v+ O" f7 d* |        }
* |7 D2 @! Q  e7 z8 ~2 x' ~             catch (Exception ex) // Exception caught here and message displayed to the screen
$ u8 x( [* R" W4 c% \' G9 L( R0 m          {
2 k, h+ ^- U7 X5 y7 {8 H7 ?) F                    ex.printStackTrace (System.err);, R6 ^+ ^. N+ Y
           System.out.println ("Error message goes here"); // Replace this error message with your own          3 J2 S- O1 g! F$ W/ |- w
        }
( m# _0 @- n0 F4 C; H                return true;
% u5 H  n4 e$ N; N6 l! F        }
1 v7 c1 T  C* Y& n
! ]8 n8 j% K; j0 c1 N3 n  U} // end of class ProgramCompare
4 S# [5 N7 _& R6 P  [% C. U3 f, t2 _" D/ P
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
4 Z+ ?: V) ~) Q& o//  ProgramCompareMenu.java    Provided by: DRS8 q+ W! x/ }, o5 t3 ?
//
/ o  ^& v7 x, G, g% P% j//  Calls AuthorisedUsers.java and ProgramCompare.java
1 G  F1 ]6 }1 N% z//$ H& G* z2 F, Y; [  @6 B. f! I
//  Driver shell for Assignment 2.; h+ S  d9 f8 j$ W6 ?5 S: g9 _
//********************************************************************5 h4 D7 j& o- e
3 R6 u- z  r! R# H( d/ N% O
class ProgramCompareMenu, q- b; C1 `% N$ D- D4 z
{
% K* v* I- ?; Q    public static void main (String[] args)" y2 l% S$ @' T- S
            {" K8 O5 D! A4 Z+ O  s4 N8 X" {
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
; j( D/ ?/ p) z( r                ProgramCompare reached1 = new ProgramCompare(); 4 `2 c1 A) J, \1 m9 C3 B9 b% u4 v7 I) }
                AuthorisedUsers reached2 = new AuthorisedUsers();       
9 u6 [  d- f9 O1 k) Q                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());& ~. i& Y' V! _* I4 x
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        / |7 u. t& T. g8 c0 t! W4 \, t
        }4 K0 f1 k3 o% _- ]$ g. G
}// end of class ProgramCompareMenu- z0 o0 F. A. J* W, [

' {9 B4 w, l; \1 f0 z/ {//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
# s# c0 \' u- e1 [* i2 ]4 ?//          AuthorisedUsers.java          Provided by: DRS+ M4 h$ [7 \" b. Q( d7 D
//               
# c. a( Y6 f) z# _4 F+ r//         Program shell for Assignment 2# {' K1 `; z/ E7 {
//
: L4 ^. E$ y7 K3 B- S, b; ]//         Represents facts about an AuthorisedUser
, ]+ @9 I: c6 x9 _) S2 _0 ?0 W//********************************************************************6 d6 N  e, {0 V, c

' t/ z# u5 m. d$ q( fpublic class AuthorisedUsers2 w7 T. t$ A" z% z. J
    {
  w! g5 q  c- {- @9 J
# Z: Y3 S* m" ~* V        //-----------------------------------------------------------------) ?& k- h/ [5 K& Y
        // Constructor
. \4 g( M; }" j7 K        //-----------------------------------------------------------------0 l, V' Q; J$ g6 B& q8 }
, c. l2 K- d% W" a# c& ?5 I4 W
        public AuthorisedUsers()# S  `; C) R3 _1 K; f
                {% m1 T1 k+ d* d1 y+ S. c+ ?
                }
3 q) N6 U# j' Y8 |7 r6 b0 g
# m- }% {+ \" }        //-----------------------------------------------------------------% t/ T3 e- t) r0 f- `0 f& E. ~
        // Method for testing that class has been reached
4 Q) t" e9 X# @- C        //-----------------------------------------------------------------        4 T0 `. r3 k9 A& A. E1 L
        public boolean AuthorisedUsersReached()) g- A# \$ o$ J) U. P
                {
9 U! k8 `8 n+ Z7 k+ s                        return true;                       
2 a% i3 R  P, F2 [/ C) f4 Q3 i                }7 |2 ]( l# n9 S5 m
               
: e' {; B& L- b3 p    } // end of class AuthorisedUsers
% P( @. ]* a: ]& }# R//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
3 n! m' g& Q$ z6 Z1 \) q0 lShanghai - 2007
# P7 m& t9 p1 S' K. A) bAssignment 2
  Q: t  j! v: d3 l, m$ \8 gDeadline 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)8 G' T# }1 W; O+ i* ?
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.
4 p' |6 l: s, `# ~/ KThe staff must be able to:
+ {5 D: t+ N' y5 [. F5 @ Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.; L9 i: n$ X" T2 j1 \5 ^
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.
0 v2 v$ g2 c) E/ A% G$ {( ] The interface should provide a menu so that the staff can:2 s; v  l4 ?* p( ?. I7 y
a) Enter the names of the two Java program files to be compared$ K5 g2 ^1 |" N* v
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.7 B; s1 [: U( M: a
** 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).
4 X" T2 i. N( P- wBSA104 Business Programming – 2007: Assignment 2
6 Z# Y8 O) d5 B' |  @Page 2 of 5
4 |, [: M0 V7 L. k7 \b) Print out to the screen all the lines of code that are the same
  x- x0 u/ O7 |$ |- o# U Include the name of the file and the line number of the code being printed for each of the two files
# T& i3 X$ ^$ p  @. ^+ i1 Y4 {+ _c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
2 f5 o) O+ z) x3 @% W. T the name, username and department of the user0 z$ W, o9 w8 L, \: U. t) C% o4 [) @
 the statistics of the comparison
* [4 u. @/ C% y( W/ ~+ e  C: J- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
$ A6 m* J/ f( `% A6 V  F the recommendation for further checking8 l9 @6 x$ e; K2 `0 j! u1 A6 _7 y
- 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, {1 ?* c( n; R0 j+ d$ j
 the names of the two files compared
2 N8 n8 d$ M2 Q% Y: l8 sd) Leave the program (exit)
  D) |' U) ?4 v" KThe ProgramCompare class: (Total maximum 20 marks available)- _4 ~7 C" ?/ f1 U
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)
" R4 Y& u, I0 D# g8 N7 Ba) provide an error message if the files are not found or there is a problem opening them
# p/ `7 F( z" c$ c- n9 J# ^b) compare each line of code
5 Z5 T% w4 u9 Z* @' Mc) print out the lines that are the same! M  e8 t1 U. a" A0 j
d) count the number of lines compared / lines the same& p7 y" x$ Z$ a; ]8 |
The AuthorisedUsers class: (Total maximum 20 marks available)
2 m. ~" i5 y! S4 S2 [2 c3. 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)
& Z3 X; s& Q9 ?; T! H6 a4. Provide methods to:
# W! I( v+ o* k1 n: |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 b: e5 n5 b# r9 T0 x" z9 }b) return the name of the authorised user
; t) C$ ~# Y9 D1 a" G9 @c) return the name of the department of the authorised user
; U: {6 V+ i: l" g/ \Individual Data (Maximum 20 marks available)
: z" G9 A; P" v* t3 e3 T% e  z5. 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.; K  ]  f& {, b8 A+ f
Documentation (Maximum 10 marks available): w$ @% U. j  n3 X! u, p8 X
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.
/ e) V* L6 w  `BSA104 Business Programming – 2007: Assignment 2
6 I: z; b  c( pPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了& r* ~9 H: a- T' [5 t
不过你要翻JAVA的类库说明。你有下载没有?
4 ?; v- ~  R# o! U查询关于对比的函数。貌似关键字是contrast,还有compare
% W. B" L! \( T+ ]6 d* ]- G* x3 ?
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
) @7 e6 J3 P4 R8 d3 Q% M8 O3 g痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
* x% s% ~9 u0 k9 M0 |: Y5 a可以下载到的 是 jdk-1_X_0-doc
$ m# R) {9 `. T2 b) L8 c+ Y
( ?* l& o5 }/ M0 I8 @[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-28 04:07

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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