找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1694|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急3 a9 z. S2 ^2 W 1 ]# `; }4 ]8 f# [* 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 | 显示全部楼层
//*********************************************************************2 h8 t4 g/ \* a- |& E( b2 K! V
//  ProgramCompare.java         Provided by: DRS
0 q8 i0 D( W; x0 l' C//
" A+ r5 b: J& E, v! u//  Program shell for Assignment 26 N) h. I) M  z7 G. y
//+ B* P) |9 J: \1 t8 L! F; W
//  Compares two text files line by line
8 D- u( e+ B7 s. }5 _//*********************************************************************7 B$ O, L4 |" V  t

( j* J6 }7 R" o( @import java.io.*;7 a1 H' A, c. y1 A/ e: {% X6 V

/ P) e3 C! {0 B; M& ]public class ProgramCompare" [' J7 r) x4 ~2 |4 U7 w2 ?/ s
{
7 M, _# x3 p+ a) Y        //-----------------------------------------------------------------/ \) l* _1 D3 A  y/ l" _8 g
        // Constructor
# p6 a) p7 [2 s3 O* B        //-----------------------------------------------------------------; J& M$ F2 x3 w/ {7 l$ V' }
        public ProgramCompare(): u- q8 \8 F% n$ j. k: r/ d
        {
9 U! h/ X4 |$ V8 L$ }/ M) H        }
7 W; J, ?, Z, m' I# n$ s$ e! m; H2 \( x1 d$ X
        //-----------------------------------------------------------------
" i& T  M# @& b        // Method for testing that class has been reached4 \# T$ i8 S4 Q" y7 x3 Q
        //-----------------------------------------------------------------        4 }0 n9 H. K5 W3 f( r8 V8 d

7 [4 S. s7 t. E" E: {% W        public boolean ProgramCompareReached()        
8 i& L  O! f' D! Y/ x. U        {& M: _0 S: d8 q0 G4 J; r
      try
8 L& ~3 c" ?  x5 B: U   {        
" J4 F& D, n* j                        / g+ }( w6 S: G' u' H# i( C1 {8 y2 x
                //********************************************************************
% w. r& w0 b7 y4 L# j$ G                // Try-Catch Statement is used to handle exceptions - such as file not found 6 V$ P; p' ?( x5 U7 n+ ]
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
) X0 \$ Q# q, Y( ?7 c; N  w                // For more information see page 534 of the textbook1 i1 t' H& ?% u3 ]
                //********************************************************************0 W# @) u# ~0 }8 d" H7 ^
                    
# D, c# m% e# M4 l# i        }
( e1 R2 S6 }) L' L% b! W             catch (Exception ex) // Exception caught here and message displayed to the screen
9 ?( ]7 i; a9 ~2 f" O/ P) \          {
' C" k. @8 Y8 C                    ex.printStackTrace (System.err);
: ^* U8 k( B  m           System.out.println ("Error message goes here"); // Replace this error message with your own          ) r/ J8 U1 g- O2 w2 ]
        }
4 }. k/ D4 c' t+ F( V                return true;' [2 y1 _, O) h  I( ~; @$ ?% K( Y
        }
  F3 S- P* p" T+ R6 Q
" `+ M2 L& m% X} // end of class ProgramCompare: e  n4 s0 R9 E, S) ?

8 L) x' m. I; A//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
- D) g' C4 g' U1 _//  ProgramCompareMenu.java    Provided by: DRS
% i  x2 x, F4 @' l//
' E- x; b6 ?: E% W1 ~2 U9 J//  Calls AuthorisedUsers.java and ProgramCompare.java8 x5 S& M) j  ]. m- d
//; E; ?4 o6 R; l: u% l
//  Driver shell for Assignment 2.8 k% H, d" ^5 Z: h. a" q% `+ N
//********************************************************************2 T! ^: s: ~  g+ q( B  w
. D. K- B5 L1 `% H
class ProgramCompareMenu
3 e6 K% P, H/ M& X: @, U$ k; S. q2 e{( U6 X* h0 [; ]
    public static void main (String[] args)8 s7 X5 `# i0 D: c
            {' W  n/ ?0 y- z- P
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
1 _: A6 U. I2 X9 J                ProgramCompare reached1 = new ProgramCompare();
/ I, T- Y$ d: C& T                AuthorisedUsers reached2 = new AuthorisedUsers();       
& J2 I) t) B" v& [2 R9 G                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());7 @0 }3 I' ~2 q9 j+ f
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
- e; }  z9 j) O        }
" x- k7 Q9 x  l  J}// end of class ProgramCompareMenu
8 N9 G9 r- H9 F( D' n
1 n9 f- V. l1 x& J8 t6 ]5 E//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************- K: ~: F! X  x# ~9 W( g- q* D
//          AuthorisedUsers.java          Provided by: DRS
0 ^% C, r+ k# h//                - {2 \+ g5 }) f+ a; D$ h' s; T
//         Program shell for Assignment 2$ Q) L- Y9 Q; i8 n$ C/ I
//
6 q& L$ v2 n& y! d0 ]: k. C//         Represents facts about an AuthorisedUser
! ^* i% ?% o; a$ m9 o4 U# @//********************************************************************' x% t6 t" T- T: w
: N' ^8 u; m2 ^* n) C
public class AuthorisedUsers2 s3 {% K2 J  D3 @
    {! f7 _7 k5 w0 L. T7 t" U9 w

/ D  [! z) b; Y        //-----------------------------------------------------------------3 I5 o& B2 ]; i/ V' ?, m! V
        // Constructor
! v- N- t, L6 p- c# f        //-----------------------------------------------------------------4 D( A* \- B( s+ \% R

5 h: `3 J9 \" ~; ~        public AuthorisedUsers()
5 ?/ n* d, i$ d' W4 U( T                {
" [$ X+ ?! M7 f7 Z, o                }
% e1 K9 q$ i; ?; S. k4 r  H
: t" H+ ?' X- |  r        //-----------------------------------------------------------------+ r3 ~- M0 W5 X0 {, ~: v
        // Method for testing that class has been reached
) i+ I# U* P0 \        //-----------------------------------------------------------------       
+ M# K* ]: x5 t" F* A0 k        public boolean AuthorisedUsersReached()" k3 n  t/ {" L# g1 t9 u$ }
                {
. a% B7 K4 l& E/ s3 ^                        return true;                        . [, }. o0 c- Y$ i% K6 z7 H
                }
3 Q$ G9 \% C6 }  N) x               
7 `! l4 s- f! P6 f1 C, A7 u    } // end of class AuthorisedUsers6 B/ L5 [: W. C6 e
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming  ]3 G1 ~6 N" {3 Q
Shanghai - 2007
' g; S( s( l/ y& C5 n) |Assignment 2& @" X% a5 [) J$ I
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)
' }6 ~: W1 a7 o# v% P0 t) _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./ U) q; d9 M" n7 D- j
The staff must be able to:
$ M8 @! b6 ?2 L3 h Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
7 \9 y9 M; C1 u1. 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.
4 t+ i) N$ b4 T# d8 ` The interface should provide a menu so that the staff can:! q) R: L# A2 N
a) Enter the names of the two Java program files to be compared
$ M9 U" Y1 F$ G9 y, e% Y For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
& G. I( G, x/ ^* a+ G( {** 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).
- c4 i& h' u: C" j6 a$ \! s4 |. d& H6 JBSA104 Business Programming – 2007: Assignment 2! l3 L7 ^" s; w. E$ `: ^, Z3 f
Page 2 of 5
  k- i, H- z4 V+ J+ o; }b) Print out to the screen all the lines of code that are the same2 W0 Z+ ?4 |% _& }0 X% R; [* J
 Include the name of the file and the line number of the code being printed for each of the two files
7 E0 k" p1 L' D* m. Y3 Yc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared  y1 x! _( `+ G# P- e
 the name, username and department of the user
+ V7 L# `% B# u% {% h the statistics of the comparison& K' t( p5 N' j
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different+ x6 h; p" s; V+ a& z
 the recommendation for further checking
3 N* `1 f9 R& h! B0 ^- U) N& `( r- 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
0 e0 ^7 |" R! _/ V* l6 C. ] the names of the two files compared9 D  u& V, Y- R+ n7 w0 u; Q& g
d) Leave the program (exit)
3 t& `  [3 q/ O2 s+ C  ZThe ProgramCompare class: (Total maximum 20 marks available). I* {. Q* K. n, _  u
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)
4 C6 \" L8 k7 Ka) provide an error message if the files are not found or there is a problem opening them
) i8 _$ \% n2 V# w5 f4 D2 I8 D0 Yb) compare each line of code
5 G$ v% v' n8 H9 b. bc) print out the lines that are the same. e" w+ c+ O6 h1 `* r  V' m
d) count the number of lines compared / lines the same* x' ^/ Q# Z" U* i
The AuthorisedUsers class: (Total maximum 20 marks available)
5 v0 w" o3 J8 f) O# X2 {1 P  c& V3. 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)0 N# r& u) u0 I: L9 w3 F
4. Provide methods to:. Y' q  i- S' i
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$ a) O8 u, O9 N/ `# I: s- r
b) return the name of the authorised user9 d6 u0 _4 s  E
c) return the name of the department of the authorised user
& G/ Z2 l* A; s9 c* w4 r; g; a2 LIndividual Data (Maximum 20 marks available)5 E9 ?( Y8 u$ z! _& D3 O( {
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.: I; X: F% a, i5 u+ f, l
Documentation (Maximum 10 marks available)
0 m  h) v7 `3 c" W4 h3 f! }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 b1 ^( V' _5 D) }- p( H$ i$ }BSA104 Business Programming – 2007: Assignment 2
' `6 d& L! H1 g, I+ W: h2 xPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了9 G  M, e: M) J: W1 i
不过你要翻JAVA的类库说明。你有下载没有?+ H' K4 `4 Z' r' e7 _, t* V
查询关于对比的函数。貌似关键字是contrast,还有compare
# P. z  q8 b& _2 ~5 {  r- f! P: K9 f! F
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -3 t. e+ V: z$ g/ {2 u% t5 Q
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。3 a* K4 E9 i2 X7 }* q7 E
可以下载到的 是 jdk-1_X_0-doc! x7 _; V5 v: V& a/ G) M
8 a( W* c/ |; |
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-3 08:01

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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