找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1066|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 E- A/ z! e0 `8 ~4 u) n4 T & J/ d4 B! e4 H! o' S2 F
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
- O- A: c+ r2 l& O6 ?//  ProgramCompare.java         Provided by: DRS
0 Y( p- R! T7 N0 K) e//0 R0 P$ d4 n# C/ L
//  Program shell for Assignment 29 w- j2 L( N3 [
//
3 K. K! ]5 x; i, \% S2 O, {1 o( g//  Compares two text files line by line" H' k# g3 _7 E
//*********************************************************************
; Q7 ~  o) [8 o! ?& r
7 |5 w( I& {% e' ]6 u# l0 i$ T, dimport java.io.*;- Q# @# H# ^. B8 `6 a% `* ^
8 t) S: b( X: [$ ]3 @, C
public class ProgramCompare
+ ~& b$ l# t6 O{6 I) ^  I9 w- F8 \& Z  Y
        //-----------------------------------------------------------------
* ]: C8 n) S( x2 ~        // Constructor
9 \( ^. _- n. `9 T" T' T7 ?# h1 W        //-----------------------------------------------------------------
6 @2 D+ f/ G, B* L( k3 z6 F! ?5 B        public ProgramCompare()2 Y' A" C, }% _$ }. ?* g
        {+ Y6 e1 `1 I* t: B. |
        }
* ], y% }3 `4 |2 w1 m/ h) a) P
6 i1 L! {. I7 b        //-----------------------------------------------------------------
5 d. T  O, q2 N/ |8 c        // Method for testing that class has been reached/ G* i  ?1 G9 }4 R& o
        //-----------------------------------------------------------------       
- A( c- d# [; d+ H8 S% m' Y
5 N* m  J( ~3 f0 @; z        public boolean ProgramCompareReached()         ( K+ i! \9 y* A: m
        {* X$ A6 K$ i* Q& K- A9 @& N) `
      try . U/ P0 D$ N& J/ i# y3 x
   {        
4 i8 x2 U# _% c2 H! p; S# x                       
5 U4 K2 M" p# n, ]5 |$ W, `                //********************************************************************' ?3 X( v( x  k/ N6 }) y
                // Try-Catch Statement is used to handle exceptions - such as file not found / L) y) E. Z5 e% Q4 {$ B+ C2 N
                // Reading the files will need to be placed inside a Try-Catch - just like this one!( h+ `) X2 _9 n0 R
                // For more information see page 534 of the textbook
- G' s9 @9 f" H                //********************************************************************
& H0 K) W+ m  G$ r, ]) f, N                    
/ g( e# [8 X4 r# c9 r* }        }$ p/ r% j4 ?, b6 R! `) L) C& I
             catch (Exception ex) // Exception caught here and message displayed to the screen 0 {, N8 y; M+ l2 F3 x$ [9 w) v4 _
          {
/ J/ C3 e5 Q2 S. N/ |' |# _                    ex.printStackTrace (System.err);2 o0 c+ [8 M1 d7 U$ y" \2 d
           System.out.println ("Error message goes here"); // Replace this error message with your own         
. _5 F: ?, t# J; ^3 x( x        }
8 |' P% M! m7 t/ s2 g                return true;
2 }& W+ m" Y' i2 R& \9 |% J: Z        }3 b: `, C6 N& I

. b  P" q$ b8 t: {% k; w} // end of class ProgramCompare
' _3 l( B. G0 d5 d3 @2 {8 s6 O. |" r
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************9 n! c9 {( Y3 A  `; H+ u, x
//  ProgramCompareMenu.java    Provided by: DRS
" ]9 N5 `/ L% m! F) n! \9 z//
( ]' j. _0 p- `0 ^, P//  Calls AuthorisedUsers.java and ProgramCompare.java0 ]* [# O. N! f! R# D4 S0 l
//
0 ^# N5 @" x' m. T  v( \//  Driver shell for Assignment 2.
$ I) R7 J$ `8 f//********************************************************************
1 ^" S7 p3 q( S9 k; R1 s. ^: `8 V* {% D
class ProgramCompareMenu
. r4 g( h( v9 F) Q" b: s- ?/ M) O{3 ^6 j2 e7 u% J* C* h
    public static void main (String[] args)
8 R5 [6 s/ X- p$ T            {/ o) v7 H" O( B/ P" @
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
: x- I$ \6 @$ n8 q# ]$ D                ProgramCompare reached1 = new ProgramCompare();
4 J4 W* i0 |% k0 @* l& F7 @0 l1 ^                AuthorisedUsers reached2 = new AuthorisedUsers();        7 Z3 b. T+ q' u$ W* b' I; a- Q# J% I
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());7 r0 r; j1 k1 e# e( E- n; a" {9 _
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ! ^+ Q4 V+ Z. J- I# a8 \! i* D
        }, N9 t( y0 @) _2 o3 \. o
}// end of class ProgramCompareMenu$ @4 m* m- J, C3 V

: I: p% r& L) P* Q9 C+ o4 b/ p//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************+ K( }0 ^$ Q0 j0 [$ ~% Q7 W
//          AuthorisedUsers.java          Provided by: DRS% n: o. h& n% Y; y' q% {0 l# e
//               
5 H4 G* k6 y, r! _; Q1 i5 y- S//         Program shell for Assignment 2
1 X4 T/ s3 T' P3 Q8 n//' L* N0 g0 w/ M- X4 h. f
//         Represents facts about an AuthorisedUser! r5 J4 B7 M5 ^; D# J7 z1 _9 e3 W
//********************************************************************
  }5 R% D% _2 f6 K5 m  H9 S& Z4 k/ ?( y% @
public class AuthorisedUsers
4 w3 c* {$ k  \7 Y    {
! t2 a, N% j" b9 d& f7 X$ F9 X2 B4 {  |8 f
        //-----------------------------------------------------------------
0 x" b; V. c7 E; Z  @        // Constructor! a3 S" X: G: G9 S5 _
        //-----------------------------------------------------------------# W  q1 l- D; V' K0 F/ F" ~. Z4 Y

& L0 B9 b  G  Y1 S        public AuthorisedUsers()) e0 S3 o: |; E2 B5 K9 N% }
                {" u9 s1 P% e8 R7 H6 F) o
                }
% B& ]2 _, Z+ ?* p' O8 f9 A6 c/ C8 Z3 \# k" v7 Q+ L
        //-----------------------------------------------------------------2 s+ x  U/ i, G1 Y- I
        // Method for testing that class has been reached1 i" Y0 w  Q* }& Z, b: v9 Z4 I  Z: ?
        //-----------------------------------------------------------------       
6 `) i* [2 m8 s        public boolean AuthorisedUsersReached()
6 {  m  k( h, \8 F  B3 C' G: L+ r. r                {
/ B  G3 J5 I+ s, P% E5 ^2 a- v5 C                        return true;                        6 ^% ]& F% q. ?1 v
                }
/ D$ u  N- Z2 d; v9 s                4 b( `0 h2 V) q
    } // end of class AuthorisedUsers+ H- B  p% y( f& i& E, J
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
( u8 X# I1 z: e+ U, qShanghai - 2007
  T; y" V: ]. T/ }: N% U/ zAssignment 2, S* ~. B. I# [8 p
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), v3 F9 X" G3 ?. O7 g
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.
' H" n9 h, B5 G9 MThe staff must be able to:
# a) c  K1 \4 |6 x4 s Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
6 s5 R" S9 T; S/ p/ p4 |' B8 ~# V+ m1. 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.4 L" E& \; K) |/ ^4 `; i  L# f
 The interface should provide a menu so that the staff can:9 B% O& l4 X! Z! ^
a) Enter the names of the two Java program files to be compared
) ^/ O& C2 x% T$ e For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
. W& ^3 I7 \; x. u$ 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).* n" O1 |/ R& a- E& d3 h
BSA104 Business Programming – 2007: Assignment 2
+ g0 S( \. S: E0 mPage 2 of 5' N! M) f* N# H8 t+ t' [: d3 Q
b) Print out to the screen all the lines of code that are the same
3 J  D8 i; |* D$ C% Z Include the name of the file and the line number of the code being printed for each of the two files
. V5 Z- R/ y& Y6 w. \c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared& c& k" r; V7 t) n1 |
 the name, username and department of the user
9 _- S. }) A! c  | the statistics of the comparison
1 s# U4 t' @# f4 n- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different7 \8 Q9 K9 U5 C  y8 a0 X
 the recommendation for further checking  T2 G! A' ?8 t4 y: m
- 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" e1 e; J  Q  R9 N% t, l
 the names of the two files compared$ t, Y% T; P% Y1 }
d) Leave the program (exit)
9 P9 ~2 p& Y6 p! D. gThe ProgramCompare class: (Total maximum 20 marks available)
5 ^4 \. T4 j% F6 K6 n" ?( e- V( [4 F2. 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 e; a: Q6 l, @. l$ h
a) provide an error message if the files are not found or there is a problem opening them
: Q1 Z; ?4 P2 b1 y. m* Q! c$ jb) compare each line of code
: C" e: V6 E# m4 J4 gc) print out the lines that are the same3 D. ^# j) t% t8 p: H
d) count the number of lines compared / lines the same$ d( C. L: j8 p! @# V
The AuthorisedUsers class: (Total maximum 20 marks available)
$ j7 F; F( W. C! 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)
. @, U! z0 v+ z2 J; q/ m4. Provide methods to:1 G' h9 ]  `$ }6 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: q4 H7 n: c. J8 P, d/ f
b) return the name of the authorised user
% `7 Y* T6 H9 L. Qc) return the name of the department of the authorised user( |0 w) m7 p2 c# u
Individual Data (Maximum 20 marks available)
; J& Q: w& ?3 u' }  M) 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.$ f' l9 e9 e' v, \
Documentation (Maximum 10 marks available)  }9 d' s1 f7 w! ]' L
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.
+ ~7 a2 G2 K, x$ cBSA104 Business Programming – 2007: Assignment 26 C- L5 w- j, ^' V- r% s
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了- _. {0 V" S: H9 u  W
不过你要翻JAVA的类库说明。你有下载没有?* V- v$ @# T; D: C3 W+ D  h
查询关于对比的函数。貌似关键字是contrast,还有compare1 B3 I+ {$ Y, S. m
( r: o. a3 I) `! O' i1 h, g
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -7 @! i* S- X! ]% B+ q% Z2 U
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。. n0 P9 F( Y  Z  R! R% r! C
可以下载到的 是 jdk-1_X_0-doc
6 }4 y8 a& x$ g8 `" Q, `. _: T
1 ^1 f/ e* G2 Z[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-19 16:33

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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