找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1098|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急3 o) J' e+ l4 d4 O2 |) F) S! K 1 }6 m% S$ p) M4 y4 H4 b
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
4 M* G: ~3 y  C+ F: ?# q//  ProgramCompare.java         Provided by: DRS9 ^9 e$ K( }) Q$ D: p" P( x
//4 j. p, O% _8 X2 }7 g5 _  Y- J8 d
//  Program shell for Assignment 2
9 z/ l- y5 {/ T9 `, N+ [3 u//
- s5 T1 w" {# @7 y3 f//  Compares two text files line by line
* B- U' C4 `- p. V" Y//*********************************************************************
) b1 @( s# N' W, {' v- W/ W! J* [/ w2 \+ p
import java.io.*;
: k9 Z& _1 \1 m2 E* X9 U' v
# [4 z1 j9 R/ K$ m+ v4 t) M. Qpublic class ProgramCompare
2 y& T6 k' E) ^7 t{+ j. i- m1 ?  \4 X8 M7 L3 o0 o3 _
        //-----------------------------------------------------------------
' W! k0 A/ e) n" |* X" ^        // Constructor, w- D3 t0 T0 [  W
        //-----------------------------------------------------------------
" o5 y& y0 @5 a8 i: p# [        public ProgramCompare()
* l& g+ |1 Z( j3 a8 K        {* G2 F5 C5 }7 ^  G
        }
3 }* X4 G. h% H( q' h0 ~
3 u3 p% j( m5 M6 {        //-----------------------------------------------------------------! D, h3 T( h. D
        // Method for testing that class has been reached8 r1 _* U" R$ A. w5 g6 |+ l
        //-----------------------------------------------------------------        3 f$ _/ f; \( W* D) f4 }
: m/ k4 P2 h; z! L7 M
        public boolean ProgramCompareReached()         ! B) a; Z0 j  C2 w9 Q
        {& Y2 v! K8 K+ [+ ?$ m
      try
  y! h. {' y, k+ o$ \  _   {        
1 Q1 g' C6 A! n2 c  V                       
  C, y: N. `) x                //********************************************************************
7 p. i; z  y' U% J. N                // Try-Catch Statement is used to handle exceptions - such as file not found
6 P" P+ N& d' N1 I* T7 b5 i  k                // Reading the files will need to be placed inside a Try-Catch - just like this one!! V  C% Q  W% I- @+ d) a. g3 n9 t, T
                // For more information see page 534 of the textbook
: ?. y+ ^, |' e; w                //********************************************************************/ n' g8 A' K# K2 y
                     # p+ }7 Z5 c' Z
        }9 Z% G* z1 u- P/ k; \8 D1 G
             catch (Exception ex) // Exception caught here and message displayed to the screen
3 a( \* @0 ]9 u5 i5 @- ~          {# w5 n7 f: m* U5 D. q' a; p) M
                    ex.printStackTrace (System.err);
5 N6 W: N# K3 o( b% T7 D$ ~6 }9 d9 m           System.out.println ("Error message goes here"); // Replace this error message with your own          : F8 u3 z% W  s+ H! _# Y! l% h
        }$ l7 E+ a8 J% o* ~
                return true;3 w( J% e. \. Q- l2 X
        }( p+ L' {6 Y% A+ L+ d% x  d2 Y5 D8 T

" b  F1 C6 s6 j" M0 n- U" w! T} // end of class ProgramCompare# z. G; T  _' @/ g! L1 S& X& H# s4 z9 z
- r7 ?. N( Q8 A: a- X' u+ ~
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
' k: h) y" c, r( u//  ProgramCompareMenu.java    Provided by: DRS
! G: _6 e# {6 s% d% n//3 X2 Y8 X. G# f, @% Q  V& d
//  Calls AuthorisedUsers.java and ProgramCompare.java
% ]- W! [& R3 v/// `* e& K# T& w4 |. Z- O
//  Driver shell for Assignment 2.
! u" T2 [) _3 L' w* R$ n. i//********************************************************************
' s1 c3 m3 [- ?- O, g2 f/ `! T
% b7 v1 g* W" D/ R1 B: v/ \- wclass ProgramCompareMenu
& A  f2 j+ N! L* R, o+ S{( u2 L; P2 F0 a' e0 x
    public static void main (String[] args)
9 g. ?0 d: x1 S5 o2 k) v            {
4 x8 p( ~$ }2 c; ^                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
/ |% x: E$ E: h) w0 {                ProgramCompare reached1 = new ProgramCompare();
, E, T" d: Z. o. E# s& q( b  _% s                AuthorisedUsers reached2 = new AuthorisedUsers();       
+ O0 v3 I) I* B& h7 s                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
) r  i- A/ O) N6 e$ p& j! I4 W                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        + C( F% M6 N4 [# b/ ^$ m
        }: u  e2 S! R' B' X" \
}// end of class ProgramCompareMenu
  v# q' E/ |- Y7 {' m
' j7 {! R( Z4 Y. M+ A& g9 [) F- P//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
" Z9 p) D3 l, g//          AuthorisedUsers.java          Provided by: DRS# p4 E4 q( w# w2 G" Q" M5 [5 J
//                - t7 w$ [! k4 o+ a2 K. r
//         Program shell for Assignment 27 u! Z9 F- ^0 |* ?. H
//& w& z3 D& V5 K" c* B2 X
//         Represents facts about an AuthorisedUser
6 q# L) F2 M9 }9 u2 |7 u! R5 W//********************************************************************. H( J. Y9 q! L7 P" ]* X) ?

$ C5 V* Y* J+ Z7 v8 S$ Lpublic class AuthorisedUsers
7 C5 `0 p' l* e" s! A    {
! N& D; V0 Q% G' p: R$ ?2 X) y3 b) l6 s
        //-----------------------------------------------------------------/ N& o8 e$ k* L+ a; r% Y
        // Constructor  l% K; L9 k# G- O: z* v( l3 ~: v
        //-----------------------------------------------------------------
$ |- z0 a, |7 _" j: q5 Y" y! _6 D+ x) g0 S
        public AuthorisedUsers()
# f) b' V6 |, o                {2 \8 m# T" r5 c+ G! A
                }; ?: R' ?' g, P
0 |( x# F: S- o2 v  E4 R
        //-----------------------------------------------------------------3 S; }( P! x* L6 ^4 A2 r6 C
        // Method for testing that class has been reached) ?' k# O: f5 Z" t
        //-----------------------------------------------------------------        9 {  L- Q  Q7 {) B# m
        public boolean AuthorisedUsersReached()' d" c. H9 D# \8 s% ?8 I: ~
                {5 x2 z6 {/ N5 ?3 i+ R) ?! n, ~$ P
                        return true;                        # j5 `! K3 n1 v. V" `& P& K
                }! @5 l/ K' N  f+ E" o/ J
                7 u# z/ g+ k6 S/ B0 O
    } // end of class AuthorisedUsers1 Y' ]" q+ F' M. g& l; \
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
# o9 v1 w$ B. s* q9 }4 g% QShanghai - 2007
; c( w1 O. [/ A9 n0 j, FAssignment 2
6 b! k/ i; E8 }8 [/ B4 O* oDeadline 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)$ X, z+ T% v0 K0 C& h
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.
& r. D  z' I2 i, `The staff must be able to:0 _! K, S0 i1 v1 S
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
& X8 ~+ P" U- ~+ |# h( I1. 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 X6 v3 S2 \# p5 R1 f8 B
 The interface should provide a menu so that the staff can:
+ G7 e7 o6 f: N4 h. Aa) Enter the names of the two Java program files to be compared
3 v! u, A1 `1 j: C: ~+ a For this assignment, it will be assumed that the two Java program files are in the same folder as your program.- ], f- e  o/ D
** 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).
, }3 K! U2 @. B  q* I! p( CBSA104 Business Programming – 2007: Assignment 2
' Y( {& q( c' M# ]$ ]+ P# t+ z# OPage 2 of 5! m# p# ~1 C' w8 m( n7 B6 X
b) Print out to the screen all the lines of code that are the same% J2 K9 _# k+ _6 w7 X7 T! p6 J' Y
 Include the name of the file and the line number of the code being printed for each of the two files
/ C3 {: _$ r) x# W$ L$ Ac) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared2 H. J9 M# y. Y  B* ?4 m! `+ ]
 the name, username and department of the user- R' L( v) l- S: o$ z: Y3 A4 a
 the statistics of the comparison
' L3 U! a2 W1 c) _7 v- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different$ w  {% E5 i- Q  J5 k. K0 g3 q, M
 the recommendation for further checking
4 W; F+ K, ]* T# w; I* T- 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- e5 X6 R& Q# }4 D! h  N* N. ~
 the names of the two files compared5 Q* H$ Z* ?/ d
d) Leave the program (exit)
  D; B1 {& [; H' @4 oThe ProgramCompare class: (Total maximum 20 marks available)7 s9 ?; G0 \4 F* g
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 G& V/ J& \' z0 I% Qa) provide an error message if the files are not found or there is a problem opening them; D6 Y% C: C8 w' @$ g( ^
b) compare each line of code
' ~) _, ~. p5 {# Sc) print out the lines that are the same
; T+ r' o4 t# h2 g) b5 |6 [4 b3 f' Qd) count the number of lines compared / lines the same% Q; _# P9 P, i' h+ e: Y( k
The AuthorisedUsers class: (Total maximum 20 marks available)
3 c" ^. w$ d( i2 F# W; c: _) m+ @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)1 Q6 K5 ^- {) K7 X3 `
4. Provide methods to:
0 K7 I6 i7 H5 I1 K, U1 Pa) 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
5 V9 M) b6 D5 Lb) return the name of the authorised user9 r$ [5 r  S, D1 l( W5 A9 V$ y
c) return the name of the department of the authorised user
, \' K1 h3 d4 Z8 V6 J' yIndividual Data (Maximum 20 marks available)0 Q. \' F6 i; y
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/ V9 r6 d% D3 W2 f* K( IDocumentation (Maximum 10 marks available)0 p6 T# b3 I, k9 k1 u! N. Q
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.) x: W, t$ z+ b7 i* Y5 i7 e/ v
BSA104 Business Programming – 2007: Assignment 2; G3 `5 n) E& X( I% b, Q
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了& \- N/ v# V' ^0 q) I+ W( C
不过你要翻JAVA的类库说明。你有下载没有?
; `- n1 J* [- N+ h" M9 v2 S  v查询关于对比的函数。貌似关键字是contrast,还有compare
  p! E: o7 j4 S- |9 M" u
. f* i% D' B( B4 \5 B4 `; c  e[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
5 H- M  S/ R' W+ F7 Z1 ]6 \- s痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。: U8 V9 I! L# W0 I
可以下载到的 是 jdk-1_X_0-doc
. T* o4 w: K4 _" K- j
  {. T- b, C$ d. e& f6 X! Z' q[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-3-7 03:18

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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