找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1439|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急: F# ~; ~; ~( _0 X7 ] # O, ~& c; Q6 q5 t( r0 i
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
/ a- K" r! e( q. h//  ProgramCompare.java         Provided by: DRS
1 |; o8 z# D8 C; n//
8 x8 h1 o5 a* s& A1 o% h//  Program shell for Assignment 2! `% S7 H' P: V6 d1 W) |& ^, O" B
//
) N4 o$ L) i0 R% m3 I7 S4 s//  Compares two text files line by line
  B. n  p4 k1 e4 n$ S  k' B//*********************************************************************
; Y- a+ q* j9 [& m7 B  N1 x1 O0 ~' B; k/ h, z8 r/ C. S* [
import java.io.*;( W' w- |) L  H$ {% W0 \

) I' H8 |1 [; t7 Rpublic class ProgramCompare
- H: J/ N; t: ^7 x# W{5 `6 U) H7 m* }  ^0 ]1 {& R4 v
        //-----------------------------------------------------------------$ d$ n4 x3 |% v$ {# D  B
        // Constructor
3 U) A6 e( d5 A- x" _  c3 \        //-----------------------------------------------------------------4 P9 y  b' a3 r+ L9 R* M- W
        public ProgramCompare()
$ a  m  z, L! g  I" g8 d1 w% _2 b1 k& l        {
4 y# H; {, D$ E4 I2 R        }; t) B9 z" x( L+ d
  C$ t' z  g, B. r3 m2 F; w6 g% |
        //-----------------------------------------------------------------
5 T5 }6 Q1 S; h( @3 m6 a+ B        // Method for testing that class has been reached
* m3 K/ s5 _. z% ~+ Q        //-----------------------------------------------------------------        # s9 k3 y5 T& {9 \

9 l! J/ ?2 t8 [        public boolean ProgramCompareReached()        
& U$ n( x* l! m# X        {# X7 a) B) _4 {% ^9 R. E
      try ! q) G# z1 n2 |* D: |
   {         - U2 Q6 L% @2 o- Z& f1 [4 s
                       
  H  U  e' v( z) @1 V                //********************************************************************" a' R4 I# r. y) Y# |  A" ?
                // Try-Catch Statement is used to handle exceptions - such as file not found
0 e" k8 n$ ^) x  t! _  j                // Reading the files will need to be placed inside a Try-Catch - just like this one!
6 W7 q7 y" {- x6 w                // For more information see page 534 of the textbook/ c% y4 ^5 s5 O3 \1 Z3 {( K
                //********************************************************************
% u" A+ f: K8 [# x* R) Y: p3 K                    
8 z  u' j5 v) k; _        }
3 s+ H0 S2 C! J8 x$ M             catch (Exception ex) // Exception caught here and message displayed to the screen ) s- B. ~, L! |0 B& e/ [
          {
5 q6 r/ r0 z9 A% t( M3 O                    ex.printStackTrace (System.err);0 z" [. f. U/ E. @8 m
           System.out.println ("Error message goes here"); // Replace this error message with your own          ( c8 h( }1 O3 ?9 d) K% K
        }  W9 A0 S% b4 X) C
                return true;
6 f  W2 J) o- I( g- A; S( m7 v        }7 d- e- g. f+ N& W2 c
- e- A+ d' v% N0 W9 V& @( o* Y
} // end of class ProgramCompare+ @) N$ M' y" f* E" S8 F3 a: w

7 x7 E& z2 g, J: u//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
8 E6 Y4 n  G. t2 }8 K//  ProgramCompareMenu.java    Provided by: DRS
, C6 i+ K: U9 S//
* T1 S% u/ Z; J3 s$ x6 A//  Calls AuthorisedUsers.java and ProgramCompare.java7 y! o' k0 u: ?! l
//
# t) n0 y0 J+ ~( R//  Driver shell for Assignment 2.
, U  ~) d+ \; h" M1 @2 g" x//********************************************************************9 j$ z- @' c4 I4 G: W+ S

  R) \: d$ |% R& i- @class ProgramCompareMenu, Q3 C& G) e2 c
{) Q9 u5 x, n5 q" a3 {; L
    public static void main (String[] args)6 g5 A6 l/ K& R( Q9 j- a, [& t# t
            {- Q( g2 H) l( \& Q: a/ Z8 ~( A2 S% E
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable4 H7 ?4 }6 ^& a  C0 g/ a
                ProgramCompare reached1 = new ProgramCompare();
* G* i+ Q4 A3 T) V2 v                AuthorisedUsers reached2 = new AuthorisedUsers();        7 W+ u# r* t! N7 u2 ]0 g
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
) T: g: f6 \; i* n% Z. W4 ]                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ' d$ y  s/ n9 d' ?7 C- V- T
        }
0 u0 w, M3 d0 E, o}// end of class ProgramCompareMenu
7 }/ U' F8 d6 e# J" Q
  r0 X4 ~) U3 y5 E' y6 ]4 [0 s//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************7 g. O' J* ^3 l5 R2 K+ p
//          AuthorisedUsers.java          Provided by: DRS- T! x5 K. }3 J4 y6 Q4 {
//                0 Z$ [' p2 W% [$ v
//         Program shell for Assignment 2
/ g# d) s# l4 Y. u2 c//2 R: O2 c/ @8 v- ^" l
//         Represents facts about an AuthorisedUser7 Z# w- x5 l  c' v- x. C* G. e* ^
//********************************************************************
# q2 m8 A/ Q) i5 `. B3 H) ?5 L# c; d" J1 l- \* F- f
public class AuthorisedUsers( k: q- |, f& Q& O
    {
- e. _7 d$ ?! v4 X# o: h8 ^/ O. ^3 O* ?$ y: E; a
        //-----------------------------------------------------------------
% [) F3 T& t, f/ s% s3 F        // Constructor
, H  w" y( T$ w, c* |, L        //-----------------------------------------------------------------' r# t9 J# E0 k8 E0 i; k  e

$ ?4 v4 J$ Y) T$ S$ i3 g/ L* e' I: E        public AuthorisedUsers()
. E  k$ |7 p7 [( a( i7 }% L: _                {  q$ J5 t0 c6 r* |; u
                }) H2 l) d! X; o  D8 F  U
  k; A, ~, w. p6 r4 r1 \: U% u$ i
        //-----------------------------------------------------------------
3 J( v" B- _9 a8 V# [: N7 b        // Method for testing that class has been reached
+ \' o* K' D; C5 c1 N# O# T        //-----------------------------------------------------------------        5 ~  v0 P$ b- D% _
        public boolean AuthorisedUsersReached()( O" K# R# _" c2 T( T" x/ U
                {
+ D4 w8 x; T$ a7 m2 s0 G                        return true;                       
4 _$ [1 `& Q. P" X                }5 u  E( V3 ]3 n/ E
                0 f- v1 i7 L# _" E! Z! D# Q& g( E
    } // end of class AuthorisedUsers
" {/ I1 X0 Q2 o9 E2 Q( T" O//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming& {0 s2 k* s; f5 A" l
Shanghai - 2007
$ Z- C0 l2 c6 l3 t+ H. MAssignment 2$ N7 ^( X. }1 F. h# U, ]4 G
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)4 C3 j: b3 ^; X6 s# z2 q8 l& j) |
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.
+ _+ j5 j6 |5 \8 G  L, B4 u! wThe staff must be able to:- C2 S9 E0 l0 {) T; `
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
, d( R, d5 V$ M1 G& R) G  a. C+ b1. 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.; |, ^8 U" Z4 R
 The interface should provide a menu so that the staff can:
# X1 @, T: `- c# j/ y& C& U& ja) Enter the names of the two Java program files to be compared
* r2 m3 v: {/ q For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
  C* p. M+ D4 c  m7 J** 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).; j; B6 G2 G( C" t+ Z3 d" D
BSA104 Business Programming – 2007: Assignment 2
: I5 ^' M3 |# B' q3 C* OPage 2 of 5
, y" k5 a4 G) g9 m3 Y9 Db) Print out to the screen all the lines of code that are the same
# S+ X6 j2 U7 r Include the name of the file and the line number of the code being printed for each of the two files
* c0 U1 G1 B4 k8 cc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
" v6 q. ~# |2 ^# d the name, username and department of the user8 ?7 s" B' K: v2 H) \
 the statistics of the comparison$ E0 t; b4 e7 c2 h) B1 a
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
8 I( `4 R2 N* J& C: t" Q the recommendation for further checking
$ {* G0 w7 O) l) e" U# ~- 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
, `% G' D9 d1 i6 ?$ u( i# K the names of the two files compared
8 E/ L, r% Y- E: c' `3 Ad) Leave the program (exit)
) E+ f, W1 t0 z9 z. H- ]9 DThe ProgramCompare class: (Total maximum 20 marks available)
2 j& L) a1 f, P- `# ]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)
0 |4 f, E2 [& U% Xa) provide an error message if the files are not found or there is a problem opening them* i+ @; R* s. Q. z3 x9 q* L. x
b) compare each line of code
8 O+ l9 {- \. x- Z8 Y7 R8 `6 Yc) print out the lines that are the same" Q: H0 _4 ?- r/ j0 v% A
d) count the number of lines compared / lines the same+ Z+ f& i. u0 ~2 _3 v8 y0 Z, f
The AuthorisedUsers class: (Total maximum 20 marks available). K( S( d! U9 M. L
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)# I% b4 [0 }  B" {! \
4. Provide methods to:0 m5 c% {6 K5 U& \( F, g' u* p
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
& H) h! Y. p4 b  G, Ib) return the name of the authorised user4 y$ E0 M- @4 q# D! }; I
c) return the name of the department of the authorised user
3 l$ `6 H7 z. WIndividual Data (Maximum 20 marks available)
1 W9 J" Z( }+ i8 u4 ^7 a) S5. 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.
6 u8 e! d% c1 \- [7 A! \" tDocumentation (Maximum 10 marks available): [1 q- y; w, r6 Z5 U
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.
) p* o+ O5 s% s6 o" V. p+ M2 {8 t+ kBSA104 Business Programming – 2007: Assignment 2
$ ~* V! F6 L7 \Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了0 L7 K# u5 c8 O3 a, _- g4 {5 N8 t# t
不过你要翻JAVA的类库说明。你有下载没有?7 C7 q0 v2 A) ?7 l" H0 q/ X
查询关于对比的函数。貌似关键字是contrast,还有compare
. E; J  V# n1 h; M3 R- ^- y9 e! u  P/ u" A3 r! T
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -9 x4 w2 K) o$ ]. A& T! i
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。: j+ I! f$ \" R2 \  f
可以下载到的 是 jdk-1_X_0-doc
' X2 c+ W* P3 _) m
+ u' z/ |  b0 _[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-6 20:43

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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