找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1846|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ( q& E* U9 d; Z- E" J R 8 P) C6 g9 ~2 j9 J) X! J
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************8 q8 o: H6 V% ^0 q7 B+ p
//  ProgramCompare.java         Provided by: DRS' L7 L$ W! ?) ~. ~* c" I) U7 K
//
1 s, a$ h  `+ U7 J( L1 Z$ h0 F) N//  Program shell for Assignment 2: D, B& ^  R$ S4 p2 R4 n8 y1 `
//
9 w, p2 l8 i, J3 I# w//  Compares two text files line by line
! }' k, ^' `" x& A2 d7 q//*********************************************************************
2 [: |  _$ H+ g! v6 K8 q9 a! S* L/ F+ B; `, Q3 c/ `
import java.io.*;
9 r) r) l+ w9 D# e  j/ q1 G/ L  d5 ?2 |* h/ J
public class ProgramCompare
  s) D& _7 S0 S  z! M  X7 g; q9 I{9 ]$ j- T4 N0 e# B& d  o" K
        //-----------------------------------------------------------------
" e" I/ u+ s2 N: b. d        // Constructor) z/ r5 W7 X1 ~! C2 ?. p( G0 c
        //-----------------------------------------------------------------
0 m  D) u9 i4 b2 A, ~/ M8 F        public ProgramCompare()! D9 @' ]  n, l" a2 Z, g' Z
        {
8 ~4 z8 z' R$ v0 @7 m        }4 _& Y  Y  j* i6 O

" G5 A* X* J9 ?1 C1 I        //-----------------------------------------------------------------
# X1 @$ I( c" k$ C5 z; F1 r4 e        // Method for testing that class has been reached
( |$ u: X# N- }# c  c% O$ G        //-----------------------------------------------------------------        3 ]/ \& h3 U. z- L9 l) Q
8 Y; q' H+ ?; F+ p% k- g! R
        public boolean ProgramCompareReached()         4 |! x* Y% w- t; j4 |
        {
* d$ [# S5 i( F! a4 u' u) j      try
6 \1 _- Q7 @6 N$ Z  m   {         ( d* I$ h1 x" _
                        9 g: q. z/ M( x8 A
                //********************************************************************* p; ^3 \) d- M0 g2 Y$ |
                // Try-Catch Statement is used to handle exceptions - such as file not found   R7 W2 C+ l, M3 t, K" j" [3 _
                // Reading the files will need to be placed inside a Try-Catch - just like this one!* s# l; }  ?  r; |( E
                // For more information see page 534 of the textbook
: D* \4 z+ X, d+ X9 V3 ^                //********************************************************************
/ O. e3 z. p0 i) K8 n                    
1 v& D7 Q1 O" Y0 N3 G        }
/ v* R( B8 W( n" {5 z             catch (Exception ex) // Exception caught here and message displayed to the screen
. o$ Y! L4 Q( U; F1 s          {
; V: M1 H1 H( P) X  f( O! u' @- t                    ex.printStackTrace (System.err);
1 F/ t# g, s* m+ s7 M9 O& P           System.out.println ("Error message goes here"); // Replace this error message with your own          & s+ C! P! ?* c. y  n
        }
* [: r8 j) B3 O/ X                return true;+ H. c; h, R% B" b$ q* u4 b) j
        }
7 a8 u# }1 Z2 ?% F4 o% n9 P; f9 p5 P. o) W
} // end of class ProgramCompare: s. z3 [9 g4 E
* u' F' J. [6 P% F9 I' |
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
$ X: V( K: y6 x& }) p0 v& H//  ProgramCompareMenu.java    Provided by: DRS; c! ?( _, p6 y, n% w. T' q
//
. f. v( o0 ]7 O  q5 f. d//  Calls AuthorisedUsers.java and ProgramCompare.java  @6 f# g2 z; s) m" C: O5 a- ]! w- v
//
, B+ r* \6 G! f' |2 U//  Driver shell for Assignment 2.
4 W  R, h  {7 J0 v6 I: R! k//********************************************************************; p9 {; `% H, a' j4 H7 z
0 h0 I' e- Y- D
class ProgramCompareMenu! C( T: Y4 y0 w; ?
{6 ^  O3 o  h! N( ?
    public static void main (String[] args)
+ ]% Q' H6 w# Y  f5 l: j) k& ~4 V            {
' H9 L$ k; I0 O/ x& v3 {! v: J                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable* {! W6 J( ]* q
                ProgramCompare reached1 = new ProgramCompare();
# \, g( {4 C1 v) I" M* O  p) K                AuthorisedUsers reached2 = new AuthorisedUsers();        , W8 Y1 C% v" j
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
: p# ^9 ?  I2 m+ N3 M; h                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        * n3 q* p% q# d$ {- o& {
        }
) p1 l7 V6 ]& o$ j% s0 t}// end of class ProgramCompareMenu1 D2 Z0 g5 h9 G! x- r

' i5 K* |9 l9 V6 J//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
4 a! _  ]8 [- X//          AuthorisedUsers.java          Provided by: DRS
: ?! B7 F. {* r$ Y; I, K//               
0 [8 }, a2 d# h3 [* D' q9 A* J//         Program shell for Assignment 27 q$ y5 i: [, w( \1 G. `! c
//
+ \8 k7 I( S" _( v, t  w//         Represents facts about an AuthorisedUser
6 A2 c$ U& }4 S  r//********************************************************************
4 Y! v- G% m% e0 |$ p" F, k* h
+ {- x/ q( @/ g, K- wpublic class AuthorisedUsers
0 N& x3 U; a1 |+ N7 N& Z0 o    {
( w! _) |9 l' C
4 o9 W& V0 B+ _) b8 Z9 L5 |* g+ G        //-----------------------------------------------------------------! T2 x) O. c: C: O
        // Constructor
' s* F5 H) N9 N5 n        //-----------------------------------------------------------------  @3 I. ?5 g* O  E5 s

9 S  }8 C' R. E7 M, V        public AuthorisedUsers()
5 U4 B+ [" \- D5 ^4 W1 l% E, I                {& {6 O8 C- T1 u. Y- k
                }* ^1 y  |+ Q" D6 E% V- y  i+ n4 E" C
$ \" }) j9 y/ ]: A) R3 E
        //-----------------------------------------------------------------6 O) j3 i5 d7 X) w+ E- ]  t& S* u- B- S
        // Method for testing that class has been reached
3 \$ g3 _7 i3 ^& w' W# t$ p  n        //-----------------------------------------------------------------        / R* I  }  F3 L
        public boolean AuthorisedUsersReached()
+ c+ |% {# F) ^' u4 T5 }1 V6 e                {
- |) }: p. s  t                        return true;                        3 n2 k% Q  c- C& O4 B* D8 U
                }
; |) A  N. ]4 z0 h                $ \# J- o; P# a* x3 U
    } // end of class AuthorisedUsers
% L0 o7 w/ H% E) x) `//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
3 |0 ~4 a& F. f0 d/ H3 iShanghai - 2007+ e4 r5 V9 B7 V
Assignment 29 ~( k2 I/ |5 T4 {9 ]1 }
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)( r" z) o) R. g
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. j# U2 ~/ v6 T( Z- Q2 H! U+ {The staff must be able to:0 c! N! l. ]: j" `0 D& z! o
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.% \% o! M9 y0 n9 X) P
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.
: P; S/ B  t7 N, k3 @& ]3 C The interface should provide a menu so that the staff can:- b0 k; u) e5 F: C# ]
a) Enter the names of the two Java program files to be compared. N' `% H* Z+ j! r% P" t7 A- i9 M
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
! g/ \4 R, Y' p** 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).
6 l3 H# E' o5 ]1 v3 g+ wBSA104 Business Programming – 2007: Assignment 2
8 J: J9 s% {7 Q: W3 d7 ePage 2 of 5
3 \7 A. n! P. V: Z+ ob) Print out to the screen all the lines of code that are the same
9 P% p" z# T- ] Include the name of the file and the line number of the code being printed for each of the two files# i6 z# o8 H! ^# w
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
# ]3 ]4 J1 L8 `" V/ C3 S+ G1 P) r8 g the name, username and department of the user* p& ~+ M0 S9 D9 t; l3 }% r; e
 the statistics of the comparison
& H  @9 C6 @3 p$ i% \0 ?- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
# B  l) h( f- _8 p" `7 T9 c the recommendation for further checking, F, L- w% g) U* l
- 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
+ y$ B3 c5 i$ w5 P$ w the names of the two files compared) q9 C- W8 F1 ~5 A1 z
d) Leave the program (exit)
. A5 G" Z- S" u& z& h$ {+ j# UThe ProgramCompare class: (Total maximum 20 marks available)) ^2 Y  K, E) d8 v9 [! t: M( J
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)
( P2 c3 L; ]! Pa) provide an error message if the files are not found or there is a problem opening them1 B* [! K1 R0 K5 o! b; ~- l! H% M( b* \
b) compare each line of code
; q9 V# J# ^. L  K( @1 kc) print out the lines that are the same- @, n+ L$ {' ]. \# [2 Z1 \. C
d) count the number of lines compared / lines the same' e; A5 c% ^! \6 v2 F  E
The AuthorisedUsers class: (Total maximum 20 marks available)+ j  A7 I; G7 W! ?( r. A
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)
* z% O6 ?! y. c7 G4. Provide methods to:7 r/ n$ n, f8 h
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
% A9 n  D: X) }& k4 l* U# Jb) return the name of the authorised user
. G3 L7 W5 R- Kc) return the name of the department of the authorised user
9 W; j4 t- e5 \- Y5 |; |, XIndividual Data (Maximum 20 marks available)
" l& x: C# |) A5. 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.! U% z6 t  ~( c+ G% U# N+ V5 i
Documentation (Maximum 10 marks available)
/ [+ B; ]! [$ ~# J6. 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.. w/ [" L+ N- _
BSA104 Business Programming – 2007: Assignment 2
. I0 Y% e" j' gPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
2 y. B; r# M  Y3 K6 t) v不过你要翻JAVA的类库说明。你有下载没有?
7 N0 w9 _7 F, V+ p) H查询关于对比的函数。貌似关键字是contrast,还有compare! M  g' M+ M3 X

) X* y, {" r2 o0 S- h8 x2 _[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -/ V& s) W  \( W$ d6 n. Q
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
2 m2 n# |" B3 n6 k, e* D! P可以下载到的 是 jdk-1_X_0-doc
3 m; F1 K4 P4 C/ e' _3 [. I6 Y: ~! y9 u% O) o3 s% S3 o. o
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-20 04:40

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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