找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1478|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 / J) X2 w7 Q# q( s$ {7 ^4 B3 {- l$ n% N$ ^
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
/ m- m# d1 \/ H+ S3 q/ c//  ProgramCompare.java         Provided by: DRS
  @3 F6 |8 C  G  ?" ^( [//
8 I; Z" F0 D9 O( }' L1 ~9 c9 A//  Program shell for Assignment 2
7 n- D% s. _! B6 V* U' Y0 K1 E  n//
7 j+ ^; J6 C* M. ~//  Compares two text files line by line: A9 }4 H7 `" h" ~# I1 ^. G! s
//*********************************************************************4 k* T$ \4 P4 m3 s+ }' {, B

6 @+ l% Y  J6 \0 d' Zimport java.io.*;
* t5 Y4 e1 s9 v  ]2 n" y
: s9 _* Y2 H: i/ W0 Jpublic class ProgramCompare+ g+ q" I; L4 @& ^
{
# g# R5 i* C% N  J        //-----------------------------------------------------------------0 u# Y9 A. I1 c( Q1 C/ t! @
        // Constructor
1 i/ k- Y0 L6 O6 z. ~        //-----------------------------------------------------------------
0 L- C% [# p  c2 }        public ProgramCompare()
3 B$ ^8 k2 @7 x# ^& ]5 W: x        {/ M2 e5 K  [$ c/ ]1 N( m, \; k. V
        }3 Q# Y$ r  v' a! O2 j5 \

- Q6 `0 g$ Z1 @% g  a& O' f        //-----------------------------------------------------------------5 i: w3 U& M3 W2 v- T7 \
        // Method for testing that class has been reached
5 U$ j: {! y) E1 S/ S        //-----------------------------------------------------------------       
( j  i( |4 u6 a4 E' T5 ~' h* @" c- _5 n
        public boolean ProgramCompareReached()         * W& j4 k; H  V& s0 a1 N6 H  m
        {: p+ I$ d  o  p1 P: g
      try 6 [- r) |9 B/ {0 u* v( ]
   {         0 I8 s% Z- [* K1 x8 s" ]
                        6 M/ `+ h- P4 U  N8 C
                //********************************************************************- E- A/ S3 v$ C. z/ h6 V
                // Try-Catch Statement is used to handle exceptions - such as file not found
8 F3 Y5 I) _2 G$ Y$ a# d/ R                // Reading the files will need to be placed inside a Try-Catch - just like this one!
8 R7 q2 r7 G/ D0 e6 T6 ?  q                // For more information see page 534 of the textbook) R2 L! }/ N! b* v- d( Q# n
                //********************************************************************
+ W, @+ t2 X; b9 h2 v. I9 c2 b1 `                     + }7 Q+ I8 d6 n- B
        }
7 |1 y. Z% n$ @( z2 w             catch (Exception ex) // Exception caught here and message displayed to the screen
6 {, x* g) I3 w  x7 ^# U: \          {* S% U3 L# D% m  P% G, c( L
                    ex.printStackTrace (System.err);: h8 }  R8 c  Q- N
           System.out.println ("Error message goes here"); // Replace this error message with your own         
* T  M" U3 R; R/ K! |        }3 M: U4 \* }3 U6 w
                return true;
$ |! D7 Y7 B4 W; J3 Q1 a7 r6 ^1 G        }
  Q6 ~# q5 y- m6 I' t" n5 S) E( _, T+ g+ t' V
} // end of class ProgramCompare
8 |* M$ D" ?( d' X. V8 R# w1 W$ A0 I! ^' H/ z
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
; k7 ]/ L) a- z2 R6 I* l) G8 k3 w//  ProgramCompareMenu.java    Provided by: DRS' q: g7 X- g1 w* q
//
% E, J# r# r- H1 z' m//  Calls AuthorisedUsers.java and ProgramCompare.java2 g" I/ J8 {' Y0 B9 k6 [: H8 ~+ u
//
( Z  r" E% c  Y9 ~4 }9 s1 J/ L/ A//  Driver shell for Assignment 2./ [# i) t5 P1 D  N. }
//********************************************************************' a) s7 U" F5 v( v% P

/ ^2 _' D' P  W4 Cclass ProgramCompareMenu% y  D: c  d5 K7 Z
{3 R7 c9 R- \- F' Q) [5 h9 I
    public static void main (String[] args)8 b( ~6 _8 V# b5 ]
            {
/ Z- z7 @" z2 z, {# \: G3 n                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
2 A5 V4 y# r# Q- b( N7 D0 ^                ProgramCompare reached1 = new ProgramCompare(); 0 b* o8 A  S3 g8 ^, l1 H
                AuthorisedUsers reached2 = new AuthorisedUsers();        ; W. W" ?3 D/ _
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
0 _2 @( b5 a: U$ |5 v* i. W# v                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
# s9 D- e% k7 N# }( I4 S9 o1 }        }
" t9 B  i; c5 @: h- j+ r}// end of class ProgramCompareMenu
8 t: ^% b( F* E8 y  Q' y) Z( L* s, y2 _$ R# T) B8 Y" O* ^
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
5 z' v$ w' e! t& F" [. y//          AuthorisedUsers.java          Provided by: DRS2 N& n$ M+ a4 e6 M; N3 [& o
//               
- T  i% J& u0 X( c5 B. s. \//         Program shell for Assignment 27 b: X: f; i  ^" l
//
, s% O: a; E* u. k" e0 x* A//         Represents facts about an AuthorisedUser
( {9 p# H2 ^& _2 u% p//********************************************************************
0 h- G* r5 k' k" O
3 R1 ]6 s  b; ~  K% g3 @7 R* Vpublic class AuthorisedUsers/ F3 b: P2 H$ j- `4 `4 T
    {7 _9 h) g+ l3 Q3 Z

" _/ u9 J$ u- d, q        //-----------------------------------------------------------------
/ j, o1 o' Q5 C" H4 ^        // Constructor) t3 t3 Y$ X6 O2 B! p5 n+ S" V
        //-----------------------------------------------------------------
2 }6 B, U0 ~+ N
8 l! e* w8 v5 H9 y; g        public AuthorisedUsers(), o1 B% C+ @$ a# I  S5 @
                {
! \) }! o' t# G! Z6 }                }0 ?( r1 a+ R% E+ w- D- @3 b$ [- `2 z9 e

2 M0 U# k1 `: \$ ^. ]4 w$ A        //-----------------------------------------------------------------
! E% a- x- _" u        // Method for testing that class has been reached# F0 _  s; u) q7 d9 L) |3 g
        //-----------------------------------------------------------------        7 @+ W) d* X2 z
        public boolean AuthorisedUsersReached(): x% N$ i& t) r* S: i" _: B/ q
                {
" q- W" S6 P/ C) l" U                        return true;                       
5 u, u; |% i9 C2 \! h                }3 V  I& \) e2 A8 o. k# u
                $ P) Q- U  _% D: ^+ o/ ?
    } // end of class AuthorisedUsers
) p/ K/ _) y, L8 J' _; H) A//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
, Z$ W' f) T" Z9 Q) l& pShanghai - 2007
, o' i6 ^4 P' u5 kAssignment 2
* r2 e2 V1 i3 }* `0 [$ FDeadline 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)' N- r' }' x9 X/ v
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.1 G* U8 X1 N$ S' n* Z$ w
The staff must be able to:& O0 C2 J, I2 i; Q) X, ^, {
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
4 ~' V, s; r' a( A' k3 u2 i0 b$ g0 \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.
2 L6 G6 R9 o& u+ v  a* V) M The interface should provide a menu so that the staff can:
+ I) q, D- T8 v. r7 P& w8 Q/ }a) Enter the names of the two Java program files to be compared
+ H7 G& R6 [  U) Y" }' i For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
5 D/ D! n) a: X8 L- y8 N9 h8 f** 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).; }2 ]: L4 ]4 ?. }" \6 }
BSA104 Business Programming – 2007: Assignment 22 j/ {) O3 Y* R
Page 2 of 5- }# b1 {; T1 f, [4 S
b) Print out to the screen all the lines of code that are the same+ }! v2 ]2 y0 {3 M# p) s$ u5 k
 Include the name of the file and the line number of the code being printed for each of the two files
7 n" {5 j) N0 l1 ]2 B8 bc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared% v3 R9 |9 }8 J! U& F8 u" I
 the name, username and department of the user
2 o" g+ F" p& i the statistics of the comparison
7 _2 B, p( s% i6 z6 D8 @- ^- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
, }1 j3 a, `- v2 j1 o; k1 _ the recommendation for further checking
) a7 ?; g# p  Q, O5 e- 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 h' v) r$ E) `, Q1 J the names of the two files compared
& ~+ q- X' \3 o! Y$ {) Nd) Leave the program (exit)/ t7 d8 G% j9 {2 R$ z# N4 l9 |/ W
The ProgramCompare class: (Total maximum 20 marks available)
" ^3 H0 c) \# k* x, q5 L/ x# Q: p2. 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)) n" w6 u6 v7 P' |
a) provide an error message if the files are not found or there is a problem opening them
$ U- U1 o( r% `* wb) compare each line of code
) [% f+ W8 n# k9 `! oc) print out the lines that are the same
. X- C* A8 h5 a7 ?( m# e3 o: J  Fd) count the number of lines compared / lines the same( b8 r7 O2 o0 o* n$ x4 G: S( m& n
The AuthorisedUsers class: (Total maximum 20 marks available)' w# l' x2 [* c
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)2 ~0 j7 Y* {2 s% `
4. Provide methods to:9 C! m9 ~( H7 e+ K
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' c9 S# Y' c+ q
b) return the name of the authorised user  o; e  s9 f0 f; O
c) return the name of the department of the authorised user$ H( n6 x& T' m" h; f
Individual Data (Maximum 20 marks available)6 O! r" j4 x: S. u
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.+ p' i" T5 @. l7 D1 i" o& B
Documentation (Maximum 10 marks available)
% c8 j3 |! {  ^! ~2 G6. 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.
  Z! R' V1 ]. v: KBSA104 Business Programming – 2007: Assignment 2
7 e% q) A0 Z0 o* L& C- p3 gPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了- K3 c2 K4 \. x. C  P: |5 N* {, Y/ P
不过你要翻JAVA的类库说明。你有下载没有?
" U8 P0 ?* z! e9 x2 l% t; @查询关于对比的函数。貌似关键字是contrast,还有compare- C) N" J1 h( |7 |% q1 X; K4 u" I

6 d. \+ f* a8 ?: E. S3 F[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
6 R: m' Z* O1 i4 t" M痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
. {! p( [* S! Y& H: z可以下载到的 是 jdk-1_X_0-doc" c+ c3 s+ G6 D2 P+ l
+ B- u( \# O) ]0 d: A
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-23 11:18

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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