找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1399|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急4 {5 g; t# s6 C+ Q% p' j1 d - R# b) Y. s$ ^$ J7 W/ A) c& A$ ^
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
: y3 G" e+ q( S; r  [9 b) L  M//  ProgramCompare.java         Provided by: DRS! ]' D$ E0 L. H0 @/ j+ v
//6 p1 d- J& `1 q7 E, [* y
//  Program shell for Assignment 29 N' @, W2 M0 q& k1 N& V) q9 g
//) i; K3 ~1 E. {. Z: d. m
//  Compares two text files line by line3 }/ V) c: d2 ?  G2 C4 t( J
//*********************************************************************
, v$ \9 ?$ k. U; |' D8 k2 M
6 F5 q  ?) ?+ @% S0 X$ m% ~import java.io.*;" S2 E% w! b! u( v

9 _) U5 I* R6 S) p9 B7 g$ Hpublic class ProgramCompare
9 v' |) M: u' T: `7 e; y5 }3 j{* m3 ]9 M  g* H
        //-----------------------------------------------------------------
8 ~, g6 A3 T( j" F. R; Y9 |        // Constructor
5 w( O" n2 v4 k+ A! p- d; J+ [; {        //-----------------------------------------------------------------6 c4 x, @0 _9 h: h' p  d
        public ProgramCompare()+ a( A. W# f# q2 f7 r  E
        {- t/ ~5 Q, u/ r
        }
1 S' f# Z* T3 V8 y7 f2 b$ ~
' k9 |. p( W. u* T        //-----------------------------------------------------------------
) L9 ]& K3 P8 m1 P. G2 `) c        // Method for testing that class has been reached7 x- G' @7 J& R4 Q/ T6 [' @
        //-----------------------------------------------------------------        ' i- r* N# J! P# X

9 _' I# Q/ U2 q1 c( p* f* k        public boolean ProgramCompareReached()        
0 Y! _8 v9 e  x, m8 G7 r        {
- F! a* |2 V7 b0 E      try 8 s7 b- v; c5 v9 e
   {        
5 C$ {2 L4 x7 s; ^                        6 q& B. s3 W0 ]% U* x9 R
                //********************************************************************( Q% d% F$ J* D# V$ w8 H: k/ \$ `8 I
                // Try-Catch Statement is used to handle exceptions - such as file not found
" v( ?' M6 h. U2 s( v+ l7 x/ B                // Reading the files will need to be placed inside a Try-Catch - just like this one!
- S! q, k0 J$ e) `7 [# a1 @' b# T                // For more information see page 534 of the textbook
+ i2 e8 d" R9 F0 M8 \                //********************************************************************/ Q6 U2 \) A# S' q+ n8 R8 {
                     * o7 n; w6 V, {+ J3 u, w0 v* J& d
        }
: q7 c5 O; Z/ l  |( F             catch (Exception ex) // Exception caught here and message displayed to the screen / [6 E# q+ E0 s4 d. e8 r! y
          {. }2 }2 C5 _7 v2 m
                    ex.printStackTrace (System.err);1 m+ Y' o& b/ Y/ _1 d8 X$ h( c
           System.out.println ("Error message goes here"); // Replace this error message with your own          7 [+ j, u7 K& J7 u+ K6 s
        }
6 E; l9 K: I& t0 r: {, ?                return true;
1 C  [; I, d% x7 w" G( O8 `4 ?        }/ L( E+ T, o0 D1 S

5 e1 d7 [/ a7 }, f2 @6 _( Q} // end of class ProgramCompare
  X1 {; p( |( V3 P' i# S8 n
' K, e; F- M* O' x4 D/ V//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************8 j+ m5 X$ B% y, s/ P* w9 D- }. r1 \
//  ProgramCompareMenu.java    Provided by: DRS
0 O# w" v" s* `( g) m4 E, t//; s! S7 }- e" R, h/ P9 K
//  Calls AuthorisedUsers.java and ProgramCompare.java
( D  n: n8 K/ B7 U; o//
5 P( t: c; Y+ C" i8 b0 h//  Driver shell for Assignment 2.
  w' [- L5 J; G//********************************************************************4 K2 l1 y/ g. w: r. b5 ~9 R* c3 x
; g3 r9 g$ q$ a; ]- V/ D* M3 |
class ProgramCompareMenu. }% @; G% C. L# p
{4 X$ N. M; H" R6 a3 T- I
    public static void main (String[] args)
5 D: g: e; R8 e0 ~$ \# z5 s            {+ d5 O& @6 z, `- V3 `8 y' I& h
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
) j' u- N' w$ h3 `* c                ProgramCompare reached1 = new ProgramCompare();
# O* H6 T7 l! ~' \" G3 \                AuthorisedUsers reached2 = new AuthorisedUsers();       
" Q8 a! T5 x# N5 E; C                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());. e) U9 w$ w: s# i% s) y
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ; u$ E8 f+ m; K+ M2 R' @7 R
        }
6 V5 q& T& \+ h2 M4 B, q, H}// end of class ProgramCompareMenu
! L. L7 h2 \- p2 T7 d' f( T! R; B0 w7 n. E# S( G# b
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************7 E# h; y5 A" ]# l5 x' W! C, p
//          AuthorisedUsers.java          Provided by: DRS
* h7 c" t5 W; {: ?1 g) U//                & d8 c+ m1 N) |) }0 @; `8 K6 R
//         Program shell for Assignment 2
9 `" h2 ^% ~! D: F//
. ~  l# l0 q) d( Q//         Represents facts about an AuthorisedUser+ m+ C; I, B3 P2 c0 M
//********************************************************************
% N. n4 P# k2 S8 G/ ?( W
  o! I) C0 S4 }, Z1 gpublic class AuthorisedUsers9 {- G' v2 S& g+ c. H; M
    {
- z. f/ i. ~8 E0 j  Y
: F$ t  |& a. _: a# x) R        //-----------------------------------------------------------------% y: t1 T6 a8 [1 R) Y
        // Constructor. k) t  O3 n$ Q0 M
        //-----------------------------------------------------------------
0 @9 z* ?' L4 }% n3 h
3 K1 w, h: H: J- A1 q        public AuthorisedUsers()7 P, g' Z- H) q9 I" J
                {
/ T! i  _' x6 n  i7 i2 _! t# o4 W                }7 W9 p, R( X$ v9 [3 p( @+ l& u$ m
4 o* r8 C0 p  \+ {" {7 W
        //-----------------------------------------------------------------
: S+ v. Y- P! X8 M  p! S* Q        // Method for testing that class has been reached/ j1 v* Z1 l- K  s, E! ]
        //-----------------------------------------------------------------       
! Y# D; D4 q1 K; x6 G        public boolean AuthorisedUsersReached()# N% Z! g( K+ z) f6 Q" d1 W' L
                {
0 X4 \% O7 S- V% u' m1 L! y* E                        return true;                       
. i5 g3 N$ @! s( d2 R                }
5 p/ N8 }7 Y) u3 e0 G7 t0 v               
; M+ c2 Z5 V3 R/ ~    } // end of class AuthorisedUsers: U/ t: J) {. }" V
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming/ I7 {. V: T; F9 ?
Shanghai - 2007) _3 f# i( I7 z% f, D+ O6 D
Assignment 2$ N4 ~. ?: o; q5 T
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 T, |- S* T2 L0 g$ Z7 Z1. 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.- f2 z: d2 k: k3 E
The staff must be able to:
* D% r  m/ o( g Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.) o( P2 J9 f5 r& K
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.
. v) b. k9 ^3 f The interface should provide a menu so that the staff can:
( S: i4 q- e$ R7 N( ~* g; Z% Za) Enter the names of the two Java program files to be compared7 h6 j  E0 {8 e
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
. x6 L3 R; U3 l3 A" w** 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).  i: P; f! L1 c) e5 ?
BSA104 Business Programming – 2007: Assignment 2& ^- z: }* T/ y8 u
Page 2 of 5/ r0 L3 Z& C) X7 I+ X- ~
b) Print out to the screen all the lines of code that are the same
7 k3 {& c  R0 N0 U Include the name of the file and the line number of the code being printed for each of the two files+ ?( @0 q' ^1 N2 ?5 j, v  T
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
: j' {8 b! Q9 g: Z5 c the name, username and department of the user8 _) z+ v6 u$ @0 J
 the statistics of the comparison
3 S( a% G# Z- `- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different: J3 Q) [9 V0 G# w3 n8 Y0 U1 B
 the recommendation for further checking
4 y8 H  i0 s, |+ b9 u- S- 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( P0 ?  Z) G$ M6 j9 G- J
 the names of the two files compared
1 M# Y8 n$ T0 y, O" G$ @d) Leave the program (exit)9 V/ z* l1 e+ w& z3 t
The ProgramCompare class: (Total maximum 20 marks available)
1 _$ T! s* I9 R* }9 }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)
' j, D+ E0 D. k1 Ya) provide an error message if the files are not found or there is a problem opening them& _. ~! ~3 I" l' u7 u
b) compare each line of code) @$ Y9 \0 M; M) k
c) print out the lines that are the same5 w  v7 T. m3 G' a6 l, H2 O
d) count the number of lines compared / lines the same5 D# y& {$ K8 Y) b
The AuthorisedUsers class: (Total maximum 20 marks available)# k6 q3 [% f2 ~" Z) `: v3 a" l6 g1 \
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)1 M9 q" E' x' {/ K) h8 E: J2 ]
4. Provide methods to:' w8 r3 j" g0 j  x, f
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/ }" {. O9 P3 K- `+ l- k9 |
b) return the name of the authorised user( C2 w- d- X- r1 {
c) return the name of the department of the authorised user
  Q5 X% [! W. U2 X. a5 A; I* h: z8 X+ M' D$ FIndividual Data (Maximum 20 marks available); r) \" k+ Z8 d3 l
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.
9 z+ h( R6 }% v: i! JDocumentation (Maximum 10 marks available)
8 E0 c+ ]1 b) ]% Q3 ?3 H# R8 s* z6. 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.% ]0 b" D/ i" X0 c
BSA104 Business Programming – 2007: Assignment 2
5 L; o1 M* _. n! D4 k2 l/ w, A. `. rPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了! E  N7 P7 H9 Z2 ^  i# u
不过你要翻JAVA的类库说明。你有下载没有?
% A. {$ \/ y  E9 u! y" Z# o' O0 e" O查询关于对比的函数。貌似关键字是contrast,还有compare/ Y' ~  a! U% B& x

5 O+ a7 w0 W1 `+ Q' t  D+ j[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
) P8 r0 G: h  b( L; B5 M) s7 @痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。4 M7 b1 Y( y7 v3 Y! i, A0 `. q
可以下载到的 是 jdk-1_X_0-doc: u9 g9 |7 V# Q( J* W

" x. C! L3 k+ v[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-21 13:02

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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