找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1041|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急% c8 v N ~# Y* a 4 K% M* T1 R3 \$ a& l: R
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************6 m6 f  U. Y3 ^
//  ProgramCompare.java         Provided by: DRS
$ S! t% c3 g# d; p+ ~//) X' A0 s# h5 G  n3 g/ m
//  Program shell for Assignment 2
  B# A9 Z9 u6 M* K//
) Z0 N$ q: v0 \# b//  Compares two text files line by line" X/ D) Y% f; l% d( w% u1 X0 {
//*********************************************************************
0 G7 K8 U: L" E. d# m+ Z6 ~8 x+ O; u% R
import java.io.*;2 F0 C+ y7 f4 X2 R# w% k' H

7 t  P2 [! A3 I' H" Wpublic class ProgramCompare
9 @1 f. s0 @0 O7 O9 z& B8 w9 ~{
+ ?  k$ d, A, R1 P# c' m        //-----------------------------------------------------------------/ e5 D6 E9 O7 J5 J; ~$ y: ^$ k
        // Constructor7 s' o9 U, H  L6 z
        //-----------------------------------------------------------------
0 l) v- d: h( ]" r        public ProgramCompare()
4 U/ r5 N7 [3 @8 I        {, U4 _  t! a2 M5 \$ O3 \- Y
        }
$ E) ~% N9 A/ N' X1 j3 O4 T' G! f' Z, s0 o& ~, V
        //------------------------------------------------------------------ r) t1 |) d& |6 L/ u7 A' m" J6 l
        // Method for testing that class has been reached
  h$ D  G( m3 P  k3 k5 D        //-----------------------------------------------------------------       
0 A% D/ W& ~& i! ^( s3 p6 Z
0 l  O/ k4 T: t- p. j        public boolean ProgramCompareReached()         # W. Q+ S" a/ O
        {% J3 \* J% `3 c: z
      try " N2 A  j; ]7 H
   {        
; t( y; f" M/ y  Z% m6 Z                        " N  w5 `; P6 n% c  e0 d% I/ s
                //********************************************************************
2 v8 s  {# R) ?0 B# ]; z                // Try-Catch Statement is used to handle exceptions - such as file not found 2 }$ ~1 _! F6 F7 B/ J* `! ]
                // Reading the files will need to be placed inside a Try-Catch - just like this one!/ L+ ~. ]. ?, J1 r2 {' e8 A
                // For more information see page 534 of the textbook
% @5 Q( H7 P4 a, s                //********************************************************************5 M8 G1 T7 L# m1 p; b( s3 ~
                     2 J% e: d, R# L0 M5 }: c
        }
" v: ]6 P0 W; N( v& H* O9 W             catch (Exception ex) // Exception caught here and message displayed to the screen
2 g  t; O8 b6 {; R" c7 v! _          {
) L9 H1 M& S5 t7 E+ e                    ex.printStackTrace (System.err);
, I& n# f) Z* t           System.out.println ("Error message goes here"); // Replace this error message with your own            e# f5 R( p* P: X( d/ V6 z
        }4 |. B! x4 ]) l! W. Z
                return true;
6 @5 ?0 k' g$ r+ _9 n5 v- h        }
# A3 F; O3 \) F1 U  G% }  X0 K6 g" ]# {+ k8 f
} // end of class ProgramCompare# ^/ P- r5 z9 `1 t$ b5 H+ g
1 W" ?+ b2 k" z. h3 Y  ?8 ?% M
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
/ J5 c# D4 \4 ]5 B//  ProgramCompareMenu.java    Provided by: DRS
7 S. l1 C- c) B/ |8 Z1 w* k4 J//
" K5 p. d  O# x6 h' T  B% J, E" X//  Calls AuthorisedUsers.java and ProgramCompare.java
  E( t% v0 b$ i6 l8 o  o//
0 L3 ?, I# B2 C. h5 J" C+ t//  Driver shell for Assignment 2.
  Z' i9 n4 A2 y8 L# X4 B% O" D; h4 j//********************************************************************
2 \1 l: R7 o* C5 [- V  s' C8 J' h* D. R( J% R. @
class ProgramCompareMenu
, ~  X# A6 P3 n3 F) i+ p{
( U/ J3 v, V. Z" p/ L* i  ^4 v+ N+ @    public static void main (String[] args)3 U; u0 O, n7 j# Y: b7 O; X
            {. D  `" C2 ~! J, T( P% `
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable2 I* z; |# k2 Y, o+ a8 z- c
                ProgramCompare reached1 = new ProgramCompare(); / p# d7 u/ v  b& w- h2 @
                AuthorisedUsers reached2 = new AuthorisedUsers();       
9 o, {$ N9 S9 _/ D                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
8 y9 l7 K; }3 J2 k                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        7 U6 F" P; s& |4 w( ]* F
        }; q3 x& K# M' `* w3 Z/ A2 a
}// end of class ProgramCompareMenu
/ K0 `1 B& c1 k. T( |; m$ u- |5 G, O
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
9 {( l, O# J6 r6 m' r  o  ]//          AuthorisedUsers.java          Provided by: DRS9 n6 R: T. K4 K3 r9 A* ~6 H8 N
//               
- q* |% {/ v5 Y5 H//         Program shell for Assignment 2
+ B) O7 M& ~; V& p//
! V- l% Y: C+ i" v; ^5 O9 ]//         Represents facts about an AuthorisedUser3 G: \0 U. I4 I# g: ^& Z4 i4 U
//********************************************************************
: _" Y' m% B8 j2 P% L' \
4 i, p" |4 g; f# y0 G; G) j  rpublic class AuthorisedUsers( g) x$ j+ H$ c. A6 J
    {8 ^% b6 ~4 k. n: k- D# }

- n- i* n  s' V5 x        //-----------------------------------------------------------------
. l/ C, q, z# U        // Constructor
& [: y; X* A, r; y7 K6 L        //-----------------------------------------------------------------
- t* T8 t; a9 ?/ `/ A" K. |7 s' Z/ O6 p
        public AuthorisedUsers()
( s" A" I# ]" E. }$ E+ p2 i                {0 R9 y! L0 v% l! j
                }
3 A8 j4 t+ R8 y7 [% D
, b: ~9 M8 Z) x( B( J        //-----------------------------------------------------------------
6 C1 c' V$ O/ C! X5 ]        // Method for testing that class has been reached
/ {( w+ l2 T6 U/ z3 M        //-----------------------------------------------------------------       
* l9 Z/ f  R/ v$ w2 e  r        public boolean AuthorisedUsersReached()) ~" [* m& @4 T; m, V6 m& l* H5 F2 H
                {! n0 \4 n) s0 X5 t
                        return true;                       
. J. ~* p1 X$ q# v: T# N: H                }
! l1 _5 X1 u; S, ?1 o0 ?               
2 W, `7 e, h2 T3 }3 ^$ Q( O/ G    } // end of class AuthorisedUsers+ u2 ^" ]- m  c
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming( N9 G/ {% [5 n( @
Shanghai - 2007
8 O9 b+ E$ R% G5 G8 Q6 mAssignment 2
( }7 a, g/ x0 `$ C* vDeadline 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)
8 j5 x  Q: f2 I; C% _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.% f7 F+ d  n- J  ]
The staff must be able to:' m6 Y- _& J, O: K/ L9 Z' R  ^6 {
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.' _, h3 a2 j8 A5 d
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.
7 V0 R$ I* |8 {2 N2 g/ T& x& a The interface should provide a menu so that the staff can:
) f+ Q, y& A! o- G; }7 C1 t$ Sa) Enter the names of the two Java program files to be compared# e0 J3 t8 P9 i5 z
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
5 A- O* R- _' J7 p1 }3 q0 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).* K2 V( P! k! T' k
BSA104 Business Programming – 2007: Assignment 2
- f/ o* a. s+ e/ M/ TPage 2 of 5% O5 Y: e" H! a
b) Print out to the screen all the lines of code that are the same; t2 M) C7 g2 U" y8 X+ X" L/ f
 Include the name of the file and the line number of the code being printed for each of the two files4 K7 Y" Z9 E) v
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared5 N& Q8 ~! l6 f1 `
 the name, username and department of the user7 U! T: u4 Y& e' s  u# ^
 the statistics of the comparison
/ M1 }8 i3 x. l8 @, m5 v% Q- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different+ T  a; r# ?0 r8 D% l+ G
 the recommendation for further checking
: l0 s# |( g' K8 D9 P5 J2 k- 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
/ T. |5 ^3 c& n/ j) Z. h+ a the names of the two files compared( H2 w& |: ?3 r( S9 I
d) Leave the program (exit)  t7 W, u, s, g" B$ c+ ~3 E
The ProgramCompare class: (Total maximum 20 marks available)4 r: R. R& m0 l& M
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)
7 h, K5 I1 b2 x. J; L+ W) E! ra) provide an error message if the files are not found or there is a problem opening them
* l0 ]6 |/ x4 E$ x8 [7 Q6 kb) compare each line of code
' R# t7 b3 S  ]( Lc) print out the lines that are the same; ^$ l5 D! ?: I: H; g# P
d) count the number of lines compared / lines the same. q/ f- N- N; t  Q
The AuthorisedUsers class: (Total maximum 20 marks available)+ v  D  P2 U& E
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 \# F0 V" M. f  y+ K
4. Provide methods to:
& ?, m0 U; {1 r8 e( l8 t/ ka) 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& g6 @0 d* R- x' Q; D) e0 f
b) return the name of the authorised user- d9 d0 w7 I( ]9 o
c) return the name of the department of the authorised user
( [/ Y! ?* \: p" a+ JIndividual Data (Maximum 20 marks available)1 f2 \0 S' _! j
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.# h- o3 X# Y1 `
Documentation (Maximum 10 marks available)
$ J0 m3 z* K) F! d$ q6. 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.
* k" i$ F! z* Z- ]: C% S. nBSA104 Business Programming – 2007: Assignment 2% b4 _8 S/ q4 c7 a
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
& U+ ?( ]: J! [4 T& i% O2 |. F不过你要翻JAVA的类库说明。你有下载没有?
  l* Z9 o( ?! H查询关于对比的函数。貌似关键字是contrast,还有compare% |6 \: F$ o2 t7 G. B( O
* y. K- V" ~  j1 [# V# T, n. T" f
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -4 Z7 i+ m! h& z$ B1 ?# Z8 A
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。2 R# B5 Y6 k( Y8 W5 P
可以下载到的 是 jdk-1_X_0-doc3 f8 I2 j1 B  H+ I

2 L0 h& `6 c! L9 g7 z[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-13 07:11

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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