找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1039|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 * h& C( h) f3 Y$ h& f4 l' \ 8 U/ _; Q9 P# |- [/ ?, E
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
7 k: _4 c$ A. T# J2 q+ S$ T5 H//  ProgramCompare.java         Provided by: DRS9 P( S3 a& b- d  |! P- }5 Z: L
//
' b# L: d( s% x- e& E4 y" a9 O//  Program shell for Assignment 2
# p. Z0 c+ Q2 x0 G- L//1 z/ s& u/ x3 Y# h
//  Compares two text files line by line
* T( {5 M8 J4 n8 y0 \9 l2 a3 K//*********************************************************************+ |: g. u. b( O9 @
: B" r  E; e% D0 ^# Z
import java.io.*;
' F  M  }0 F; J. o* |, v; C1 I
8 f9 q9 C5 t* B/ R. q& Opublic class ProgramCompare' _4 J, g; l" N6 M4 q
{
# g$ d6 w; d) F8 z  W" D        //-----------------------------------------------------------------
; G) B) T5 A- F% L3 J        // Constructor  J" {# o/ _1 M+ w) R
        //-----------------------------------------------------------------
( e: H5 A( Y- S" e9 ]" o0 z2 g" |        public ProgramCompare()
0 S: q, j; A: [* ?# Z( o        {
- R7 e- o9 S: ~$ k. U  t5 n        }5 h3 R  m, O" D: d+ V- s! t# p

! ~' ^& P9 Z$ I) v+ }9 {. J6 I        //-----------------------------------------------------------------
9 b* S: c. u; R! e7 d& ^        // Method for testing that class has been reached# B' J6 _6 B" p+ I" u" E
        //-----------------------------------------------------------------       
: u$ y: ^/ ^4 L- [8 J
0 o* {( T* f9 i7 O$ ?, y) P        public boolean ProgramCompareReached()        
+ Q2 B5 F0 r: x# Y' k        {
1 Z% i& c# b5 u+ H      try % X/ ]7 g1 i1 Y% w
   {        
% M9 v2 j& G0 w4 q- U% e                          f* a4 Y* T3 K7 Y6 \' H
                //********************************************************************
6 f! Z7 G" i5 `+ A) W7 S; t                // Try-Catch Statement is used to handle exceptions - such as file not found , d2 w! n( f" Y1 M  W4 t( w# q' w
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
, T/ _( i/ B" u# p) i( `                // For more information see page 534 of the textbook
9 C2 z5 g4 W& Q& w                //********************************************************************
9 P( M$ g# d2 ~' B8 E% ]. ^( Q* x                     " j9 S0 p- J7 I3 \  {% z! ~
        }
, i6 g- s! }, i) K3 k, \7 ~             catch (Exception ex) // Exception caught here and message displayed to the screen 4 m5 S1 i: w( U# @" O8 {0 h
          {
% q, D5 C$ M6 E# M5 ]! _                    ex.printStackTrace (System.err);. T5 j, c" R4 H, x. M4 D  T; P
           System.out.println ("Error message goes here"); // Replace this error message with your own          % S# r' @* q) `. G3 R1 U: N8 G* ]
        }
# \' g) y+ ~% m4 m" N                return true;
8 a; W, C- \) A        }' b0 A  S  N& V: }% A9 N3 Y

  t! n1 }+ \1 A1 Z} // end of class ProgramCompare# B! v6 m" Z, n8 q3 D9 s

3 ~( S: Y+ Y5 y4 ~) E( V//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
' V! f7 M, a0 k% P- I8 C7 X! e//  ProgramCompareMenu.java    Provided by: DRS! s  s$ G# g4 ~* E0 C
//
+ [( a9 q; V' _( S9 a//  Calls AuthorisedUsers.java and ProgramCompare.java
( f* T  K' X( o- `" j//2 n+ C0 R2 c5 J" K8 |
//  Driver shell for Assignment 2.$ @5 {3 z( p" s4 a
//********************************************************************
2 u$ K" B3 a3 L: |8 [- T' H& O% X# H8 ]9 n% W4 q
class ProgramCompareMenu
$ c1 Q. A9 n) w0 |, A1 k. j" q{
1 [% [- l* E$ D0 h    public static void main (String[] args)& l% [3 G3 {" s" F% l0 @
            {
7 u( ~9 ], n% J8 g. ]8 ?$ q                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
% a' M0 X; M( m* |                ProgramCompare reached1 = new ProgramCompare();
9 h5 Y2 A* c2 L/ ]* q                AuthorisedUsers reached2 = new AuthorisedUsers();       
6 l- ~0 w4 n9 X9 S5 m% w3 H                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
3 h0 o9 }7 u% {! e                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        # L6 L/ o5 l9 c1 A, a. q8 Z! |
        }
+ i2 {2 y' U  d! f}// end of class ProgramCompareMenu
+ K+ m7 n3 ?1 c& W( G0 a
0 S# U3 |: Y0 w' A//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************3 |- P+ P  L6 T& d1 x
//          AuthorisedUsers.java          Provided by: DRS
' j9 ]+ R" G. e$ ^) Y3 S8 [//                ! n7 B6 h/ h; L
//         Program shell for Assignment 2
* c/ B3 d( t. x//
2 v) m1 |1 z# |" A+ k8 ~/ L; Z//         Represents facts about an AuthorisedUser4 c' R. w& g  Z. \: z
//********************************************************************
0 z3 `0 i# n( u2 \
: E4 V2 A! r4 T) f+ ipublic class AuthorisedUsers
3 h, y/ G, p2 Y7 P7 h    {
/ J3 o% y9 I1 J% h0 ]! \0 M6 c" a
        //-----------------------------------------------------------------# n  W8 r, e* g2 z/ K' \
        // Constructor
3 x' e: I6 k7 o- ?        //-----------------------------------------------------------------9 ]- G  W% G  l* O& |2 R

( ~, Q8 O9 C1 ]        public AuthorisedUsers()
8 `  J" c( V5 q# W" l7 T                {: @/ n1 K0 r! Q6 W
                }# X6 L2 x4 [8 \# [- B2 a5 {/ G
" q1 [: {% r8 A+ K$ ^: |
        //-----------------------------------------------------------------* r! n6 e, S" ?
        // Method for testing that class has been reached6 R2 @4 s7 K0 q% `* i4 O1 a
        //-----------------------------------------------------------------          {& w7 f) ?4 V, @
        public boolean AuthorisedUsersReached()
& [) {: ?6 _5 ?0 q$ C1 @, X' H                {, f( U8 b& H6 L/ n- c# C& L  U
                        return true;                       
7 e0 o  c8 }1 ^7 c                }% P/ s, B* w. T/ O- p; }
               
; [7 Z* L6 o1 o4 K" Y3 l    } // end of class AuthorisedUsers
) C) X/ i4 z6 J; F% ]//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
% s0 H+ D9 s5 T# j$ u6 cShanghai - 2007" V  L3 c3 D$ A$ a; R/ x
Assignment 23 n8 k+ l6 s' u8 U
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)
$ F( x, Y5 ^* Y+ p/ x$ \, I0 T1. 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.
/ j5 J/ N, m% iThe staff must be able to:8 e. V! ?' z) i: @0 ~
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.) h: H$ _4 {8 T# @
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./ `, L5 a& J9 C9 ?+ V  t, ?
 The interface should provide a menu so that the staff can:
8 {( \" N& m9 L" o* m% Na) Enter the names of the two Java program files to be compared+ d+ Q" ~" u9 X8 J$ D! W" N& i
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
# Q! j" v1 v3 R: q5 e** 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).
" _" z0 j0 I9 c/ L" T6 oBSA104 Business Programming – 2007: Assignment 2
6 H# m. H5 F4 ?, YPage 2 of 5
" @+ \/ W6 w+ t. ?; N+ _9 h9 Lb) Print out to the screen all the lines of code that are the same
* N. _' K: J: c8 F* N  f7 b Include the name of the file and the line number of the code being printed for each of the two files0 R, Q# S2 k" u+ r1 N+ d
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared1 ?1 c1 ^% R- J8 R  ^9 p
 the name, username and department of the user% G+ Q9 K8 T9 {; ]5 _( i; B' |5 x
 the statistics of the comparison9 \7 N& Z" ~$ q
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
2 m$ B$ n" E& L1 ^ the recommendation for further checking
9 \4 f8 r" P6 ^0 j( _7 D& y) M- 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' [6 u; V% s* @  I
 the names of the two files compared
5 l/ Q' v; D. }+ g, y1 [d) Leave the program (exit)9 z! w- {* i! {" Z
The ProgramCompare class: (Total maximum 20 marks available)' K/ k! Y; J1 {, W
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)
  k/ W  X! F2 b7 Wa) provide an error message if the files are not found or there is a problem opening them
% ]* {! Q, N; |& k: U1 nb) compare each line of code$ u1 t, o: q" w9 l1 F. \  C
c) print out the lines that are the same
/ O. I- R. j# l+ sd) count the number of lines compared / lines the same  ^9 H) B! s! a
The AuthorisedUsers class: (Total maximum 20 marks available)& r5 Z/ S7 g( P; I
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)
5 U  f5 Q6 u) e+ ?0 a5 t8 f4. Provide methods to:. ?. ]& y* U+ k3 {
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
: J. D  v) `  H$ o* Z$ @b) return the name of the authorised user
  H$ S- w5 j& z& e) n/ [6 V2 sc) return the name of the department of the authorised user9 B) j4 \8 I( ]- Y( J/ x( b
Individual Data (Maximum 20 marks available): q6 `8 S* D/ N0 l+ B
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.+ L0 i0 R) A. H
Documentation (Maximum 10 marks available)
6 w! a* n" u1 I/ X- e  H6 c6. 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.9 g. A! ^+ a. u$ L/ @
BSA104 Business Programming – 2007: Assignment 2) i( S7 s! v8 }# r
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了6 s$ z8 x& `8 D: Q' _/ K
不过你要翻JAVA的类库说明。你有下载没有?& e; i' }" }6 ?- O! U- b
查询关于对比的函数。貌似关键字是contrast,还有compare
' w6 [5 x9 I! }1 w9 ~
* \0 `6 {2 v- }0 L[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -) g7 @. I& \  a8 s. h7 A
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
4 o& p4 n' W/ ^- H7 q9 l可以下载到的 是 jdk-1_X_0-doc% ]: \+ r" m. J. I; ^/ x9 f, v
" y1 O, ?0 B: n' U) g* a7 Q. V( H
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-12 09:47

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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