找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1560|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急) E/ w: S2 `7 k! j4 s ' O$ ?7 r( s/ \% h& q% l$ f2 u
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
7 y4 v! N( D' p8 Y//  ProgramCompare.java         Provided by: DRS1 z3 b# Y7 J  X  E$ r, R( V# u
//2 W' I3 c. D7 V+ Z' Q
//  Program shell for Assignment 2% Y8 i) R1 p$ Y) D) C* S8 k
//
: T: _; v, r$ V, z+ H- u/ l//  Compares two text files line by line
1 ~7 J2 J7 V% D: A9 l7 d( v" R//*********************************************************************7 U, @+ g7 Z0 a: Z

0 _& _3 @/ `. X4 {import java.io.*;  S2 ^# K7 P6 m- c0 S5 j
' `- Q1 y2 g- v* z$ E) {! {
public class ProgramCompare
* J7 L. \9 `6 [8 j; [{
( b5 B- f5 l) C5 Q4 r/ H        //-----------------------------------------------------------------
: U1 U. F/ e/ A' v1 c6 {: U        // Constructor9 z! @, ]2 X' v0 e1 f
        //-----------------------------------------------------------------( b" Q$ l+ m2 K& n
        public ProgramCompare(), h9 ]7 e4 Y& Q3 B
        {
* S; _1 A0 s( s( ]  _# m+ D  q        }* Z# h* ^/ O9 @: {! \9 i( ]; _
" X- e. p; s0 ~1 N7 ^3 U. ^
        //-----------------------------------------------------------------
9 j% R' C, Q4 X/ N+ j6 ^& k+ ?        // Method for testing that class has been reached
' w. C$ w' z/ ^4 q        //-----------------------------------------------------------------        " q4 B- f5 T  U* G
" ~, j  l7 I8 z
        public boolean ProgramCompareReached()         . k! v7 {$ Z% r/ f( k2 }8 s0 d
        {. w" o" @" B, A
      try
9 E9 c" c1 M/ S2 R* [# B   {         # F8 a; ~7 Q/ T) R
                        ( q0 v. Q% t" f% B
                //********************************************************************
2 {8 b) O, F. O2 f+ A  ~9 V/ M, r                // Try-Catch Statement is used to handle exceptions - such as file not found 8 b( T" S( u+ D0 \. z- C
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
9 @% b' B9 v: d8 j/ Z- o                // For more information see page 534 of the textbook3 @7 U) P4 z+ n
                //********************************************************************
! |" P8 Y% x4 J                     ; i9 r6 H) @. s& g
        }
& K7 t7 E1 u1 t# B0 ^. @             catch (Exception ex) // Exception caught here and message displayed to the screen 1 v& U) M. p! E0 u; N  @/ W
          {5 z# A2 D& C5 e8 ~
                    ex.printStackTrace (System.err);' N$ Q3 h- O" }: l* X) f$ c
           System.out.println ("Error message goes here"); // Replace this error message with your own          ' b5 L- X* Q" N2 n8 `# F
        }
0 \7 Y8 Z! g2 M1 E                return true;
& o/ j% d2 K# t4 \        }
9 k- @4 a2 e7 N5 W: Y# {
( h8 a/ e% J  e8 N" F. K. x2 [} // end of class ProgramCompare1 {/ n: E: R. x

# K; V! Q% T5 a% z  x& M//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************- \3 u2 U, `% n( _
//  ProgramCompareMenu.java    Provided by: DRS/ M. {8 T, Q7 }6 U7 u% K; [* B
//
- y  b; {& x  n7 C//  Calls AuthorisedUsers.java and ProgramCompare.java
, v" k3 ]+ @" k* c4 s8 C$ B//( P/ d5 g0 E  K% ~8 v
//  Driver shell for Assignment 2.
2 P: |& e5 C& c2 z  M//********************************************************************
+ C7 n/ G$ u1 `7 ?  ^  a* \* T9 o$ C
class ProgramCompareMenu
: ^& a) y' Z9 h! `' g{
  }  Y3 c9 M& m5 s% \$ |    public static void main (String[] args)
+ H3 e8 d0 D" Q            {+ y) g3 {! q# J# B( m/ D: l
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable- Z2 T" t7 R) y6 J
                ProgramCompare reached1 = new ProgramCompare();
, `" Q* G4 ?2 d' t  z                AuthorisedUsers reached2 = new AuthorisedUsers();        3 P0 [# V' s: I7 C! u
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
: v7 q7 q2 M! k3 E                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        7 c+ @. ~# q6 A  s; W" ~$ Z! k
        }% F  l# Q8 d+ Q; Y* e7 I+ F
}// end of class ProgramCompareMenu" X: w! l: p4 i% ^4 n) b

' j3 ^+ J5 r" w: F) @//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************; O+ Q! \* I8 e, [8 g" q6 l, X
//          AuthorisedUsers.java          Provided by: DRS9 m$ ^; [4 L8 S6 A4 [
//                2 o! G" @, s" R1 }' D
//         Program shell for Assignment 2
' \8 x) O, ?3 ?# s" X//
! D5 o2 r9 Y9 D! c, Z' _1 u9 r3 e//         Represents facts about an AuthorisedUser
4 \" w7 X) i# m4 n) l9 ]//********************************************************************
/ H* ]# ]# b+ O/ _1 U! p( M7 \( J( ^$ J/ Y
public class AuthorisedUsers
( j1 \# P7 {* p$ v9 Q6 _    {; L3 {3 A' D: `; y
% ~2 z6 s: u! X6 L
        //-----------------------------------------------------------------
4 o8 b7 l" A  N  M) X% A. ^        // Constructor' {" w$ E3 f- A; f' ?
        //-----------------------------------------------------------------
! D4 p% a7 t/ [5 r7 N5 U! h$ P( X" M3 q% {& U* E% w  ]
        public AuthorisedUsers()
2 f1 G; d) M+ B; b                {
: m1 l5 x- `. c+ ~$ `: E% R                }' Y) i  P( L. n7 Z5 q2 B
/ w! ?0 `. N" r7 k1 E; P
        //-----------------------------------------------------------------; V8 f( S6 M, ]" }; q, m4 y8 P  _
        // Method for testing that class has been reached% G( w0 c5 \& ^* Q; T
        //-----------------------------------------------------------------       
7 s+ l3 b* |3 E* S% z        public boolean AuthorisedUsersReached()( b: `0 s! I. `3 i: c
                {7 `4 I6 s$ R( g6 m
                        return true;                        4 K0 ]" s. U$ `, j* T  e
                }1 Q' Z- Q& Z- B- v1 C( i( E
                * k7 T. b6 a6 B) J" }' G
    } // end of class AuthorisedUsers  C! X) T6 q; t$ ~! d# \: k: W& |4 D
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming. J- n$ b2 x& ~4 K9 [. M! B
Shanghai - 2007
) J8 A5 q2 g: JAssignment 2$ H5 K/ z5 }8 t/ [% S
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)& I0 H: s' X9 s# Z# e7 [2 O6 U2 ~
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." ]% _& ?& b3 C" s# R* ~0 `
The staff must be able to:8 S; S0 N. Q, [
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
' s: ]( t+ Y9 |- s3 t0 L1. 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.7 u3 b9 D8 F! q* E2 q6 T: D4 r* G
 The interface should provide a menu so that the staff can:; Q) J$ z& P4 r, b! L
a) Enter the names of the two Java program files to be compared
1 r3 Q( m  B' O8 P2 H- u- A For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
6 L/ x# f7 u# [4 {3 \** 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).
/ ?8 }# Y# z' N4 n' [! {( gBSA104 Business Programming – 2007: Assignment 22 x# E+ ^0 c% L
Page 2 of 5
/ q1 w# g0 e! R4 q/ gb) Print out to the screen all the lines of code that are the same
! v- I" c. d; C& P, l% G Include the name of the file and the line number of the code being printed for each of the two files
% _9 o% S! A: y; \5 L2 C6 W3 {0 H/ I1 Cc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared$ u3 \' N4 q7 ?* c: U5 m
 the name, username and department of the user1 h  G  N9 }  N" x( J( O6 j
 the statistics of the comparison
6 Z3 c6 G7 j% m* z9 H* H1 W# Q- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
/ N& i0 W) i; ^1 a$ g the recommendation for further checking( N6 ~* E+ D+ U& d
- 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+ ~- s" c9 \% z) q1 D9 n4 V
 the names of the two files compared+ @, v. x& J! x+ J
d) Leave the program (exit)
; l$ |2 q! F$ _& F' k- tThe ProgramCompare class: (Total maximum 20 marks available)' U3 v! _% }& E2 B1 o; J5 s& K
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)+ K0 P3 X& u: F5 o( X2 C
a) provide an error message if the files are not found or there is a problem opening them
7 H( a  @# q/ s5 ~# q1 J8 p/ n, |b) compare each line of code
: v/ X- ^# k& o0 C3 D9 j3 X- Zc) print out the lines that are the same
$ o7 F* z( {" L  D7 o( hd) count the number of lines compared / lines the same
9 w. v, O) j4 H! [; J( MThe AuthorisedUsers class: (Total maximum 20 marks available)
3 w/ w5 C9 K* J  U) ~+ C( X3. 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)
) Q2 o8 s% r& |+ o2 L2 [* T: ]" x4. Provide methods to:" T+ l& e6 S4 J; T5 J4 N5 i" c+ E
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 match9 G- j5 R) C2 ]
b) return the name of the authorised user; U8 P& B1 z; n
c) return the name of the department of the authorised user6 n8 l) N6 M& w# N
Individual Data (Maximum 20 marks available)
- j( C$ z6 h3 ]; [8 \/ A5. 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 g( N6 v& T- b6 D6 K/ j" }Documentation (Maximum 10 marks available)
) j3 a8 Z9 A' I1 k4 k6. 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.. j, H! K5 y& ^: R
BSA104 Business Programming – 2007: Assignment 2
: Y1 [3 Y8 a. V6 x6 l1 J% P4 W& [Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了, p7 R+ c- n* x
不过你要翻JAVA的类库说明。你有下载没有?
3 J! O  {" p7 M查询关于对比的函数。貌似关键字是contrast,还有compare
, |# e* _# L- v8 ^: R3 @5 S* l) v
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
' q7 C- }- Z7 F  w& F! i, z0 ]痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
4 B2 t2 A1 C, r, M3 P) I可以下载到的 是 jdk-1_X_0-doc, d( N$ B5 ~6 `) w% m9 N
0 z* X6 Z) N% _& G3 C
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-23 10:06

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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