找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1557|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 1 j2 ^2 S, }; c& M) @6 u/ G$ @' e/ T5 q" ^0 e+ Y6 j" |, p8 a
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************) `3 o: ]8 Z2 t( r& x  v" R
//  ProgramCompare.java         Provided by: DRS
, \2 Z7 r7 c* Y$ y4 a+ [$ |. `//
+ h6 J- S; a" k/ i9 X; Y" M+ s5 P//  Program shell for Assignment 2
+ h* @9 F* h+ `  L& a5 J1 {- \//. u6 D6 ?* C/ N) O
//  Compares two text files line by line* S( A, E& G3 o5 o2 |
//*********************************************************************4 p3 r; G0 B7 Z0 j# j  |2 ~" V

( @* ~9 ~6 C0 Oimport java.io.*;+ {; z" f9 Z- Z6 R: X

( y1 u/ O2 q$ i0 x6 ]2 Cpublic class ProgramCompare! P# C7 _, i% Q) ~, N; W8 j+ w
{. Q2 L6 S& u0 v
        //-----------------------------------------------------------------
1 ?6 K3 j+ v# |  r0 L6 q* s        // Constructor
7 o1 f! K5 b  ~  S) q% L        //-----------------------------------------------------------------
3 l& [! r7 x8 \  V        public ProgramCompare()9 A# V" \: l: Z  {2 {
        {& Q  v( T* x% ~# W( y
        }
3 m+ x! {/ u" N1 S, ?4 j8 @4 j( q  |4 F& |( m$ i! S1 E* X
        //-----------------------------------------------------------------
7 Q/ N* ?, `9 Y        // Method for testing that class has been reached) F7 {* I, Y$ j
        //-----------------------------------------------------------------       
3 l! M: B( ?# a) t, H% Q' a# ^
: a( y! o2 \6 |* b* G5 t, E, p        public boolean ProgramCompareReached()        
; Y3 s$ d$ _3 m# ^: ^* X3 p6 @        {
* i6 `$ b6 R% W      try
9 ]# a8 c5 W) j* i* g/ j1 Q" ~   {         - W% K4 `+ b$ V) y
                        6 J  R  D; o6 [4 w# v2 i% s
                //********************************************************************7 [5 p; T  W- _' |3 `, v
                // Try-Catch Statement is used to handle exceptions - such as file not found # T. R" ]/ {& U2 ?1 C& m, m; u
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
6 A# o6 T0 H" f% V( U+ N9 i                // For more information see page 534 of the textbook$ {% b9 g$ Q% l+ @4 ]
                //********************************************************************8 J1 a) M" E  D- g3 P
                     1 G( x( k7 k  ^, K- f1 f
        }
# |; o  v8 T5 y/ R5 t3 v             catch (Exception ex) // Exception caught here and message displayed to the screen
" r+ T1 |5 K. E* \# x0 |* e          {
; R+ U, P2 m( y, n2 u0 o0 c3 G4 M# E                    ex.printStackTrace (System.err);
( A  }9 o# k6 k# S6 A7 F           System.out.println ("Error message goes here"); // Replace this error message with your own          * j* c. U& o+ e+ X) m) o. P
        }
2 j8 r7 B. ~0 x+ l; g& q3 T                return true;
) F. x5 N; K; F; H9 ?. {" Y        }" H& j" P; l, }; W; C. y- t

2 L; D8 s1 x# ?/ ?5 Y5 g} // end of class ProgramCompare8 q- K$ E2 y/ {& T6 K/ n- L

: @6 o2 x# O6 E//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
/ {& d8 d! V2 P+ {1 P7 g( j//  ProgramCompareMenu.java    Provided by: DRS
% e5 Q& l4 Y$ A! }//
3 i, {* }7 N. b# ]6 Z) _, G- f/ g//  Calls AuthorisedUsers.java and ProgramCompare.java8 ]* O" @; K" t/ h& T+ Y" u
//: `  ~7 A/ y$ Y0 l& c4 Z
//  Driver shell for Assignment 2., D3 K& ?: {4 v" e
//********************************************************************- q$ R- I7 D) H* e# T

# u) s1 Z, _3 F* lclass ProgramCompareMenu5 S9 e+ d) D4 B+ k$ y4 u, s
{
: ?$ }* [' H. j" n  L  f    public static void main (String[] args)
) {3 j* X  Y4 E! j            {# ~, M* h* }6 o. a. p* n, S
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable- I* k6 v0 Q; |7 E8 o
                ProgramCompare reached1 = new ProgramCompare(); 0 w/ H& B4 y/ g
                AuthorisedUsers reached2 = new AuthorisedUsers();       
6 c1 h% {9 u/ o- g                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
" E$ f. `1 T9 d! T: M3 }- @                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        8 X9 @& x- m3 H  M/ k% d; M
        }
) F2 V$ u- Y' C3 i}// end of class ProgramCompareMenu
6 H: O9 p' U6 G( n3 ~8 t& l0 m9 x8 N. i+ \$ {( L
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
" {5 y2 V1 ~4 N" M+ c//          AuthorisedUsers.java          Provided by: DRS
  _8 L0 F% ~7 e( q# E//               
1 A/ @: K/ P1 g5 X* M5 @- `//         Program shell for Assignment 2" M% w6 `! V) h7 B+ p3 G
//
9 a4 U1 s* p& L//         Represents facts about an AuthorisedUser
. i# m# F4 f6 j7 L$ O+ D//********************************************************************: Y; N' x+ j3 ?0 U1 d3 f
$ m, ~' U7 K% W* }
public class AuthorisedUsers  m4 |: ~1 x; S9 w/ u; x
    {
9 Z7 G8 B" Q  n& N
8 E" S' K8 R" N7 z$ T1 n: Q        //-----------------------------------------------------------------: N: y& m' f* @& z" W5 }) o4 e: U
        // Constructor
/ G# O1 }) U, a) A+ }        //-----------------------------------------------------------------; D& B  c# w9 g9 y2 M

- W5 u6 n9 W4 A& F2 D9 v3 s        public AuthorisedUsers()
5 d3 o6 g0 P) R: t                {
: c* j/ @3 @8 e1 A% r                }1 B; T$ K9 r4 Q- B. A# Q
9 [" l: U3 @7 L; c
        //-----------------------------------------------------------------
% r7 n" b" F9 v/ L6 y9 N7 L) Y        // Method for testing that class has been reached) |$ c$ S  W" s, r8 V
        //-----------------------------------------------------------------       
% w1 c, {5 {/ E/ x- D        public boolean AuthorisedUsersReached()
+ Y% |: S  L) V2 d3 ]+ D/ y, v                {
( G; m7 z* F8 Z4 a/ _+ Q                        return true;                       
0 l  ?, l0 Q8 f8 b                }! H3 N% I+ n8 @0 |
               
2 G2 D# E+ ^+ S, V& Y1 s    } // end of class AuthorisedUsers$ O8 H) S0 O' a! k- f
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming9 t8 c. F, T$ y" u9 \& t
Shanghai - 2007; \, q. S/ P5 p. U
Assignment 2
& V2 C8 u, v0 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)' @2 m4 K" ?6 ~# R# U2 b
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.
( d, \2 u4 e1 \" ~The staff must be able to:
' T2 \8 n. A; w Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.! b/ R" _, \6 d# n5 L( _
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.
6 O- J, b0 J/ S/ b2 R The interface should provide a menu so that the staff can:
5 ]* }  [' n, H$ Ha) Enter the names of the two Java program files to be compared
& f, H8 i; C5 e! w: T* x For this assignment, it will be assumed that the two Java program files are in the same folder as your program.6 a% Q! C6 `* D8 c
** 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).
5 n! L5 x% o  A5 z, W0 UBSA104 Business Programming – 2007: Assignment 2, L3 X6 a6 `- h/ u& H4 S
Page 2 of 56 h" ?, x; I# @+ z' G
b) Print out to the screen all the lines of code that are the same, h4 P4 R" J, t
 Include the name of the file and the line number of the code being printed for each of the two files. }* {5 v9 D& C" M
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared& x0 m+ W. x$ B% W
 the name, username and department of the user8 c$ n1 W8 M! {- f' O9 R
 the statistics of the comparison
5 x5 `; B& \' r0 l( ~+ q- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
8 {1 H, y+ C( z, F the recommendation for further checking2 u/ H8 M6 d& |- r
- 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% H$ V$ c( g) ]% D
 the names of the two files compared
2 m/ A( H6 u% g" l* F; Z8 Fd) Leave the program (exit)
2 n$ [; f& \) E5 [+ pThe ProgramCompare class: (Total maximum 20 marks available)
) \0 o+ h4 H  L5 b3 ]' ?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)
+ e6 h5 ]. X+ @) L1 _a) provide an error message if the files are not found or there is a problem opening them
3 i# U# ?; h' C6 m  wb) compare each line of code6 C" R8 M- n% U3 i
c) print out the lines that are the same. u, b5 ?9 [+ _2 r' L, d  }" |0 c
d) count the number of lines compared / lines the same
0 [: w5 k" ~) I4 u; {The AuthorisedUsers class: (Total maximum 20 marks available)
5 }1 z7 r( Q$ k8 B' Q3. 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 a3 s# c: ~5 ^& v; y4 ~$ k
4. Provide methods to:9 O8 @4 w3 L! f9 w
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# c: h% e6 x3 z0 b# I
b) return the name of the authorised user
) e* F8 t! b, G! Y. _9 Lc) return the name of the department of the authorised user- o! @- N  U* G+ t
Individual Data (Maximum 20 marks available)- m8 s$ c1 |8 r9 ?/ _1 }; E. D
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." C: E5 b! |9 Y' P0 q
Documentation (Maximum 10 marks available)' j' ~, c3 n, x% C  h, c
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./ {8 Q2 g* A" e0 H  }
BSA104 Business Programming – 2007: Assignment 2+ R$ E+ G0 r0 h- C' \
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了$ w3 V3 Y8 r2 Q: `
不过你要翻JAVA的类库说明。你有下载没有?0 ?! J4 U( F% o) x
查询关于对比的函数。貌似关键字是contrast,还有compare7 R6 L* W6 C3 J5 |5 B# y
6 r  P( q$ k5 |2 {
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -% c: ]* v# L, K3 a1 t2 v, l: k# j
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。: W: ~6 D) K7 T$ [3 E6 g9 f4 E
可以下载到的 是 jdk-1_X_0-doc
  z$ t: a/ I9 {: h, E# p" t5 u$ s( Y. C+ {9 j3 r4 B" V2 N
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-21 20:25

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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