找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1252|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 4 D. s9 Z5 ?! T& |/ E/ C" Z 0 J4 Z+ H: z6 [, }& r" {4 [
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
1 y( {! a2 a1 M  a+ @  H& o//  ProgramCompare.java         Provided by: DRS
3 D4 d; |2 y9 Z4 I  Q: f" W//; [! \0 n; U& T8 _7 \1 T( R
//  Program shell for Assignment 2
" ]. o: g- ]# O2 u/ b% t//
, v( Q) N6 D. ?/ f" A//  Compares two text files line by line
' n2 ~7 P0 [$ Q, S" U8 K7 T//*********************************************************************
$ w/ {; L+ @( `- `% r: p* e( B: ]4 d  ~4 Y
import java.io.*;$ z2 E9 B+ Q! [) Z2 x, y$ v5 O

. M: k  y0 O. n3 ~* m( U3 P3 T* dpublic class ProgramCompare5 n! \1 e( W; y+ b( w1 `
{
$ t, Q( J" x; K: i2 Y+ E        //-----------------------------------------------------------------$ L- b' D# R: n: H0 n: {; T. [: }
        // Constructor
- X/ v+ v5 w& v        //------------------------------------------------------------------ ~8 `2 R+ [! V8 v. A
        public ProgramCompare(), K5 v0 O+ E5 `
        {
/ F3 Q/ i/ E* z- q/ o        }" Z! d- ]% J% r: ~% e

* c- R1 ~. n7 F$ p- s  M# `( n        //-----------------------------------------------------------------
6 T' @6 S$ F8 C% E# O  c0 }' ?! |1 W        // Method for testing that class has been reached
# a! g" E3 F, h* h/ o        //-----------------------------------------------------------------        7 W  I; }* }$ t0 t1 U
$ W, `" h( V% t3 R
        public boolean ProgramCompareReached()         5 }* G& C  L+ b1 _* ?% G8 f
        {/ s. g, B+ Y9 \
      try ( }! C$ o# k5 K" ~5 ]/ H
   {        
8 V: Q# P+ {8 ]  p                       
' ~6 X4 k8 E- p                //********************************************************************
! J5 d# C) |: q3 g                // Try-Catch Statement is used to handle exceptions - such as file not found
% d+ ?  y7 g6 h7 t2 h3 Z2 y# m                // Reading the files will need to be placed inside a Try-Catch - just like this one!
) ]. a. {) E% ^4 t6 T6 ?                // For more information see page 534 of the textbook
. D1 j  {9 ~/ [                //********************************************************************
, H  w1 i5 H& Y! e                    
  c9 f7 d1 H7 o& w; b- s6 [: s) N        }
9 P/ E. A* ]3 L! @$ b, @- q             catch (Exception ex) // Exception caught here and message displayed to the screen ) R! x9 S3 ~8 U8 L7 n5 p# C
          {/ W1 n0 q% D* h( w* }% J
                    ex.printStackTrace (System.err);) [4 p# T- S* v" Y' J! W
           System.out.println ("Error message goes here"); // Replace this error message with your own          * C- l$ P% H' \
        }
4 K, Y2 s7 o1 ?: k, _                return true;
/ }# y4 l. x# J        }
3 {) E9 \1 _2 X. W; k$ n1 M3 t; W" |/ C& t5 v- N* i; j! c
} // end of class ProgramCompare
# b- _, S5 f4 B5 t8 ]1 B) F
8 M* `" N. p4 A//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************2 W$ D- h2 c" C0 A6 S* J
//  ProgramCompareMenu.java    Provided by: DRS
3 M  m& ]8 ]' U6 P  }6 C; ~  a+ v//  D$ o2 w1 g, S3 y4 \
//  Calls AuthorisedUsers.java and ProgramCompare.java
) X3 F2 E4 Z7 j3 H; l2 m9 {//
" N8 D( N+ Q% a4 V//  Driver shell for Assignment 2.  h1 S0 J5 g! o; Y" h: {
//********************************************************************
& _' e; b6 h0 m* ?, r
0 P8 O" @0 O4 F9 dclass ProgramCompareMenu
' h' J3 x' l7 U- v: W{
; W, f* M7 J5 }6 x+ D    public static void main (String[] args)
5 N1 p/ G7 X" x/ O            {2 M$ R: W2 Q  _0 [# l. A0 A
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
$ r( g% B# w$ z5 n0 s: j; ~/ g+ q1 d                ProgramCompare reached1 = new ProgramCompare(); 0 z9 j2 c1 j! z9 U' q. x' D
                AuthorisedUsers reached2 = new AuthorisedUsers();       
1 w. Z; n" ^! K, A3 z' K                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
% h' u' \$ A# I0 s                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
. o/ ^- p; s, Y/ [% a, u/ B        }+ g" c- v/ d5 ]7 ~# r3 }
}// end of class ProgramCompareMenu+ j$ }: \1 X! p# O2 \7 w$ T+ t
, L8 t  a, H( x4 Y, {2 m
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
! q) k6 B* i5 P1 f//          AuthorisedUsers.java          Provided by: DRS
7 D6 J. n2 s2 ]  j! e% e& b4 ?9 s9 c//               
# ^+ t% ~* W  N4 I2 o$ N# K5 E//         Program shell for Assignment 23 i' B' b2 G# x7 q
//
* |% _9 W2 I0 ]& P: m1 u8 U& e' g//         Represents facts about an AuthorisedUser
: Y5 T! G1 p& O$ D( e+ C//********************************************************************
4 D* O9 l8 T3 k" G& a& b
" i, b! H1 n1 j/ k- M0 n, s" wpublic class AuthorisedUsers# f7 W" a! C# b' B: Y  C' I
    {+ c* V: @0 p5 l3 B0 O0 L
7 X" j) s8 L) o5 W* O6 S3 e* ?
        //-----------------------------------------------------------------
- E, N% n% d2 d) y$ g( Z! s5 g        // Constructor+ B* ^+ r; @, w  W4 N6 v
        //-----------------------------------------------------------------3 l1 i+ b. y5 |9 ~3 ^; c

; r3 O* y, t# m( j/ Y- I        public AuthorisedUsers()
" `5 C4 m# E- l0 E! t2 `                {
1 I$ H/ }! v! u7 T- r' Z                }: N1 o* G' V( L) }

+ K% s; t- t$ J        //-----------------------------------------------------------------
6 T+ T; a" `# q4 J- ^$ N) D- G        // Method for testing that class has been reached+ ?  M1 d& l& e- e
        //-----------------------------------------------------------------       
7 @! `! G/ c% l& E+ c) c) R# M, ^        public boolean AuthorisedUsersReached()
/ l0 t9 }; B9 a1 Z8 a9 w+ F! o                {5 {0 s" L) @" Q! r
                        return true;                        " O  m, M* F0 [  O6 E
                }
$ q4 H6 ?- ]" e) c+ z" S6 I; K                + O2 z, i! U# h. `# I5 F1 C& q
    } // end of class AuthorisedUsers% l' R; C& S8 f- R( f  P+ |5 ?
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming1 R8 F5 J; G: s
Shanghai - 2007* R9 ?4 h9 h% Q, _, q2 S7 n
Assignment 2
6 }% a$ D- X( H7 XDeadline 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)
* B' ]5 Z8 u8 n/ t1 A1. 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 @" r' P& ?+ C: z! f: Q7 @( LThe staff must be able to:
. u' a: {# g9 d# | Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
# I5 I0 k/ A" y! {$ ]" ]6 ]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.
! |! G: P4 q  |! l7 ]) | The interface should provide a menu so that the staff can:
1 B5 K8 v1 K5 Z+ o2 Za) Enter the names of the two Java program files to be compared, `5 i& J9 G! P2 V
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
. A6 l0 @1 Q# m% _7 k$ ^** 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).; }  H- Z+ I  N) Q0 M9 Z* s
BSA104 Business Programming – 2007: Assignment 2
& s/ b/ R* c/ K# a6 }Page 2 of 5: y4 m' u$ R; o8 @0 [
b) Print out to the screen all the lines of code that are the same& {& J- {5 F; P9 o8 m
 Include the name of the file and the line number of the code being printed for each of the two files2 B; O9 R" s# Z4 x) p) \
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared' d. G  s/ g6 U
 the name, username and department of the user- F* k. p, b: R$ A; V
 the statistics of the comparison
- ^* Z; j* x5 _2 i2 Y0 @% X- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
8 J5 h) g1 Z: q) Y7 Q the recommendation for further checking
3 u8 F/ z; @' W1 A& j2 R7 d  Q8 [# ?4 F: h- 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
, K4 N$ Z% h0 v/ k$ ^9 Y the names of the two files compared
7 C! \7 Y. d/ O# id) Leave the program (exit)
% ~% F1 _' U" Q. V$ _) V' Q3 TThe ProgramCompare class: (Total maximum 20 marks available)
% C; Q- p. O; O0 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)
( I. p' Z: f8 F. d+ ]" Ha) provide an error message if the files are not found or there is a problem opening them' ?1 _" ?, D. e. b7 n" @4 V
b) compare each line of code0 g% {# Y8 W# \, O0 |' G4 L3 p
c) print out the lines that are the same$ o/ Y$ h$ J- |1 n- E; P' z2 W9 q
d) count the number of lines compared / lines the same6 z0 `* x$ p% X( f4 ?
The AuthorisedUsers class: (Total maximum 20 marks available)& G* V3 G( c: Y1 K+ H
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)
/ N/ q0 R- j0 @3 X0 S4 V4. Provide methods to:
% K8 J9 I5 h8 ?9 [# ?, Aa) 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$ S+ B3 K8 |+ M. V
b) return the name of the authorised user
; q7 T3 Y  }6 f- Oc) return the name of the department of the authorised user
1 V( g, n' U: [8 S! u  G, mIndividual Data (Maximum 20 marks available)
9 m4 _# u8 b8 l' d9 L/ Q, L5. 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.- n/ W2 i: c# D  N& G
Documentation (Maximum 10 marks available)6 Q( R& p8 [% j1 Z8 q( J& |
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.
4 w* ?! V2 l+ q# `0 ZBSA104 Business Programming – 2007: Assignment 2
' q- V& y: d# c0 N  r$ C+ p: Y6 g0 \' vPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了8 |8 ]) f. L- l/ U, j, j' n
不过你要翻JAVA的类库说明。你有下载没有?
9 Q; x$ P  [* s/ F' C& T& B* d9 S查询关于对比的函数。貌似关键字是contrast,还有compare
. Q$ ~  N7 F8 D/ n8 j) X; T$ K/ c& M% {3 N6 H" x; A! e
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -; B# S! c5 g- ^+ u0 ~0 c8 z
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
) g* @" _* g& {3 [可以下载到的 是 jdk-1_X_0-doc! j8 R  z2 G. J+ h1 F
( H% H8 @; Z) q4 E% N, |9 Z7 w
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-8 09:10

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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