找回密码
 注册

QQ登录

只需一步,快速开始

查看: 956|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ( ?5 r Z% t" ]2 m2 t% L. r9 ]" W% B5 C X
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************3 t+ u7 c; ]( F1 U# A
//  ProgramCompare.java         Provided by: DRS. N5 ]8 D0 S! {: u# V- y8 z. k4 \& I
//
6 s  [$ u+ }7 F$ Q; U: a//  Program shell for Assignment 2
* m, Z. \1 _) K' B1 Q, P- x//. ^7 \+ g5 A" x# G8 q4 H5 Q
//  Compares two text files line by line$ o1 Z& G: q5 W/ X; {  k
//*********************************************************************
1 c# M- h2 L' U, x+ _/ X5 b5 b# z) d9 k- \, e
import java.io.*;
6 B$ d; X; Y0 i1 S0 O& J& f2 O- e+ V) j; F4 M' R7 Z
public class ProgramCompare2 b; E7 Z7 Z2 M) l9 Q- a7 C/ W
{
" E1 `: y+ x7 m6 O- r$ r  R- l' n6 c        //-----------------------------------------------------------------
% k* y8 H0 p3 o# c, L5 Z! S4 y        // Constructor
2 W, R! M" j2 ]; g2 |        //-----------------------------------------------------------------6 I" U/ ^+ ]1 B. H  d; e# B
        public ProgramCompare()
/ a3 x7 w$ y) r3 c" Q" W* m! E        {9 H  L/ L$ n- E  ~! k$ B9 e
        }
( q0 e3 R' R7 t: v2 p' ?- [# y6 p. A  p  p# W9 i
        //-----------------------------------------------------------------8 V6 i' T9 O- \) s  y9 q9 U
        // Method for testing that class has been reached
4 |: R( i1 }$ B4 o        //-----------------------------------------------------------------       
4 H. z: G& A& Z0 H2 }9 t$ x: y* m8 s* [6 G4 Z7 H# V9 e, d
        public boolean ProgramCompareReached()        
1 C" w4 X& k6 D5 u. |# @        {: R" e) k/ L" u, g) g: u5 a3 v
      try
4 z6 [; d5 O7 E1 T. U# m& H. [   {        
! K5 e: f4 [0 N% s. Z' v                       
6 x2 a9 Q; E( f( s' Q                //********************************************************************- E, y# a2 g# X# h& o
                // Try-Catch Statement is used to handle exceptions - such as file not found
; f7 A" K( F- U* W& T                // Reading the files will need to be placed inside a Try-Catch - just like this one!
3 s4 a- t# b5 z& H' T3 Z                // For more information see page 534 of the textbook* o- ^7 h7 {, h0 L0 C5 ~" s: }  C
                //********************************************************************
: @8 l& `4 w6 R) `9 ^                    
2 p- u* w" w5 Z/ ?' y        }3 s, `% b) T0 M$ q6 f* O
             catch (Exception ex) // Exception caught here and message displayed to the screen - O9 u) o5 C: M' }) Z
          {
9 H% w$ t$ ^5 d) ?                    ex.printStackTrace (System.err);
3 l9 C1 e' W5 [  _) {5 ~3 G           System.out.println ("Error message goes here"); // Replace this error message with your own         
, n- b1 Y) d7 B% Y7 O& t2 P  O8 t2 {        }2 C3 e# V  }  Q+ O
                return true;
4 g: I# A% K7 _        }
' r$ }4 x2 o1 S1 v3 R4 C
' l! q6 N. m6 j4 I- l2 Q} // end of class ProgramCompare
' ]2 _/ f$ l$ L$ p( K4 [
8 L' F4 g* w2 S9 x+ J//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
8 s! K8 Q2 k1 i0 E" M# x" x//  ProgramCompareMenu.java    Provided by: DRS
. ]- z2 I8 ?3 S4 v0 }//1 P7 i: h9 @8 ~( ]
//  Calls AuthorisedUsers.java and ProgramCompare.java
; r8 s& u2 u8 X# N8 _//! z0 Z. b4 Z% a9 o4 v5 q0 A
//  Driver shell for Assignment 2.
& o* v$ o8 ^0 ]//********************************************************************
' n3 ~8 d; _0 d' a1 Q9 u9 [, O9 F, m$ Q9 G
class ProgramCompareMenu  q5 b* b2 d, [$ [+ O4 Y
{
/ I& ]  C( G. I: N+ [# b4 M& ]    public static void main (String[] args)
% j  X! @$ S8 m. p            {+ B4 {" Z, i3 F% K
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable* O* i' ]4 c& ^) ?0 S! F' \6 G
                ProgramCompare reached1 = new ProgramCompare(); % `$ b9 p" P- G  X( M
                AuthorisedUsers reached2 = new AuthorisedUsers();       
! h. p7 I$ `: D                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
- O5 k+ V: N' a3 G8 m/ y/ d                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
/ p2 l1 |5 ]5 w7 l5 l" Y+ }        }
9 d; ~( x0 `  g2 ?}// end of class ProgramCompareMenu+ Y$ R5 S5 F  r1 a  @3 b

" [+ \$ r( d, E8 ?7 U% l8 Y//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************) \$ @* i/ {' P  X, L
//          AuthorisedUsers.java          Provided by: DRS1 o3 y) Y7 _0 j
//               
$ K0 }' l) c0 y5 _' R# P//         Program shell for Assignment 2
, ~% o8 a, j; e1 t. O. [2 i! T//
  V$ }4 g! r  P" J2 `//         Represents facts about an AuthorisedUser
( _) P) o/ F% N( @9 E7 F% Y9 y8 b//********************************************************************6 K6 _1 Y+ f1 q9 _
! Y& b& ?' u* A) }, h: x2 |" q3 M
public class AuthorisedUsers
0 U* {- G, ?  w8 x  W  }: i    {2 `$ h3 [& I/ P4 Z! G& b/ H- `& m
- \+ }( D9 I  O9 E6 @0 ?2 X7 e; U
        //-----------------------------------------------------------------
! H; A$ @( h2 s        // Constructor
& A. `6 j) E+ m( u1 t2 i9 w1 z1 \        //-----------------------------------------------------------------' O7 q$ a; q- I, z
. X; Z& }' o* y, L
        public AuthorisedUsers()/ k5 v6 Z+ v8 H
                {2 D$ f* j1 C8 [, w: v9 f  W
                }/ K# E8 Q# o0 L' Q

( {% Z2 M4 b, Y, t2 e/ {        //-----------------------------------------------------------------4 H. M8 e" h! L+ p, [2 K5 h, J
        // Method for testing that class has been reached
$ j* N' m6 o# F        //-----------------------------------------------------------------       
4 i8 b, [, F$ E        public boolean AuthorisedUsersReached()) ^) t$ q$ r3 O+ \9 R6 O
                {+ D5 R( H# X: V+ \5 [1 g5 Q
                        return true;                        + p+ y; `* V; n* B
                }5 I& A% L& s$ j3 @, K
                7 ^( E) a) Z- ?  M( D! \5 y
    } // end of class AuthorisedUsers
5 U: H* b3 }9 x8 v8 f% r//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
$ L1 m- L1 U0 _1 `5 WShanghai - 2007
2 g! s; q$ \  f- ~) O' ZAssignment 23 }  D7 b. N; i8 T4 R& W7 D
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)0 b. Q$ D8 K3 [
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.
+ d$ S/ N/ Q5 z9 MThe staff must be able to:/ O( Q6 Y6 `( i2 o8 d' |
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
3 z5 r  P+ A0 f9 L( ^; Y3 e1. 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.
, Q) E! G' E: i The interface should provide a menu so that the staff can:& f* i- `- ^$ V( p! k1 S; M
a) Enter the names of the two Java program files to be compared0 d! ~0 c$ A6 I( y
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
' E0 b0 e) ~$ m9 J+ ^& I! E  t** 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).+ x: y: S1 a* j2 g
BSA104 Business Programming – 2007: Assignment 2
/ ]5 n3 f# F3 o3 x) k; PPage 2 of 5* @' Q' P' q+ m& i4 Q
b) Print out to the screen all the lines of code that are the same
1 H- g9 r  g& e Include the name of the file and the line number of the code being printed for each of the two files% U& f0 o4 K0 e# _" [
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
& U7 s+ A( x" q2 L4 _5 |/ [  f* e the name, username and department of the user* D' x9 h  B2 m( Q) \
 the statistics of the comparison
0 }) h) v/ `+ g- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
& f6 D2 i& x# _, `5 Q( @5 Q% I' | the recommendation for further checking
* c. o4 N8 u1 j! {7 L7 }) q- 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
3 r9 \5 c5 k  u' A6 ?0 m9 J the names of the two files compared4 x$ f9 u7 c8 a! O6 r
d) Leave the program (exit)
$ n8 G$ D9 A. j0 h9 Q# X% ^The ProgramCompare class: (Total maximum 20 marks available)
( ]. W9 b0 {( D2 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)
6 Q( g) c, K3 [+ M! _$ Ea) provide an error message if the files are not found or there is a problem opening them
) a% o, l2 H6 ?6 h; c) B& M- K" i, p7 Yb) compare each line of code
8 @" S& C( X% p* J1 D1 Kc) print out the lines that are the same
" s0 S' ?( Y+ td) count the number of lines compared / lines the same/ e; T6 f7 M' j" p; a3 o
The AuthorisedUsers class: (Total maximum 20 marks available)
  d2 ?2 @# c! L5 F4 r) u4 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)
" q4 l8 v( J* V; ?. D4. Provide methods to:( g  G& g, ], E7 Q0 H; Z& V
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
( Y+ h1 ~3 ^, [  M( D9 ab) return the name of the authorised user
/ P5 ~* i& R3 O9 ]0 fc) return the name of the department of the authorised user
$ ^; y  O1 g# eIndividual Data (Maximum 20 marks available)
% q  j. d$ _' k; L5 ^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.
. B0 _- \( f$ Y+ e9 eDocumentation (Maximum 10 marks available)
% _) m3 w! E6 }6 _/ _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.: V" |7 T) w- N3 c
BSA104 Business Programming – 2007: Assignment 2
0 \" l# t) g* O$ |Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
1 J$ c, n; E; ?; R" E8 q不过你要翻JAVA的类库说明。你有下载没有?$ Q1 Y1 L% P/ L$ Y: s
查询关于对比的函数。貌似关键字是contrast,还有compare
' E7 n9 V3 o' r+ @4 k/ J: z
: }/ c( J; M; \[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
7 c" X7 \7 Q, c2 X( C痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。8 `! |# h: }. D# G! {* `8 B$ }
可以下载到的 是 jdk-1_X_0-doc
1 H/ }7 y6 K' o% P) b' q+ ^  R# L9 I6 i
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-21 07:40

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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