找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1621|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 1 S5 U m s5 x5 [ 4 N) P, e9 X- T [9 f2 I
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************% X) [( r3 M# m  Y6 ?
//  ProgramCompare.java         Provided by: DRS
' B+ k: ~& g7 q) y//
9 D7 d9 N! ?( J7 I+ J7 t1 s: W//  Program shell for Assignment 21 G1 \% M7 k" f, c+ s
//
2 ~9 P8 ?  q( X* L3 ~) J% M# ?//  Compares two text files line by line
! x( Z" e/ l1 k) @, \2 @0 [//*********************************************************************
+ H! o$ X$ E6 g' x3 K( y; F4 Q& h
( {- ?4 |& ^0 G" Q1 S, P# a6 E; ]import java.io.*;
2 D9 |% z" I/ o: W, f; ^7 I7 H3 T
8 L, S2 y+ N7 g. S$ W+ Dpublic class ProgramCompare
0 p: N5 b. ^' V0 ^4 n& I{
3 Z# ]0 H9 Z# v        //-----------------------------------------------------------------
$ |: i8 d' C6 b, `2 B0 w        // Constructor
0 C- m8 j. l- M) f        //-----------------------------------------------------------------) m- ^7 ]  n) [/ j& b
        public ProgramCompare()
7 ^- u' Q2 z% h% ~6 U6 j        {
; I" D) p* B4 Z$ b' o# ^2 F' o' G( A        }% {1 U9 x8 ^- r0 \  I: h, r
: \) n' `: n8 k& \
        //-----------------------------------------------------------------& X" s9 G: t5 |% _2 c+ d& Y1 C+ N
        // Method for testing that class has been reached& b1 u8 }3 S0 W1 t
        //-----------------------------------------------------------------       
# U5 Z; e1 [! ~% d" Y/ ]8 [7 `* L
  }+ f, a4 t' k* D* ]' W        public boolean ProgramCompareReached()        
) W0 ]  }$ U5 Z# A        {' k# x* }0 |9 O
      try & K  m1 m) R% a& B4 I1 W
   {         ; h4 `- J$ D0 `) p! d0 ?+ C
                        - L* \# M, {# z/ v
                //********************************************************************
1 u2 q2 C7 \% ?" e* G  J, ?% H                // Try-Catch Statement is used to handle exceptions - such as file not found $ \$ y3 Q# b- n% D
                // Reading the files will need to be placed inside a Try-Catch - just like this one!* t+ d: Q  J3 }' b
                // For more information see page 534 of the textbook
6 g/ h! p% r4 U6 K. P4 `- m, p; u2 }                //********************************************************************
6 U$ ~+ p# Q2 e: z  I1 u3 @5 [                    
4 q% B$ ?# V4 ^% l9 ~# L        }8 y/ W2 Q* |- ~% d
             catch (Exception ex) // Exception caught here and message displayed to the screen   _* `$ u; A8 b2 l) a, G
          {
) X. H/ G+ B0 c' o9 A/ s) h                    ex.printStackTrace (System.err);. {8 ?# g0 k! S& }  E+ |; I
           System.out.println ("Error message goes here"); // Replace this error message with your own         
1 L$ c9 p8 k4 B% M7 b4 O! J7 k: q; I        }
* b. }. U/ E. x( ~* G5 d; a                return true;* d0 [3 a$ b! q, r" e
        }
! A5 ?" N# G/ v$ L+ m$ y; Y3 e* R. Z, Y! s
} // end of class ProgramCompare
0 T5 p0 x5 h- G9 B% q0 X& H
' A0 C' N9 U3 |% \//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************$ Z" m/ G4 Q* a7 O: z7 _* ~) _3 n
//  ProgramCompareMenu.java    Provided by: DRS! ?- q3 g  ^% }$ ]: @4 X# w
//
' ~( b5 Z! t  c+ E, X//  Calls AuthorisedUsers.java and ProgramCompare.java0 [6 }4 L3 ?1 Y) Q1 q9 j0 \) I3 ]  ^
//! E9 W2 T3 I" ^' {# {9 U3 {! g
//  Driver shell for Assignment 2.
* a3 M+ F3 B; T+ e4 S//********************************************************************9 v: O. ^- k  q6 X, j
' ]2 n" W; ^! @4 C+ ?+ P* L7 P
class ProgramCompareMenu$ k" X9 S" ]+ ]; b& b+ ~% E
{1 _+ V: O( ^5 a5 x* [9 i7 ~$ d
    public static void main (String[] args)+ w5 g2 Q4 G, ^3 l& Y2 c* R: c) b5 P
            {
# ?8 v6 i; M5 I. S                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable7 E8 I& l9 g0 [; N9 q! m4 h/ m
                ProgramCompare reached1 = new ProgramCompare(); - Z: ]4 v* X& Q: z6 Z3 i4 H
                AuthorisedUsers reached2 = new AuthorisedUsers();        2 m! k+ I( s% r" s% M! t3 O+ k% w
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
% I6 R4 T  N3 D+ K8 n                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        , g8 \' L  S; D' g+ [- _$ Z
        }
9 T5 j$ M! F; d* m0 G8 f4 b}// end of class ProgramCompareMenu/ J. t* k  ^; v
! k# w/ ?3 ^0 g! y. q
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************# ~. b; o' \4 k9 K& N6 p' t
//          AuthorisedUsers.java          Provided by: DRS. S8 J) L; `: @' M+ \
//               
8 Y/ V2 p+ o% M, D) \  S//         Program shell for Assignment 29 I' A" Z/ b/ x) M9 _5 ^; d$ T
//+ r; ~! B' v9 c; U* l7 Q
//         Represents facts about an AuthorisedUser" |! U) t4 v2 O; }. P9 Y+ L
//********************************************************************
( M# G/ V0 ]! i3 f9 Y
# E# [0 O% ]; F) f" [public class AuthorisedUsers; D+ G2 g, K( u- U3 |
    {# G; X6 K3 |) k+ k" b
8 ^2 ?- n$ M; f2 b/ \" J
        //-----------------------------------------------------------------
. i7 x3 k% ?; p' I1 ]        // Constructor4 Q, o7 p1 O$ ]$ S- \6 P- p
        //-----------------------------------------------------------------! T- {- ~+ M. r1 q3 z

: C- @! h0 {. L, w4 `        public AuthorisedUsers()7 A9 ]$ t, t' m/ R
                {
& T9 V% r" v( J) M$ B/ p; X0 q  U                }
) F; p: `. ~/ }3 m/ r% N4 ?
  O9 F( O2 z6 X5 F2 J0 O' x        //-----------------------------------------------------------------
+ l2 f  g9 q! m        // Method for testing that class has been reached
  ]! Q1 s0 {! n1 d3 W9 L        //-----------------------------------------------------------------       
" r9 o. A* I: l3 z        public boolean AuthorisedUsersReached()
1 E7 C! G  T: C$ _" }# M                {5 G. m9 \8 T7 {! H$ D
                        return true;                        9 A/ G$ V5 U% `8 r4 v
                }/ P3 H8 K; h2 V- \. W6 K
               
7 t. R& a( t! E; T6 ]/ P    } // end of class AuthorisedUsers
6 b" `& x7 W* j: u3 o2 d0 N. k//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming- t& x4 D( E2 n1 m' V0 O4 D
Shanghai - 2007
. G# Z% Y% S2 wAssignment 2
# m$ W  z% {9 }- Y, S. s5 h3 RDeadline 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 _) ?6 a8 G, {: P2 ]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.5 {( w( w1 X# \) p* l/ ^8 W
The staff must be able to:
4 P( ~+ `% d, O9 `+ c Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.* {% b; _* e" }
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 d8 w9 G, Q0 T; V0 c  _3 z
 The interface should provide a menu so that the staff can:& \. N) [( c7 [5 ]( ]
a) Enter the names of the two Java program files to be compared
1 {  K" Z' u1 W$ U8 c' z For this assignment, it will be assumed that the two Java program files are in the same folder as your program." [& @) l! X9 {3 ]4 {. j
** 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).$ i8 n# n( K" b, v! |' q
BSA104 Business Programming – 2007: Assignment 2
& `3 b1 {7 d( y3 R3 n, YPage 2 of 5
3 A- L. L, y/ T6 @b) Print out to the screen all the lines of code that are the same
, [9 U. l" z( H/ v/ ^2 e$ d' g# t8 E7 n Include the name of the file and the line number of the code being printed for each of the two files; z' Q6 {- M% {  A
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared" Y% L( l. s+ I
 the name, username and department of the user- o4 M% s7 B. k1 K8 X
 the statistics of the comparison6 E! m0 c7 c+ L* R
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different+ Y8 \7 u2 A' t5 \8 N" r
 the recommendation for further checking
1 q& a. g: C: g0 a9 Z- 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 closely0 O9 e: k8 x4 s' Q
 the names of the two files compared
' X, Y& ]- c( ]- z: p1 ]d) Leave the program (exit)* T8 Q/ g5 t: u0 W( r
The ProgramCompare class: (Total maximum 20 marks available)
& O+ C3 m% E: E8 X: M2. 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)
  a% R! j% R- H2 g" Ha) provide an error message if the files are not found or there is a problem opening them9 L( ?* Y7 Q; W( g2 d6 I, Z6 i3 \
b) compare each line of code
& T6 G2 X  s" {% o- S- s7 X# Ec) print out the lines that are the same
2 w5 \+ b9 a0 t5 G3 p4 L7 {d) count the number of lines compared / lines the same
" \0 ?2 d5 E1 `4 qThe AuthorisedUsers class: (Total maximum 20 marks available)( a2 W. S: `. S0 B  V
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)- t) F4 A* v8 c" {5 m
4. Provide methods to:
& D( D7 g. Q1 |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
: x$ C& T) C5 z6 g+ `/ S& a: Pb) return the name of the authorised user
& ]" v4 [$ @% m( K, @c) return the name of the department of the authorised user
2 P* @: C, |: |' ^) Z& ~Individual Data (Maximum 20 marks available)( @% b- F1 x! a* q; Q0 L
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.3 h0 h2 q+ n+ X( j7 N4 k
Documentation (Maximum 10 marks available)% t4 N$ w" s8 Z  v$ n4 S$ m, u
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.
) I% Q2 @% u7 j# `. J3 E4 FBSA104 Business Programming – 2007: Assignment 2
9 j* L- @* X3 u; o+ }3 GPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
! \: Z% p0 V8 f: J4 d# t$ Y不过你要翻JAVA的类库说明。你有下载没有?
3 L, ?  J$ u- B3 k查询关于对比的函数。貌似关键字是contrast,还有compare
( L" Q5 R( `! _6 Y5 X7 n
% O! b( U* b8 s; z, D[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
9 h& Q* p( _# f1 w3 W9 r痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。4 G$ e  P" s# r: }2 N
可以下载到的 是 jdk-1_X_0-doc1 I, R6 c( S& J  b! T3 F
, O$ A. j" ^( K; K. }/ a  c" q
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-11 22:04

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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