找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1435|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急2 x5 @. V2 D ~+ w$ _ $ F# C+ C- D9 `* f4 W6 d8 W. 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 | 显示全部楼层
//*********************************************************************
$ y! j9 E4 O+ C! I! R* q% T$ E$ k//  ProgramCompare.java         Provided by: DRS& G! \4 a( z  g  w' U9 ]# G
//
) M1 `- H; k$ P//  Program shell for Assignment 23 V9 m' I, g  E
//
4 {* A1 ~# L; ^9 o( b- p2 l//  Compares two text files line by line
. v/ a9 Y/ n7 Q% i* D& U//*********************************************************************2 y9 d' n, @* g' C5 N" L
" W# w) _7 \# y* W
import java.io.*;
  n" o* L& |4 `0 Z
8 W9 p; z1 l2 e" n( c( m+ p! Xpublic class ProgramCompare
+ {1 N" n8 w' e) P2 b/ J) Y{
' r4 k3 X! G! k* B+ I! i        //-----------------------------------------------------------------. P5 k+ d1 W1 ~" [1 H0 C
        // Constructor/ D9 R' p. c# U! J2 ]  T! f$ e
        //------------------------------------------------------------------ Z" n7 ]2 b; r* a% h- A! H% M# _  ?' L
        public ProgramCompare()4 I% m3 ^; h9 S! l' R( S
        {" R: b5 n0 G' x  y4 B9 M. m1 I' F
        }
4 M& [: X& G5 r3 G) G2 c4 X2 e3 J# r: R" y' y5 x& V; p
        //-----------------------------------------------------------------
) T9 ^, P$ q! a# g" i" K- P1 b# H        // Method for testing that class has been reached0 b. Z* Q1 L- X4 P' e
        //-----------------------------------------------------------------        9 [( K% P# O2 _

+ ^' O! Y, x, x$ @- N        public boolean ProgramCompareReached()        
& Y3 k; s/ R2 N: e  x# L        {
' }) U3 x+ O6 U: f3 ?5 B" Z      try * e+ n2 ]5 m1 C3 P1 a0 n2 e
   {        
1 j% g- `0 d) z2 m- N8 m) ~                       
0 J& F5 L* w8 D- a: a                //********************************************************************
+ h, z4 t1 H7 C  x  ~                // Try-Catch Statement is used to handle exceptions - such as file not found 9 r" q5 e5 B$ c# l
                // Reading the files will need to be placed inside a Try-Catch - just like this one!9 y. b" T/ m3 a6 n
                // For more information see page 534 of the textbook% u3 h6 V& F9 ?# D. H7 ^
                //********************************************************************8 x: d' \. D$ X% h
                    
) L& \8 O9 W1 N4 ~0 q, L; D' b        }; D# h- W  M* }% o( M6 h0 N5 Z) q
             catch (Exception ex) // Exception caught here and message displayed to the screen 7 p& l; U  Q8 h3 e8 z% h# }
          {0 z5 ~! R# P  }& O7 F4 U
                    ex.printStackTrace (System.err);1 m3 {& S' J8 s" Q3 u
           System.out.println ("Error message goes here"); // Replace this error message with your own          0 w; Y6 S, r5 M% V# w7 Q
        }
) N4 ?+ b5 Y9 W                return true;2 p2 k# \: [3 n  H! m% G- {& H/ o; \
        }
3 b* T- ^  I# M: v; c; {+ I$ |) e$ A* S- v9 G& B1 X8 O: H. f- Z
} // end of class ProgramCompare
) t  v- F0 Q/ M/ \% E, {* @0 d: C4 [# o" H
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
0 @6 i9 M2 C( b) j6 n& J//  ProgramCompareMenu.java    Provided by: DRS
  ~) m  p0 z  }, M: m4 P( R//9 Z* D, h+ ?9 s% v4 P
//  Calls AuthorisedUsers.java and ProgramCompare.java9 s# U' K  Z, I$ D
//0 |# H7 k1 s# e7 |: R- {" Y
//  Driver shell for Assignment 2.
) W8 j; f" r; A7 i6 M) J8 W+ I5 b//********************************************************************
2 }+ [  n  v' a; Q8 |1 \2 H
7 k* e7 g+ N7 r# Wclass ProgramCompareMenu
4 `9 D1 h  n. q{7 n3 y# g9 L5 l2 j( h7 d2 r
    public static void main (String[] args)8 i' e) e1 Y( i/ o+ Y7 K8 L! |
            {
% n( {' t, H) |) B) V3 |                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable2 m+ l0 U" X  U6 W3 X
                ProgramCompare reached1 = new ProgramCompare();
( i5 K& E& P* {% x6 A                AuthorisedUsers reached2 = new AuthorisedUsers();        * n0 c/ W$ N5 L. h, M
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
6 l' g+ }1 K4 t- N                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
1 H# f6 ~, A8 N; M4 V        }
( o8 |7 z4 |4 a}// end of class ProgramCompareMenu& c0 F) }3 m1 O8 J* l4 `# @

8 Z* ]( B  [7 ]- I. r: a//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
- [8 m2 P" ~7 Y+ R" l//          AuthorisedUsers.java          Provided by: DRS7 ]4 m- A/ A+ \7 @! F% w
//                ! W6 f) p& ~9 X- C; Z2 [
//         Program shell for Assignment 2, S% o3 {8 W  c. M8 n7 _
//
9 p/ g$ r* g( c2 V/ _; g0 m//         Represents facts about an AuthorisedUser* p7 Q. @6 b9 N8 a4 l% O+ Q/ V' ?1 z
//********************************************************************
5 R$ r2 Q8 f$ q# L3 w9 }4 M+ @; o5 G* A+ r' h/ e# R' `3 x2 u! K
public class AuthorisedUsers
$ m4 K- f5 E2 Q' C! w' N# J    {1 k1 y1 d6 @: y6 a$ G
! N9 t0 {' g) A2 C. W
        //-----------------------------------------------------------------
$ P) M- `7 T: F        // Constructor3 m( ], A& z, G3 f3 s! F
        //-----------------------------------------------------------------) Q9 D6 E, H: {, L( x; H2 L
6 }8 r& E5 u' S9 m6 g* h; v- {
        public AuthorisedUsers()
8 @9 D, d6 r% G+ E. d' \                {8 b% e% U; F) @7 Z0 P
                }9 \: h& X% G0 R
+ m( `  R% P1 L0 Q
        //-----------------------------------------------------------------. y3 L, @5 F! |- G) o
        // Method for testing that class has been reached: L( e. b, N# _& N" _$ R
        //-----------------------------------------------------------------       
+ h. d- I: y! v3 {2 _7 Z; x        public boolean AuthorisedUsersReached(). _4 Q) c- _1 J
                {
& C% l" `6 u+ l7 \                        return true;                        1 _3 T: [0 {1 o3 |7 j3 F# _
                }
5 P8 q, Z  }( l3 x! j. w                % \. V; ]  T- L# f" Y( `6 a9 g+ e
    } // end of class AuthorisedUsers7 }4 U' F2 Q- K' w
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
1 {& u) o* {) m2 H0 |- ?. L4 bShanghai - 20075 N' v: E% G! }6 y- ?8 a6 N
Assignment 27 X1 o1 S) q' m& S
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), m" C! s- p: X+ y+ P# D& l
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.
; T6 m) ]" L3 L5 [( z; G- VThe staff must be able to:, M* n+ T7 Q9 T% i0 _8 x8 y& }
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.( p* f$ l; n; C+ [$ R0 A
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.9 L0 b7 X$ I1 Q; Z
 The interface should provide a menu so that the staff can:
7 _3 S, W" W2 Y1 {: {! m" M% va) Enter the names of the two Java program files to be compared
5 R5 ~1 t" A% u8 e  Y For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
5 K( X: C) g) `' Q** 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).
$ t+ B& v5 q1 r2 ^( DBSA104 Business Programming – 2007: Assignment 2, _/ v( P' k7 G1 x/ Y
Page 2 of 5) h0 i+ @6 O6 p# n
b) Print out to the screen all the lines of code that are the same
- c* x" m4 H4 d* o8 N, L Include the name of the file and the line number of the code being printed for each of the two files
0 U6 U, Q, g" ~2 i' Uc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared4 n! S+ l$ L' N& m( x; w
 the name, username and department of the user4 b# T# E1 b) E3 I
 the statistics of the comparison
8 ?, l9 K9 }8 S0 c' h- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
$ s% t& d/ f1 P! Y8 m8 L9 D the recommendation for further checking8 n+ I* Z6 z! K7 P' x6 z* H% x1 o% |
- 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
( s+ i. r$ ~0 t6 |0 O7 u: O the names of the two files compared
! n3 T- x% ]* L# W# b  h1 md) Leave the program (exit)! q' @/ |) w0 x4 W& R1 W
The ProgramCompare class: (Total maximum 20 marks available); G8 w! A) W" g- E8 s, Z6 k4 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)
" P: u4 q" k1 ?" sa) provide an error message if the files are not found or there is a problem opening them
2 j2 G% b2 g6 @( n$ U; a" Pb) compare each line of code" Q- B) u. k- {6 Y3 h
c) print out the lines that are the same% V. X+ u5 Z. M( w4 {9 Q0 M
d) count the number of lines compared / lines the same
$ P2 s; g+ I2 O2 EThe AuthorisedUsers class: (Total maximum 20 marks available)" R+ a: D( V4 T' V
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)( H/ M! G! @; j, ?% U$ \
4. Provide methods to:
  q" g3 G" v( T: A7 |% w2 `7 ?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; W0 G' W/ S/ a. ^1 m1 ?5 |' G
b) return the name of the authorised user' n; `2 q5 @0 }: |4 d: {& J1 N
c) return the name of the department of the authorised user
% Y; V, [0 @4 U$ j( aIndividual Data (Maximum 20 marks available)
5 j, Z% k. j! z7 K  n5. 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.5 v: ?: Q' M& V+ S3 k8 l6 Y- y: d+ W
Documentation (Maximum 10 marks available)- Y1 b  e. D$ l2 h  p; E
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.& a" v6 k' M; m, ?* k- A& k  c) L7 z
BSA104 Business Programming – 2007: Assignment 2
& i3 N, b. Q5 GPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了* z! j6 W2 f  V, t
不过你要翻JAVA的类库说明。你有下载没有?" \+ {7 z( V' S5 ^5 F) _3 d# b
查询关于对比的函数。貌似关键字是contrast,还有compare
$ {) t' r: v- Y! x. M* p4 w7 N5 F& v! P8 s4 X
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
) g$ H* N! n' a; b' F0 M痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。1 p, c; B8 ?) L* o# I) Q! X9 c; s
可以下载到的 是 jdk-1_X_0-doc! i0 b9 \/ q" u& _

! d) o* A- }5 k& u7 m) l) U6 r" A[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-4 16:01

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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