找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1088|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 6 h1 Y5 H% c* W$ U9 b$ H 9 l) ^% s* F1 E4 x8 j
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
( P" G  U/ u) N! a2 \" W; t  A//  ProgramCompare.java         Provided by: DRS
" U( E( N7 G, B//
# d8 J4 G9 N# E( {//  Program shell for Assignment 20 r( n1 h: [" W( l7 M2 h% U
//
+ ]  z7 U2 |$ j7 U* N7 C//  Compares two text files line by line
! a5 ]8 @" e8 k: H" \0 c//*********************************************************************' w9 ?" r3 \5 Q
5 Q4 l) d# h  _- c4 g
import java.io.*;
8 m9 G% w) j4 v3 L/ F% c$ A5 z! Q) v$ Z8 e
public class ProgramCompare
8 o& E+ J0 y4 n' T; h{
. p4 E8 H: v; Q3 m        //-----------------------------------------------------------------7 `. i6 N7 u. f0 |7 r, E
        // Constructor
/ {) h# V( T* x2 E        //-----------------------------------------------------------------3 Y& e4 E% X) ^+ O3 a; ?3 z0 l
        public ProgramCompare()( K! T6 ?/ C! j. g$ y$ p
        {
7 L4 U( M  i) c3 F, G- E        }! v; ]/ ?. C& P/ [$ T; S# O/ I- `

9 l. q2 l- Y3 L4 }; t+ B        //-----------------------------------------------------------------
% {7 a  {' Q4 \/ F- k, P- X& _        // Method for testing that class has been reached; c3 A# j) `; d; v  B
        //-----------------------------------------------------------------        * ]3 n9 k+ \& @" n3 c
& _+ f7 ~4 Z: [
        public boolean ProgramCompareReached()        
+ S" @! k& c% n' k0 N) A% t2 C        {, c/ A2 R* U3 V. G
      try 8 c% _+ u  S; j6 J1 T
   {        
! Q9 G- K9 P! \" m/ Y                       
& r- [: G- c7 L. U: I' I) R# ^                //********************************************************************, b4 ?4 Z3 N7 a2 X: h
                // Try-Catch Statement is used to handle exceptions - such as file not found
- C0 ?4 W3 _5 C, }! |                // Reading the files will need to be placed inside a Try-Catch - just like this one!
. }3 J1 l3 N' l. i9 l1 E7 B% a  b! K                // For more information see page 534 of the textbook
# E/ {* w* \9 x( F1 Z& B% i                //********************************************************************( i2 Q1 L0 N  Z
                    
9 H4 \1 T. g. f6 S        }
/ B/ C4 N6 i6 a4 @, Y; r8 n             catch (Exception ex) // Exception caught here and message displayed to the screen & L% ^: B! m! R' O- R. y7 @
          {
/ `7 W: s  I) j- Z  q5 O5 L* w                    ex.printStackTrace (System.err);/ s/ y& E' _6 d2 w
           System.out.println ("Error message goes here"); // Replace this error message with your own         
: H7 X. J% F2 ~) k, H        }( S8 e# M$ P7 B8 a# O% B
                return true;, u; {# r& h1 F
        }
/ i; A) Y& o0 u: I! Y# H: q: j: e% h" J8 H
} // end of class ProgramCompare
5 F2 ?. V- [4 N
/ a% ~1 z+ s9 v: }0 }3 C" }' l//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
' \: A2 C' y* I/ w  ^9 ]' W//  ProgramCompareMenu.java    Provided by: DRS
4 d$ c7 |0 v; u* @- N//+ \6 |, g$ P4 v' A) Q
//  Calls AuthorisedUsers.java and ProgramCompare.java+ v- G7 T0 Q  S8 V( p
//
( u2 F* L+ f/ m0 H//  Driver shell for Assignment 2.: {8 s; e; u6 q
//********************************************************************% ]' k8 Y2 F) |/ |

% J" q5 U5 g$ d% Yclass ProgramCompareMenu8 q% D1 {# Q; p" L" U( i, _* T# m& O
{- Z  F- H/ g6 ~: v9 W5 B! K
    public static void main (String[] args)
9 P2 S' k# @6 |, x            {& E6 \# d1 Z4 U2 V! C& B. o- Y
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable4 q1 W) J1 W: _& J* _1 @
                ProgramCompare reached1 = new ProgramCompare();
2 x" G5 ~6 j7 N                AuthorisedUsers reached2 = new AuthorisedUsers();       
, ]. O. t# {$ c' G2 R7 i7 G7 l8 Q                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());1 [1 R$ k1 f+ [7 W0 ~
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
. w2 P, w, f( {# X5 c        }
4 u$ e) \( p! U$ T& l- g}// end of class ProgramCompareMenu+ G: p& D) _7 r+ z) G+ z
- m5 P; b, x* {) s) T9 Z( l, t" Q" p8 s
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************' {8 k0 @# m0 e$ W# C
//          AuthorisedUsers.java          Provided by: DRS
3 u0 c; O( j' b# A/ D//                - F- M( @1 t$ T) h2 V+ R
//         Program shell for Assignment 2: K) }3 e4 K7 t6 U( d2 d1 L
//
. x( b- S8 ~! J. H2 A, ~//         Represents facts about an AuthorisedUser* _; L$ R9 `4 o
//********************************************************************
. k. v  y5 X; m. u, p. q9 t3 o- V0 Y& k+ H
public class AuthorisedUsers6 c& l6 E, A6 J8 e) y. g  {; d% c3 @8 M/ s
    {+ |3 q  V2 _. Z, O2 E/ L: z

; G. \4 }4 k' \: r$ ?        //-----------------------------------------------------------------& B$ v6 q- L4 O8 a" c
        // Constructor
5 N. o" }& v" K: E0 Y2 r        //-----------------------------------------------------------------
0 y/ U4 `6 H9 l. o2 ^+ d8 b5 W+ N! `
        public AuthorisedUsers()2 V) @! ]% m6 O+ U# G' @
                {. v7 ^- J% {: z3 R% A! s
                }
4 b: D9 p& L0 ^- M0 o1 T; C' j4 ~1 B4 G! Y4 `" ~; H* [
        //-----------------------------------------------------------------& o2 S) X( j, Y6 F2 G8 o
        // Method for testing that class has been reached
* v$ {6 }/ W; x# k3 R        //-----------------------------------------------------------------        + H1 v7 l) a) d+ h: i
        public boolean AuthorisedUsersReached()3 `4 l0 ~" I8 D7 q
                {
0 @1 Z/ m* O# O' c, X                        return true;                        $ A; `! L6 D0 J; w5 j8 V+ z
                }! Q( ^# c: `2 W% w8 R3 B7 p
               
& Q' C9 y7 v1 }! n( X# X    } // end of class AuthorisedUsers8 I5 c6 X/ t. d" h
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming7 q+ c6 A9 u- `: l' ^
Shanghai - 2007
& C/ V/ [- P- ]- V, q8 f7 QAssignment 2
9 F* X* B2 u: }5 L9 q8 a( t. pDeadline 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 F1 U0 F0 E, u, H. H5 T1. 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.  a# V' y7 @+ T8 n$ E! I! _
The staff must be able to:9 ]& t# y" t0 s
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
  Q9 p5 E" z$ {0 r1. 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.% c; l, d; w; w% s
 The interface should provide a menu so that the staff can:
! b" m& o$ e( V+ g3 }a) Enter the names of the two Java program files to be compared
; m  O; f! c. s3 s For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
6 r, Q  m3 C% Q# 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).
% M2 t2 b/ L. y% H; D1 aBSA104 Business Programming – 2007: Assignment 2
& _4 y8 O/ }& d" \" e" O: }Page 2 of 5
5 L4 c3 @9 V* r  t7 e2 Kb) Print out to the screen all the lines of code that are the same
- n, b+ ]3 G+ J0 S Include the name of the file and the line number of the code being printed for each of the two files' y/ |! x) C$ D6 t% j& K
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
, b9 c, s: m$ R7 c: y0 } the name, username and department of the user
, B; S; k' N7 ` the statistics of the comparison
6 E2 W& F$ K/ B  X' P- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
/ K+ A  w( e$ I4 [ the recommendation for further checking* ]6 R: Z" U1 k: w0 @
- 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
2 B7 g. q# P. g/ @9 S) o the names of the two files compared, J$ T  K; w* Q; }! P7 ]% a
d) Leave the program (exit)
* L; |7 ?1 c5 kThe ProgramCompare class: (Total maximum 20 marks available)
8 @; L: S! x6 |1 r2. 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)
! [# W: v" {' N% o9 }8 f6 @a) provide an error message if the files are not found or there is a problem opening them- i# A, L. @. _9 d( ], u7 x5 H# G; T
b) compare each line of code
$ W; ]3 d% H# h/ S, C, }c) print out the lines that are the same
; f8 S7 U/ J& h4 @d) count the number of lines compared / lines the same
5 ?, t# P3 m/ p) ?# LThe AuthorisedUsers class: (Total maximum 20 marks available)
# D; d$ m; R! w2 O, Q2 ?3. 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)6 O' [" F% h! h. G& y( B
4. Provide methods to:
" f( d, m( @, v  Qa) 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  v& K8 v) o! p8 ~
b) return the name of the authorised user
' Y5 `  S* p) Ec) return the name of the department of the authorised user
2 M: }9 s( [$ a6 H4 A% W. `. L  l+ Q7 ]Individual Data (Maximum 20 marks available)5 e+ S3 k: L/ U, i' U9 g' C# b
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.& m0 F: l/ u1 c. G" q! A1 o
Documentation (Maximum 10 marks available)8 R' G# s) a% I( Z7 N
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.9 D& i5 j. @. v* b
BSA104 Business Programming – 2007: Assignment 2) Z. N2 n4 j7 r% ]
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
6 Q9 v, n: Z- Y. B# A7 }# ]不过你要翻JAVA的类库说明。你有下载没有?
1 V! J+ h  m9 W# c; r查询关于对比的函数。貌似关键字是contrast,还有compare
. s: |# m) g. {. E% F, P+ @' Q" N% K# Z5 A
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
, _- f/ Z* M+ b! D痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。5 X, Q" \5 a" `( O
可以下载到的 是 jdk-1_X_0-doc0 ?$ P2 D9 i: z& U: x3 m

! x( V2 Z- K! w1 c, l[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-3-2 16:20

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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