找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1193|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 4 v* ~ s+ c9 T! r0 V4 Y( ^' r L8 r# \/ G- m6 L1 [; f& z) 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 | 显示全部楼层
//*********************************************************************
' i8 |5 y! K" C) `! Q( S' ^* x//  ProgramCompare.java         Provided by: DRS8 l+ a) V- Y! N2 I' O( D
//
# r, Y" X2 Z- m1 w5 v' S//  Program shell for Assignment 2
9 I' r" A4 {( A. h; \+ k+ ]# G, j//
; _# x( H1 n1 \//  Compares two text files line by line
$ G- t. E: d& Z. r$ x! Z//*********************************************************************
# d8 @) e3 x  N/ J7 ^, q0 x& m& @
( X1 l  M+ ^/ W( J1 rimport java.io.*;7 }+ \% G$ h5 A! ~8 z
. J4 }& _+ M0 Y1 @
public class ProgramCompare
+ h" C; U2 `, k# Z; i{, ?, z8 ?+ R" k+ T$ B+ k3 V* F; y) v
        //-----------------------------------------------------------------) H; p* d3 [8 }3 o4 r
        // Constructor
0 U, O7 y/ U- j$ O; R        //-----------------------------------------------------------------: `# E) ^! q8 M+ g2 X1 c
        public ProgramCompare()+ K9 @+ A, x* e( U( `1 D% s) i3 W
        {# M7 |! Z2 P( D, y$ ?* m9 _0 z
        }+ h7 e1 ~, C: N- r
' i% q; p1 `! I7 S
        //-----------------------------------------------------------------
" Q6 u6 y. }6 O        // Method for testing that class has been reached
1 g' {$ \) G2 J  D% e        //-----------------------------------------------------------------        $ [2 Y* M7 L6 j6 u6 |, n2 O

9 `8 _+ n7 z- z( Q) \* ?5 n, A3 m2 p        public boolean ProgramCompareReached()         - G. Y1 |! S+ _' u
        {1 N# C" M6 x* P1 L
      try
9 m; n) i# q/ q# B5 ~7 ]+ y   {        
6 _2 a) p: y5 l                        - h! A  I! g' _( Q2 w
                //********************************************************************
2 Q7 S  M/ l; _; j4 N                // Try-Catch Statement is used to handle exceptions - such as file not found
% g" T3 s) E9 _; V3 q6 P6 \# p: E5 g) ?                // Reading the files will need to be placed inside a Try-Catch - just like this one!
! z8 F0 o* h4 K8 l                // For more information see page 534 of the textbook; Q$ f0 U# ?, m$ U
                //********************************************************************% u' V9 h  S, J
                     3 z) h6 Z5 ]8 d
        }2 x# f7 I9 C# u  ~8 T  o
             catch (Exception ex) // Exception caught here and message displayed to the screen 0 f9 E! j- _% ~4 E$ e& A
          {
" F! p+ h0 u' ^2 `# P; z$ i" G                    ex.printStackTrace (System.err);: ]: l/ o& [, o* R- ?+ H3 ~
           System.out.println ("Error message goes here"); // Replace this error message with your own         
( |# t* W( q3 I6 K& f        }2 c3 C7 g& ~* L3 Z/ S1 E5 Q
                return true;
7 Y$ s6 w! y6 E        }- V; k, o& r& |# q  n( e" l/ t
' |7 {& R: v, a
} // end of class ProgramCompare
+ A3 x3 ?$ C8 I$ E6 P2 k1 q# N. V
: j6 i2 J0 a/ T7 r' F1 V* X1 ^//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
* ]. \6 @2 ~0 w//  ProgramCompareMenu.java    Provided by: DRS: [" A: C, Z( H
//
% Y, R. F; ~3 w* B$ H+ t8 c//  Calls AuthorisedUsers.java and ProgramCompare.java
' g) V( T# T* ~/ q2 I3 {! q//
+ q) @" x2 V7 ^. u, i( t; K# Y//  Driver shell for Assignment 2.
( s3 d1 {4 K; V9 i% R4 v% G//********************************************************************
% L* k' Y5 x- ~4 r. g4 x( K) i0 X" l
class ProgramCompareMenu/ R! X* u( e. r5 q: h" \' z0 H
{
: n8 [1 u5 k  m/ T( O2 G2 a( ?% H    public static void main (String[] args)0 S. z; r8 t6 K# }6 X; t# i8 x
            {5 [. n2 J; X; C9 v
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable4 J5 [. X+ m" U9 ], }9 ^
                ProgramCompare reached1 = new ProgramCompare();
  }8 |% g" j9 q( F* Z# M6 F                AuthorisedUsers reached2 = new AuthorisedUsers();       
5 f  L: F& R# z. ^; y- ^                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
. m) b. }/ V' _  @                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
" k. S7 e: y. b0 Y% D* X2 R        }
" F- o) p5 }% P, w}// end of class ProgramCompareMenu
5 c8 `# b( M% \+ d: V- }( A7 H7 h: u  f$ S- U) _
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
9 g1 T  I0 f' d4 y) ^& A0 ?8 H/ W//          AuthorisedUsers.java          Provided by: DRS
  j$ A! t& x& y; o//                3 [. p, i1 |( @4 P
//         Program shell for Assignment 2
0 ^9 Y3 Q: \* {8 p2 P//. M# c' n! ~' y+ J1 J% L
//         Represents facts about an AuthorisedUser
: i/ |! E- ]# j) F0 Q& J//********************************************************************, V+ y0 ^2 W9 r( U& ?! C% i
" [& a1 ]0 N6 @1 ]1 \. r, j
public class AuthorisedUsers
6 `: W& w# z0 X6 Z    {
9 J3 l: d; G0 T- P# m. a+ o( W& j9 i6 V
        //-----------------------------------------------------------------
  R9 y4 D/ A- e8 n  L        // Constructor' L/ ^' G$ e- p: }$ w
        //-----------------------------------------------------------------
/ l0 i1 b  T% u' k' H: L; s/ T5 g1 H4 p. J9 P* t$ g
        public AuthorisedUsers()
4 o8 y0 K2 \* E+ ^& t$ _, @                {% P& U) T% z0 K7 j
                }
% j! {( Y7 o4 v7 r- P5 ^0 }6 {% ^3 }/ g3 ~- o) r
        //-----------------------------------------------------------------$ A1 V" k- y3 u4 P$ e, S
        // Method for testing that class has been reached
4 _4 _4 ~; F1 B9 A( ~( R        //-----------------------------------------------------------------       
+ C6 [" V+ u# @        public boolean AuthorisedUsersReached()3 W- ]0 F0 `& f: _2 B( O2 p
                {  O5 }7 S# K. ^
                        return true;                       
" @8 c" `& v, Y9 O                }
9 p7 @; Z" {8 C/ |$ @- q                3 ~0 \- c/ ]  I  j# Y1 @
    } // end of class AuthorisedUsers
4 |* n" g  p- s5 s) a//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming+ d2 J/ X1 {, ~6 C
Shanghai - 2007) X& R: l$ W, v5 F* I, ~2 c& ^
Assignment 25 T9 Q: }  E6 I
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)0 V6 }; `0 N% F3 X6 D% I# u$ D
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.! m: J5 j4 N0 |/ h3 z3 D
The staff must be able to:
& }4 _8 O! C, q1 y8 Z0 y% q Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
: a4 O+ X; H- I, F$ 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.
0 A: N9 G7 o) A5 m3 o* a% S; w The interface should provide a menu so that the staff can:
7 t' a3 v1 F" u) ]a) Enter the names of the two Java program files to be compared. p  m5 E3 b, V$ p6 b5 `
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
4 {5 k* a. J) _  ?) T$ H: \** 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).0 ^! F, b0 K$ E
BSA104 Business Programming – 2007: Assignment 2. F5 x, K3 N& F7 }; z/ z$ k6 U' K& k$ R
Page 2 of 5
' t8 A) F4 {( Db) Print out to the screen all the lines of code that are the same4 j: i$ V$ r) C0 E# @
 Include the name of the file and the line number of the code being printed for each of the two files# D+ |* u$ p$ j5 T% D; h
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared% U7 D% o. N. z) E" u2 e
 the name, username and department of the user
! c% a3 V/ c) \3 w- A( U  g+ o the statistics of the comparison
4 ?. r: u3 W& G& w- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
# U: d7 k4 _  c# l the recommendation for further checking: M2 ^# v1 T- k' a: o0 X
- 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
# ~+ J; [- f, v3 [ the names of the two files compared
: q) K0 v4 u1 m; u$ I% kd) Leave the program (exit)
. y) k/ j' w; k8 t, J* f; f! K+ ?6 EThe ProgramCompare class: (Total maximum 20 marks available)" V( I! e! Q9 t+ }" v. s2 h
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)
5 K6 L4 k# k/ T- d$ \, d2 }a) provide an error message if the files are not found or there is a problem opening them
1 C1 c  s! v7 Q. _3 {7 Sb) compare each line of code6 O( r1 Z/ F; C* R4 U+ V; \
c) print out the lines that are the same6 G( m7 Z" G- t7 ]3 U$ y& I
d) count the number of lines compared / lines the same( H) F+ ?0 ^5 k$ C. s
The AuthorisedUsers class: (Total maximum 20 marks available)
; d, j) ^- R2 J! k4 f0 }: W3. 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)8 e3 i1 u: D% [% @
4. Provide methods to:
4 i: k( c0 g6 o, Y: B  `5 Pa) 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
# K& V1 Y+ ]- c* z" mb) return the name of the authorised user
' D* b1 J* u& |% _( mc) return the name of the department of the authorised user( U: Z. M* C5 C7 g, \1 ]7 W) j
Individual Data (Maximum 20 marks available)4 T8 G( y2 M, ~1 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.4 f5 d4 w7 E% M( n
Documentation (Maximum 10 marks available)/ w$ `5 P5 Y0 n1 R. 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.+ T  a. ^6 _$ n2 k4 [2 Q- d
BSA104 Business Programming – 2007: Assignment 28 [6 @8 X$ ^$ ^
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了9 x% U9 u# L" V# ?! A8 V( F
不过你要翻JAVA的类库说明。你有下载没有?! |# o3 K( P- o1 l% n' k# g
查询关于对比的函数。貌似关键字是contrast,还有compare
$ e. U7 ]3 @6 @; K! p1 e2 s  z5 `$ U, Z& g' U! F
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
2 r' m6 P: C; s( I# k痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。+ A- ?: \- j/ e
可以下载到的 是 jdk-1_X_0-doc
5 \& `0 i9 y+ ]- z! W7 x: Q; T. a" p# i; z7 l+ C
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-13 04:40

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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