找回密码
 注册

QQ登录

只需一步,快速开始

查看: 969|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急9 [ \3 E6 u* H p : y" e! g! b2 I: a3 O
回复

使用道具 举报

 楼主| 发表于 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 y' l5 F! X& a. e8 l: s
//  ProgramCompare.java         Provided by: DRS
" I6 c  P' Y3 e1 w8 V3 {//
2 m, `$ f, j1 N, O; g//  Program shell for Assignment 2
. O0 }/ R  s5 I7 |5 [//
: ]/ d' s# }4 v$ h. [//  Compares two text files line by line% o& m. a- Z, G; _
//*********************************************************************
; ^, O9 H0 ?6 c, F
9 W" H3 d. X0 R! I" \$ @import java.io.*;7 o1 X1 h1 Z( l- C) \- F
3 C% s6 P2 G8 W  p$ e: P8 v8 B
public class ProgramCompare4 B  F& p# X  S, y) P+ C7 P2 `
{
' Q& i  ?6 o# M4 g; `        //-----------------------------------------------------------------6 x1 G) L) i/ g2 P* k
        // Constructor0 ?- S, F3 T5 [9 G' `' t" D$ i0 o2 d
        //-----------------------------------------------------------------4 T1 w: N. o: _, z* V! f1 ^) W
        public ProgramCompare()
/ n6 d! w% g' h        {
1 W5 ^' i/ _7 T. ]2 ]. R        }
4 N, z* w+ f4 C* ^
% G  V* G( X6 t+ X# J2 f, v0 `        //-----------------------------------------------------------------
, `! p! c8 j0 @. Y, ?# P8 W% U        // Method for testing that class has been reached
0 {6 A( [' K3 O8 u) J" J+ W        //-----------------------------------------------------------------        / Y" V5 p* Z3 h5 }7 w& q, h

; g/ f0 A. k6 ^, W5 z  t        public boolean ProgramCompareReached()        
* K' ]' g! q( e- K1 f+ t        {; z6 b% x2 w+ a# N, h: E  b% }
      try 9 Q4 Y7 f9 y9 V3 P$ H
   {        
1 D) t5 {9 \8 Y" u% ^                       
% |/ R, o! T6 q, i5 Z  W+ X                //********************************************************************  R3 I( C# j$ B# }' ~7 o  L7 n
                // Try-Catch Statement is used to handle exceptions - such as file not found
3 @! @7 U8 u! ?9 k) ^" `                // Reading the files will need to be placed inside a Try-Catch - just like this one!1 Z( ]+ ?. I# \4 h* F! J
                // For more information see page 534 of the textbook
7 N9 {! h0 s) H' E7 _                //********************************************************************
6 |0 q+ ?# g4 N% I                     4 i; W) E8 o+ ~9 ]# w. \
        }" o8 o( s) A" w- s
             catch (Exception ex) // Exception caught here and message displayed to the screen ) n$ ?+ G5 d1 k' U( X7 m, ]
          {; x+ b) V8 k" `9 \- U
                    ex.printStackTrace (System.err);1 g) S0 P$ r$ P7 @
           System.out.println ("Error message goes here"); // Replace this error message with your own          # w. w) \& z& I, P
        }
7 @+ q! V" @3 J, S+ P( t. O4 t                return true;
5 B7 U2 k, v7 r: G0 K  H9 K9 k        }
! h! M9 V) a+ `; }% |, F8 I' b  e& {8 b: E! k. ?7 S8 s6 `" f
} // end of class ProgramCompare
( U: v  D) x; [( X; [% M3 v; c# ]3 m" ]
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
6 i& R2 u; ~1 h# S3 O8 ?//  ProgramCompareMenu.java    Provided by: DRS% J& }8 S' ]* P/ m% e9 d! H! U
//% f) D! l1 m  v  Y) J
//  Calls AuthorisedUsers.java and ProgramCompare.java0 K  m4 X9 c+ \/ i
//
$ k; K% S9 G" Y& h) r: ?//  Driver shell for Assignment 2.
6 z# s# X6 J! n" `. X' ]//********************************************************************
& M' e4 K1 g4 z) A, q& }, M4 y/ w2 c5 p% j0 a; l& Q
class ProgramCompareMenu8 {3 n1 l! b3 g, c3 x2 \
{
  k, [8 f% {3 _; b, }* Z+ _: E0 U    public static void main (String[] args)
; u9 K3 M, `, ]9 A            {
4 b7 v* h: V* R3 u% t% t                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
7 k  }% w- v7 ]" D                ProgramCompare reached1 = new ProgramCompare(); 5 i. i4 [; w- E+ X5 Y. d# i" A
                AuthorisedUsers reached2 = new AuthorisedUsers();        " L% E% |$ z* f5 _* w
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
! M% }  V% V8 }                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
) N- c6 H8 C% `; S. a: w+ M        }
6 d; c& F. j9 M0 C! N, K}// end of class ProgramCompareMenu2 _' V  i- {' p( u# O( d- q# o! D3 x

9 q: |4 ?- z- F. s7 A/ b, D7 k6 v//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
5 X  A6 i! K6 f) P: d4 G//          AuthorisedUsers.java          Provided by: DRS$ Q8 A/ Z8 r. r& p
//                # a0 T6 P& g3 R, M( @2 O
//         Program shell for Assignment 26 E! `3 H% E& ~# {# H3 r, k
//
! r8 Z9 U/ [6 J//         Represents facts about an AuthorisedUser% U* p0 L2 x! @- q: h) }) A
//********************************************************************6 m  ~% N) I; {5 W1 ^+ P

  @6 q: @0 j. X& \public class AuthorisedUsers. q+ U9 M  y* [, Z
    {8 m& [5 a, K0 x

, C, ~5 O* a5 W2 J        //-----------------------------------------------------------------% K' |  P' N+ ]) f2 O$ @
        // Constructor8 h# O& v2 n" G% h& }) b1 @4 i! @
        //-----------------------------------------------------------------
8 Y: C/ r( g" b7 P6 ^5 Q
& M, H" K* e7 Z3 S/ G        public AuthorisedUsers()- H7 d6 P$ K# z8 i
                {6 v* v8 I8 {9 x9 a5 y
                }
% p) x6 H1 A- _8 [; A1 m
7 {0 y4 b  P9 z3 D* {! ~. S& ^        //------------------------------------------------------------------ t% q: ?6 d0 \7 n* M4 p7 n# _* R
        // Method for testing that class has been reached
5 p0 r: p& I* u4 k        //-----------------------------------------------------------------        " }. e3 D# ^7 e4 }
        public boolean AuthorisedUsersReached()3 D% q% m5 t. I9 w+ g3 H: a/ m
                {
: `1 p, ^1 \7 a; q                        return true;                       
1 z2 X3 s, l4 i. |/ u) `+ N                }
& T% d7 x3 c" v                0 |( V- A5 O, @. E- ], s
    } // end of class AuthorisedUsers
4 r1 |3 @: f$ Q- t//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming, `  i. h# x" r9 j+ {# Q/ t% K
Shanghai - 2007
% ^! x% Y1 \% n  b& x) e! MAssignment 2
0 L# ?0 }7 Y: A0 B' T' @4 q4 {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)
% t4 f9 g) a2 h; s1. 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., ]: O# _9 t2 V0 h7 S5 X5 R" k
The staff must be able to:
6 `  w, t: y9 n# I Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
/ J! E0 h2 U* k. N  Z1. 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., B0 x; f# k0 B5 k% @: ?/ t
 The interface should provide a menu so that the staff can:
6 ^* W$ r3 }5 b, k' m2 C, c) D, Na) Enter the names of the two Java program files to be compared
" u! E, K8 g# S For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
. K! x4 D, B( [9 T, o( f4 t** 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 |% g8 K' {8 S+ U
BSA104 Business Programming – 2007: Assignment 2* w9 n5 ]0 q) g5 L
Page 2 of 50 m  R  _2 T$ b, p# A! }
b) Print out to the screen all the lines of code that are the same9 e! `  v, t  {
 Include the name of the file and the line number of the code being printed for each of the two files
5 M( ]  q, O9 k7 B- qc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
; U( t! c3 Y7 Z: e" i+ t4 r the name, username and department of the user. i) ^2 W3 E5 j, ~2 p" V" @
 the statistics of the comparison
  h1 t! N7 I9 b! ]# r- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different' J- s! N/ w' L) k$ r1 \, \9 @( \
 the recommendation for further checking- J1 r8 W% N) P  D1 R* n& P, F
- 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 closely9 r7 C# [$ S5 e. ?" ]7 \8 r- a
 the names of the two files compared( q  s' i3 L7 C7 L, \
d) Leave the program (exit)
" u/ K( K( R7 S% C4 _  GThe ProgramCompare class: (Total maximum 20 marks available)
  v4 S$ z& \7 b2. 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)
8 H6 c1 c$ d6 R( v. _5 Ia) provide an error message if the files are not found or there is a problem opening them
+ q* C/ f0 \) I2 K8 Pb) compare each line of code
4 j6 }0 h) U, C6 c! Bc) print out the lines that are the same" e7 w# Q5 I# |* k7 U& e
d) count the number of lines compared / lines the same3 f0 f3 t) t% a8 r
The AuthorisedUsers class: (Total maximum 20 marks available)
2 y+ M( C+ Z0 q* N+ p% @3 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)* [2 o# G- n9 l
4. Provide methods to:
  i7 S$ A7 |  Ma) 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
: _& M+ z6 ~$ U" `' U: @& t. Bb) return the name of the authorised user, ?: Q+ G" r  U3 h' x
c) return the name of the department of the authorised user5 q% z1 Z- A1 F( d
Individual Data (Maximum 20 marks available)  E& t! V0 o" Z) S
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.
2 |# s0 B8 T0 A2 B8 X$ h2 lDocumentation (Maximum 10 marks available)  \/ F" @% ]5 I$ y4 j/ A) l
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 d* ]* A0 \! ?9 D& ?3 M% g' z
BSA104 Business Programming – 2007: Assignment 2. n& z! I, N8 C1 Z( q
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了& h4 w1 s7 J# L  e7 V0 _7 _# {
不过你要翻JAVA的类库说明。你有下载没有?) m$ r. M& D. v7 O! j; R4 E) z  y
查询关于对比的函数。貌似关键字是contrast,还有compare5 j0 D' W4 p! d% p$ G) \
& y7 j( i9 v& H! G) o* @7 d
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -8 m- R% ?8 ]% U6 v+ d
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。/ i5 J) n2 t( a& g
可以下载到的 是 jdk-1_X_0-doc. e6 W( {) H& q. _2 Z! R- w

2 J3 d9 L6 [% H9 d  n; ~2 K: r[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-27 10:14

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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