找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1856|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 2 w% S I9 Q2 K! X; V, b$ g - i% o9 [$ `" J) B$ v
回复

使用道具 举报

 楼主| 发表于 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 {' `: `( o' _9 g; H7 `
//  ProgramCompare.java         Provided by: DRS) s3 T* @% ]2 \1 N6 P# y( F+ w
//
+ R/ p7 @1 B* u- G: P% S% A0 j//  Program shell for Assignment 2
  l! }: L3 x2 G: d: F//
( k' g! z8 q* U//  Compares two text files line by line
7 M$ S( \. J, @/ G/ s//*********************************************************************
  ?$ T) ~  B9 d' ^
' u) k. g- z/ @9 vimport java.io.*;
  G8 [/ p% C# L- ~% x! `8 c+ n. a! G
public class ProgramCompare
/ k! Z  S: d, N, |5 ?4 E- R% @{
4 n* {/ f) G  g$ P! H# C        //-----------------------------------------------------------------, [$ \6 Y$ E) L$ i# _0 w  d
        // Constructor
9 ^9 `, _+ Q$ B        //-----------------------------------------------------------------# }4 v6 U6 X) W! Z& ^. Q# v8 I$ [
        public ProgramCompare()
. f8 q3 k% j1 A7 N        {
5 b6 ]( }1 V2 G2 J) A0 ]        }) o8 X1 {: [+ c; I7 i: ]% a) N

! v. |8 D7 B+ Z; w3 v# H4 [, v        //-----------------------------------------------------------------. g& k; {0 ~) k+ u& c: d5 d5 J
        // Method for testing that class has been reached7 }) u; E; l% G4 \4 _; E) o, s
        //-----------------------------------------------------------------       
" j: W! R+ X) d6 {; I) }& \" _/ C. J, z% J
        public boolean ProgramCompareReached()         $ Z/ M' `$ \2 e; y0 [
        {9 W; g$ u8 k; P: B1 v) j4 E+ }
      try
- \" P( M& R8 _+ D   {         ) X2 j8 }) x( n/ f
                       
) _$ T+ }4 x8 b0 T$ f/ Z: h6 v! S                //********************************************************************, d) O- a6 Q4 x" C# T
                // Try-Catch Statement is used to handle exceptions - such as file not found 1 I& \& p* r- X, B& b
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
  K* G5 [: v* I( X5 q8 {                // For more information see page 534 of the textbook! n: F7 R6 ?7 E
                //********************************************************************% }/ f) l3 }; d) `
                     % K2 n  Q8 Y1 t8 a- u
        }% k3 G; c) Y! z0 [+ S9 x8 _& R3 P3 o
             catch (Exception ex) // Exception caught here and message displayed to the screen ( a1 i* I$ A! H( y( V+ J" V
          {+ X- u9 y0 p2 y; e+ I& L# B+ |6 g' C3 ^
                    ex.printStackTrace (System.err);
0 F- j) o2 S5 J) S+ Q; C' r0 H           System.out.println ("Error message goes here"); // Replace this error message with your own          3 M; J! z; ]; z$ }4 O0 l
        }
0 ~2 ~* S& T* l' M6 b  Z% |+ q% G  o                return true;
. |* c3 z! \+ v* X4 V' \1 \        }, O/ M# h2 r3 j# i9 \
2 ]5 l3 N+ e  x$ P: V' \
} // end of class ProgramCompare
3 t8 _# T$ G& q8 b( f0 X& G4 P/ ]
' Z4 v( W! s7 q6 {! W. D% g; A# d//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
2 x  _/ {# Q! x9 M9 i//  ProgramCompareMenu.java    Provided by: DRS
8 h! J/ N! b( k+ M5 b//. J# F/ ?5 s: y$ a2 W( ~, d* l5 X
//  Calls AuthorisedUsers.java and ProgramCompare.java+ K; Q1 K7 W# e7 n% T" J
//
/ l1 |3 q1 h' C% l//  Driver shell for Assignment 2.
; X* D' L; O3 }. g//********************************************************************
( w, q( h  O1 U. m8 S. E( M7 W  }7 |6 r7 Q# z1 ^4 d# x
class ProgramCompareMenu
8 X1 U5 B7 l3 M{
  r+ v' p4 T" x    public static void main (String[] args)
6 I% ?- O+ _. M            {, y1 ~9 `' g" Q2 ]- \4 V
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable4 z1 w: j6 [' |8 ^0 B) P6 t0 |
                ProgramCompare reached1 = new ProgramCompare();
' I0 s7 W! t3 K8 W+ P$ G3 j                AuthorisedUsers reached2 = new AuthorisedUsers();       
! E5 N) k) d6 I7 o9 G- m$ P                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());* |1 I) |: Y- ^7 I4 t  Y4 G8 A
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
' r" a  g% `2 g0 u! J        }
! c5 \% w) X/ T}// end of class ProgramCompareMenu
' e* @6 R% ~$ x! y0 A# n3 {; M9 K" W8 l4 C7 r$ B
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************/ M, V2 q- W% E: v: f
//          AuthorisedUsers.java          Provided by: DRS9 }6 j4 @; ], E( P! P' V
//                + o' V* n7 m) ^$ @. ^
//         Program shell for Assignment 2
9 P" j8 m4 F9 `7 h6 u$ h//
4 y+ k8 D: S; B; g//         Represents facts about an AuthorisedUser
  n; q4 k0 n3 ?//********************************************************************+ z4 q9 E: P  T2 `3 K' ~3 r$ w: W
8 q4 N& ]- X3 n6 H
public class AuthorisedUsers2 T# L; o/ Y. F% \6 l
    {
( w: V+ ~6 d8 q, B
& f- o1 }/ I* n) G% i7 l        //-----------------------------------------------------------------  E! N4 t6 V3 S  q, @$ e# b- I
        // Constructor! F; y- z/ ]1 Y# y+ a2 W
        //-----------------------------------------------------------------! |+ a. \7 V; A! {

( J5 |3 p6 ]9 z9 G6 V; v- J        public AuthorisedUsers()1 ~1 O, j# I# i
                {8 Z, j8 R3 g' T# Y1 a; o
                }
% ?* D- ~+ g( I5 y4 `$ o, j7 k' E0 b$ j6 E& e. o" `  N
        //-----------------------------------------------------------------
: d0 T; y+ N* u        // Method for testing that class has been reached. y  j' D# N# }) \
        //-----------------------------------------------------------------        5 t6 S  \: B- r# b# t
        public boolean AuthorisedUsersReached()
; @( R. l% b" H1 u) E                {- r; A! k7 y6 v# m# q' Y
                        return true;                       
( j, y. W% r) m1 g4 J% n; o2 x/ _* T& W                }
: p( x6 w0 i, B1 A# R' B- m/ d) b/ A" x                ) \4 r4 X1 j0 w' t% V4 N" j
    } // end of class AuthorisedUsers3 t! @2 U/ D+ D! e9 x8 s0 t# I
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
. R. p6 G; I, y) sShanghai - 20074 {0 L. r5 Y7 A' _  C* l
Assignment 2
2 ]/ {+ c  {. f1 I& s# ~9 e/ CDeadline 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)9 a4 k% P8 L- P$ h  E3 e
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.1 {$ V* H. m& }$ o
The staff must be able to:$ Y0 Z0 y$ J5 ]0 U1 ]# o
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
; i# X/ @9 o/ O5 M/ p; N1. 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.
. l1 i; k6 W0 R The interface should provide a menu so that the staff can:
" _* h  G: [% E/ pa) Enter the names of the two Java program files to be compared$ S9 O# @! v1 T. p2 `9 b
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program." G, g" o, x8 [& R% s: l
** 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)., e; s+ k; V* F5 ]
BSA104 Business Programming – 2007: Assignment 2! `0 E. ^6 s- _% [$ r
Page 2 of 5
( C/ V5 e" T1 pb) Print out to the screen all the lines of code that are the same2 N; ~" b" B! r: h8 v' q
 Include the name of the file and the line number of the code being printed for each of the two files* Q/ |. j5 C4 |1 b, Q/ \9 E% t
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared0 ]0 D# b& H, K% V+ W4 R
 the name, username and department of the user+ `0 L2 O3 s7 m3 j$ ~# r6 h
 the statistics of the comparison# A% u/ K3 w& F! c6 b7 ]% R$ a
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
4 G* z% k% Z" S- Z, x the recommendation for further checking+ d/ D# Z) x  E5 p
- 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
( k0 D; f' _' L; g1 d5 I the names of the two files compared
2 Y& Z: M, v' z# xd) Leave the program (exit), O2 a& `+ E3 Z
The ProgramCompare class: (Total maximum 20 marks available)9 V, `5 h5 f2 f, 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)8 u7 H0 ]( g  s7 X
a) provide an error message if the files are not found or there is a problem opening them4 d7 i6 i" W: J& |9 [
b) compare each line of code
2 |4 G9 R3 e. I$ lc) print out the lines that are the same& q& r: S+ P: V
d) count the number of lines compared / lines the same8 H2 d$ o2 }0 B. i8 g
The AuthorisedUsers class: (Total maximum 20 marks available)& r, Z) o5 m  K: j7 ^4 K* t: f; @
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)+ f- C6 h) z7 J. f3 T( y
4. Provide methods to:
8 R1 f# w- U5 B5 d2 g2 U8 |( }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" B9 {& o4 |9 y; J
b) return the name of the authorised user
8 F! I# E! z5 H: }- hc) return the name of the department of the authorised user
$ ?2 {# I# r' A% d0 B9 }5 s, qIndividual Data (Maximum 20 marks available)3 B' Z4 V9 U, R+ r
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.
) v7 h5 l8 K& G5 e; ]$ G, H! h* QDocumentation (Maximum 10 marks available)# z5 ^% e" w/ u1 W
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.
( G+ n! Y& s( o* G" h7 C% dBSA104 Business Programming – 2007: Assignment 2
8 a% {5 [/ X# Q' G2 [Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
2 [  v1 w' r. d" W5 H' k- `不过你要翻JAVA的类库说明。你有下载没有?
  }/ }) {4 i1 w6 X+ `8 L9 f+ w查询关于对比的函数。貌似关键字是contrast,还有compare
1 ~5 J; U% l* U) a, Q: V; k8 X# N1 _7 n9 M# l6 ^5 c
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
; F. W+ d6 c6 b痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
* G. T0 k) F- ~" ]6 {可以下载到的 是 jdk-1_X_0-doc
: r  t; l5 R9 w% P5 h, ?# ^" m* X# `3 A6 N0 T4 V; u% i: h! C
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-25 15:51

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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