找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1850|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急1 c" U8 m1 n2 u- [+ V5 x ' `1 k+ p$ @" x! [
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************9 \* s' m( _0 h6 S# x
//  ProgramCompare.java         Provided by: DRS1 r7 _& M) `( w1 ]5 [' ]' R- o
//
' Z) K( l4 O8 B6 z, |, K! ?: j+ `//  Program shell for Assignment 2! ?6 H' T4 w1 d* A8 ]& e! r
//
' k; f  P# X) L" t" m//  Compares two text files line by line+ W2 d( ~! {3 O4 {
//*********************************************************************
# P. l  P, z9 ^. @  E, K, L0 I# i# [1 k
import java.io.*;
/ G# g3 Z) L% ]
/ y# b6 m: W- Cpublic class ProgramCompare) x& o+ Y  v. j
{$ \; D' O7 h! \
        //-----------------------------------------------------------------3 C' Z' j) P( f# y/ a- u. D
        // Constructor
# X  k# {; w0 ~% v; y* n        //-----------------------------------------------------------------9 k/ m3 j+ s" J+ A2 z
        public ProgramCompare()' ^7 v5 f4 y* v7 G' M
        {
9 E5 T" @' j# Q2 O$ @* s        }
4 Q" h4 I# V9 p. G- O) C/ n5 M1 e% O; \' Y1 `
        //-----------------------------------------------------------------
, F6 w1 j/ b7 ]4 N0 _/ `% r* t        // Method for testing that class has been reached' `2 X6 {$ N2 w- g: d& L/ Q8 {/ o
        //-----------------------------------------------------------------       
% z3 E8 v2 G* M  Z8 ?2 a& {5 A8 G3 A0 D2 C& ?" T/ |- v7 V7 e
        public boolean ProgramCompareReached()        
6 A* h3 q- M) M0 V: U5 W1 V        {/ h" B3 X0 x! j* x% r$ k3 V
      try
2 q0 j9 i  H( f8 E   {         - H4 r3 h9 b2 v
                       
3 V3 W9 B+ t8 T% Y8 s. \                //********************************************************************  Y5 X8 \! g- f9 C$ E' n7 i
                // Try-Catch Statement is used to handle exceptions - such as file not found
2 v  b, M' X9 T1 b$ ?                // Reading the files will need to be placed inside a Try-Catch - just like this one!
. M: J6 V0 S- J7 X4 W) l+ K7 l                // For more information see page 534 of the textbook0 V) O" R& L  b0 O0 z' P5 b  @
                //********************************************************************
( f7 m* B( l2 U6 \$ Z% v+ K                     4 ]; [* s5 F- E: J# u/ Q
        }% B4 y: p- t9 I& ^
             catch (Exception ex) // Exception caught here and message displayed to the screen
5 g; s1 k9 t9 }2 M# U          {( G& p: T' r9 m/ D3 c
                    ex.printStackTrace (System.err);- X( J$ _9 Y8 ]  s! ?1 J5 N. y9 M
           System.out.println ("Error message goes here"); // Replace this error message with your own          " x9 r, N' s3 g
        }; n6 V) f& v& C# s/ A) x, v
                return true;- v# E0 L$ t4 u* M* W# H8 i" N
        }
# f! c! i  y' y! s& k
1 y! \) U* @5 Y0 k9 K} // end of class ProgramCompare% A4 B( [9 D* o4 M4 B) Q% a

9 H4 A4 _' j3 D- S5 N( n//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
7 P6 d; k) P; e* L" Y- ?3 U//  ProgramCompareMenu.java    Provided by: DRS2 N8 E  i! Y3 H+ j
//. J" W, I7 E8 t; f( Z) S
//  Calls AuthorisedUsers.java and ProgramCompare.java3 o5 R/ a2 E4 s! }
//9 B" P! q8 X+ a% L8 I- X  |
//  Driver shell for Assignment 2.
- w% B7 k3 z1 ~; B1 `" f//********************************************************************, a5 O& v. T, p6 d. o6 D3 N  y
" w( v6 i! I  P/ i: Z, L+ Y5 y$ H) C
class ProgramCompareMenu
1 n: N+ k( X1 [$ c& U$ I7 k- `% t{
. {  x+ Q/ M4 s    public static void main (String[] args)3 R; z/ S$ S, S( o! ?
            {
. I& s/ X; [# ]0 r; J                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
+ a1 S8 B6 D( k2 b                ProgramCompare reached1 = new ProgramCompare();
% J4 G% E( S2 F" p% U- X; j                AuthorisedUsers reached2 = new AuthorisedUsers();        * Y. w, W  ^7 A: e
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
3 ?  @( l' V* A$ x' {+ ~# @                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        8 s7 f8 n( ]: t5 ?8 Q  a
        }& v- {' G5 d, b$ L0 d3 ~) d
}// end of class ProgramCompareMenu
% o; c5 B4 U5 N% o8 m" O
2 I' _( E  [. L* O# O; e  s6 R//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************: r1 C& n  _) ?! A3 K5 ]( R
//          AuthorisedUsers.java          Provided by: DRS
7 B% m* P3 @- A- }//               
  {+ N( Z3 }! }8 @7 }8 q% j6 [//         Program shell for Assignment 24 U5 Y- i! I, y' o1 s  |
//+ L4 o- F9 t1 Z! q" j
//         Represents facts about an AuthorisedUser
6 A7 H, Z9 v4 I/ z//********************************************************************+ R- A5 n0 L& N7 P) d  n% }
' k( b4 L% F, {- q6 [5 h
public class AuthorisedUsers
2 k) X6 B! H% d' [5 G    {
0 k; i: W6 f5 O7 x! m  e# S4 L( b! c4 S, j! `; {
        //-----------------------------------------------------------------7 A  T9 r7 c& D+ E
        // Constructor
: m8 M2 Q+ k) q$ a        //-----------------------------------------------------------------
: s2 W% X5 F; w# h# E* E; i3 z  Z7 @2 I) F
        public AuthorisedUsers()
# G: k4 n* o( N( }6 H: ?% J9 g                {& W/ |' y& E3 Q3 L. l, f. E) x% M
                }, x6 c' H: k: v. e9 s

, v0 z+ ^# U, Y" m: c$ T+ M" F6 O        //-----------------------------------------------------------------* \: g1 A9 }* J7 _4 L- A/ T. G
        // Method for testing that class has been reached
& O4 x& w! f* b8 ]        //-----------------------------------------------------------------        - N" F% E; @; p& ?) v( f
        public boolean AuthorisedUsersReached()
; K) K, l1 n3 g- {8 Z6 |% F0 F                {
, I( C: S; W; X5 V                        return true;                        4 X1 }7 s9 j2 ]' S# n- C6 L
                }; d- N/ S1 \) y. Z% O9 d! |9 w) S
                7 e/ L$ i  ]' g
    } // end of class AuthorisedUsers
) m5 P+ R3 u7 {2 v, P, t//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
: F4 Z( Z) H5 z' CShanghai - 2007- E% K/ B# E9 s6 G
Assignment 2- n0 m. ?3 K* o2 K2 Z
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), S- s( b1 v' U/ [
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.
4 F+ i. N4 U& z- o( S9 ~# IThe staff must be able to:% b* ^1 A! G+ b6 F$ G" A, D
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
' a* E, ~2 G3 Z' L& S1. 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.
2 x: U' w: C) K/ v9 Q- n# y The interface should provide a menu so that the staff can:
- ~1 [2 g" n/ w  z. l4 Za) Enter the names of the two Java program files to be compared
" T$ W, b! c7 G3 G; _9 ] For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
# l/ R# H2 B- W8 J! r** 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).
2 Q3 G; s1 d& Y" l+ b% N5 e1 {# |BSA104 Business Programming – 2007: Assignment 2# r. q, N2 J$ X2 j
Page 2 of 5
' C9 H3 W- j% e2 f! {b) Print out to the screen all the lines of code that are the same
. P0 W! n3 c9 A/ B, y Include the name of the file and the line number of the code being printed for each of the two files4 k9 i! ^. |0 b! T4 k6 ^/ k# y6 y
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
6 Q0 j- [: ^; F& K the name, username and department of the user
) O% Z, B3 S1 Z2 {7 R' k the statistics of the comparison) }* n0 _  E4 g: `
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different. v% @. z2 e9 z: x7 k, Y0 s) L9 g% L
 the recommendation for further checking
2 [. A/ `+ r* N- 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
. L- n- I- c0 |( B- n the names of the two files compared9 Z( E( M( s4 s3 ]: `/ \' U4 t$ X* ]
d) Leave the program (exit)
7 T) s- x$ |/ F, ^2 ~' D4 nThe ProgramCompare class: (Total maximum 20 marks available)6 t$ i5 ~9 p2 ^( 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): S' X9 s8 ?4 ~3 v/ q
a) provide an error message if the files are not found or there is a problem opening them7 p& W! T4 i( r3 |4 H9 O
b) compare each line of code, {8 X9 l0 x& e5 ~) ~7 P1 N2 L( e, V3 m
c) print out the lines that are the same) b/ B  k( B$ l- e4 v5 @5 n. g
d) count the number of lines compared / lines the same6 t" y& T' x, D, L
The AuthorisedUsers class: (Total maximum 20 marks available)
4 Y) M+ N2 A4 F( q4 \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% l$ I; Z: M4 u
4. Provide methods to:
6 {! H5 Z0 l6 s4 ]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
. u" e8 f7 _, Zb) return the name of the authorised user  [# U+ K; G4 ~3 `5 r4 ]
c) return the name of the department of the authorised user6 M/ I2 R+ {8 c
Individual Data (Maximum 20 marks available)
4 f6 y- k3 l$ V5. 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.) ?" `; l( w$ i6 }/ ~
Documentation (Maximum 10 marks available)/ @5 `; C3 }  b
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- Y  O, R- i- H" RBSA104 Business Programming – 2007: Assignment 2& S9 w5 x; E/ {2 U8 B
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了' C3 f) s( m. e: p
不过你要翻JAVA的类库说明。你有下载没有?7 @* c8 _  N/ A/ S; ^2 r
查询关于对比的函数。貌似关键字是contrast,还有compare$ k% l$ ^" m) H0 s: a' X# `

" _/ G) U3 s( t9 Z[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。+ T1 N3 P( I+ f. O: @3 L' Z
可以下载到的 是 jdk-1_X_0-doc
. n$ u1 L7 j1 b' w3 g5 t# a! V% B
! P. ?% F5 p0 P  y9 z0 X[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-22 08:12

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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