找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1380|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 / p! g4 f% P5 P/ U; D ) l5 u S" o; `1 W
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************- n: Z& F0 ~; l$ }- @8 _/ n
//  ProgramCompare.java         Provided by: DRS
+ e$ r1 i( [2 g9 ^6 ]( p: l//; N8 i+ e" ?0 U" u2 E) A
//  Program shell for Assignment 2
# o2 P" D' |" ]" X" G//
( Q0 W6 B% z: n8 e9 M//  Compares two text files line by line
4 I% T8 }, a( h- S% ^//*********************************************************************
  n4 n/ C& |" J: E  v2 h  @' W% }& J! h
import java.io.*;
9 A/ D0 P8 \% ?$ S
% K0 O% _$ x& R5 ?& Wpublic class ProgramCompare6 c# ?3 p. X+ h* ^) m0 W' Q
{4 V: \& W* J: {4 h$ ^
        //-----------------------------------------------------------------
( m, N4 U, `- k' [( k        // Constructor8 H( z& T( J' {7 n3 @' G
        //-----------------------------------------------------------------
% v) ?- e+ f% x: C8 V        public ProgramCompare()) U# J- a" L; U% u' d' E( k: P
        {
6 h2 ]! @$ [# p: b* P  T7 \        }) l! m5 I- Z& y+ y: z; C1 V2 p; p

" t7 y* z* ~2 x/ J  Y        //-----------------------------------------------------------------
; Y4 S& [0 l& G9 v3 J. E" Y        // Method for testing that class has been reached0 X* N7 e7 V; r" v' V2 _
        //-----------------------------------------------------------------        * K% q3 p8 ]# g/ t0 b$ @  `3 N9 {( o

" ~; Q4 @1 R) _4 d! N        public boolean ProgramCompareReached()        
2 r) P8 s! n# B3 I! v, U5 ~        {0 y- g5 J$ W. P( f
      try $ t' b, E# k: d) b% o
   {        
( d3 m! M  N( M* x; [+ x                        " F2 N: V# G0 c' ?
                //********************************************************************
% `: @& J; K4 _& `% K1 Y4 }' Z                // Try-Catch Statement is used to handle exceptions - such as file not found
& d" e* H2 V4 t4 g, @: x                // Reading the files will need to be placed inside a Try-Catch - just like this one!% p! I( z6 w; w( J4 b6 \
                // For more information see page 534 of the textbook
5 A" N) X; L+ W) Q9 |                //********************************************************************
$ a7 R$ J/ g: y0 e                     6 O8 Q' }- T! }, }* s# z5 e. D" a% H
        }# y4 w0 j( Q* s' @+ C4 F
             catch (Exception ex) // Exception caught here and message displayed to the screen $ t6 Z0 q7 K3 \" {2 Y" Z
          {; |9 \0 C9 B! Z- O( x
                    ex.printStackTrace (System.err);
4 a1 [* q  W0 `           System.out.println ("Error message goes here"); // Replace this error message with your own         
& C' N+ G) T( y0 `. v6 x        }2 O+ @9 T) O4 G1 c
                return true;( X% t! H5 f9 Y  T5 @/ ^& _' u  k
        }
0 ~' h1 q* H; O7 I6 M/ K! L+ }" P5 Q! X; N  H! ~( f9 O8 W
} // end of class ProgramCompare
! @5 |( p8 _  F) {' t$ {. ?
( A4 v/ i1 W/ u. U9 R: W. x//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************5 A9 C- V/ I$ _% Z+ c4 Y
//  ProgramCompareMenu.java    Provided by: DRS
8 S0 @  g/ u% \//5 b! o+ W) r3 e5 c% x: C* {' ?
//  Calls AuthorisedUsers.java and ProgramCompare.java) C! F  W1 f4 O% [* d& F; m
//
9 O0 G# {- x# c& i: U6 ^//  Driver shell for Assignment 2.7 j  C' L- P* B" A
//********************************************************************9 O' h- `" ~2 D# r

( _% \4 N$ \' z2 ^7 O0 f* ]  w0 eclass ProgramCompareMenu0 Y# [' d0 n1 S( n, k
{
& v, s. k9 l0 T2 I3 f$ D    public static void main (String[] args)
4 x% V) Y& W& C' d; w5 `8 c0 I            {
5 O- r: Y( e( X0 g4 W                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
7 ]! _; L! D4 r4 b8 j. z                ProgramCompare reached1 = new ProgramCompare();
: o( T% r; G9 i0 ~6 Z9 n                AuthorisedUsers reached2 = new AuthorisedUsers();       
3 _! o: h. j# a$ }0 Y# W                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());/ H5 S; v6 }7 }: _- {
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
: _# i% Y& y' [) l7 c' ~        }
( n2 A# g- o' l  c: T. y6 X}// end of class ProgramCompareMenu: c% h8 i7 o5 F

2 K# @  e: J% O//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
& L$ P- n: N/ d. ^5 B6 h+ k//          AuthorisedUsers.java          Provided by: DRS
0 m( ~% q* [* O6 V- V' F: \0 s//               
( L/ d: a  O2 M0 t//         Program shell for Assignment 2
+ z" S! n) b8 w2 Z& V" f* A//; T6 {1 O2 {8 W# C
//         Represents facts about an AuthorisedUser
7 T& e4 Q$ B& \//********************************************************************
4 e/ Q: j( H5 P! ?4 B) S1 C
% L. J5 l7 d) [$ W( Wpublic class AuthorisedUsers
& I2 x- |2 P# E+ s    {* y# w& v1 B  s- x
3 K# D! I3 j5 l4 x) @8 s" d! h
        //-----------------------------------------------------------------" O# F  B4 @1 x; `5 Y: E, T) i
        // Constructor% o, J0 Y) q$ e
        //-----------------------------------------------------------------
# N6 N4 ^" ?+ l) b5 [0 p& X2 I; L3 T" r& u* K" `
        public AuthorisedUsers()
% W8 n: r2 l3 y& F4 S0 A) P                {$ t! V1 f9 H+ G
                }: r% \; W! S$ U7 _
& z; c; |% S+ A7 p% P- I
        //-----------------------------------------------------------------
' d( l1 ?3 ?: m4 H# W" f9 C: S# e        // Method for testing that class has been reached4 W8 X! L* R  b
        //-----------------------------------------------------------------       
* j" c0 f9 z5 |1 z/ t        public boolean AuthorisedUsersReached()
4 d( T( S8 N6 L$ [! G                {2 B& E* r+ w2 D. t' r( g
                        return true;                          Z2 |0 W, r  Y, F/ y3 ~* \
                }
% T$ a$ d) g: R" x                # w+ X& f4 t3 v# O. _
    } // end of class AuthorisedUsers
: f3 N2 Y/ R8 _. A+ e$ s9 ]' ^//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming2 D4 _/ d  {/ L: g2 s' [( C& z
Shanghai - 2007
" E& u* ~; r% \7 t4 VAssignment 2
' g$ x; m9 ]  C8 HDeadline 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)
* D' c# {2 L) O0 q. \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.
* e4 w3 U  R, n+ WThe staff must be able to:
+ X+ D# q( Q) s% V Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.9 w# x7 c% {! `2 x8 C
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.& J8 i4 I$ F5 y5 p8 p
 The interface should provide a menu so that the staff can:
( B, g% w' v6 p6 ^a) Enter the names of the two Java program files to be compared# P5 Y4 D( a" w+ s3 ~" e
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.; b3 L$ i$ J% W' s/ t- B; ^
** 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).
* W8 ^& g6 f* i9 K4 F3 WBSA104 Business Programming – 2007: Assignment 2
, t$ i; ?7 }7 D7 g" G7 ]& MPage 2 of 5/ _) M# D. ?; c! l& e7 o
b) Print out to the screen all the lines of code that are the same
: _! y* v; R- t" ~8 B$ I Include the name of the file and the line number of the code being printed for each of the two files3 k! A& E' I  n. \+ W2 R5 m
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared' y- a" W( x* e6 z) I2 O
 the name, username and department of the user
3 [$ h" {/ `0 P0 u4 @: n6 l the statistics of the comparison, i1 h3 J% Q. \1 E; [
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different! U  R% U7 |+ |
 the recommendation for further checking
1 q: y& i1 a' n% X- 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
, ^% d0 d/ k; O7 e the names of the two files compared
* W2 u9 Y" X* Ed) Leave the program (exit)
7 Q% z4 b6 N8 P# eThe ProgramCompare class: (Total maximum 20 marks available)% B$ X& I! b5 K
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)
; E* F0 Z) x0 C0 H+ Ja) provide an error message if the files are not found or there is a problem opening them5 U. ]! g8 o6 \: }8 B0 E
b) compare each line of code
. \: d# @: F# E; Y5 Wc) print out the lines that are the same! {8 ~+ q! v- A( ?5 z; i! y( Y
d) count the number of lines compared / lines the same6 m3 i5 i* p+ Y" f& h4 Q
The AuthorisedUsers class: (Total maximum 20 marks available)
! ^8 {2 v0 ]# H  S3. 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)
, l$ J2 u/ g* O4. Provide methods to:* _3 d( u- ~# @, S  I. g
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
( H/ a3 r. h# H9 F7 U' `5 \, B1 l# Sb) return the name of the authorised user
) n! V: l9 E* v- S6 z- q3 B' Lc) return the name of the department of the authorised user5 q% g$ c) [# O" A6 n5 v$ y" v
Individual Data (Maximum 20 marks available)
/ L/ ]9 n! X+ Y2 r3 U" m5. 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.
' Z( }  P+ L6 ?Documentation (Maximum 10 marks available)7 i1 ~: k% M% V3 K+ d: E# R
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.  M$ h/ N2 W/ B4 \) l7 y$ e1 x/ h
BSA104 Business Programming – 2007: Assignment 26 ]) E/ U. E. R- W- Z. M! r
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
, u1 L' o5 l$ u( j( m9 q不过你要翻JAVA的类库说明。你有下载没有?
2 Q: S. @$ u: i查询关于对比的函数。貌似关键字是contrast,还有compare
- L. p' S  ?' Y1 R, w- S, c, m7 _! ^' y* y9 H3 {; Q! Z9 r& _( }
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
! [6 }  ?2 B1 J痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。& B9 q9 y2 I' O" t2 @7 z. P  k8 u
可以下载到的 是 jdk-1_X_0-doc+ O1 O8 f5 k! |8 J$ s( \: s* w9 h
' v+ f6 w3 i8 R( J; J- ?
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-14 02:59

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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