找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1489|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 2 d2 U2 `4 m' L7 Y: A% G/ }5 J8 w5 ?: j
回复

使用道具 举报

 楼主| 发表于 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 K+ Q+ x+ I' e( v9 W
//  ProgramCompare.java         Provided by: DRS1 ]' J* c8 q5 t' X9 B4 F
//
; z- O0 Z( m  @6 L7 x//  Program shell for Assignment 2" v) S4 f; T. T0 J5 R7 X
//% p. W% y% R7 l+ g
//  Compares two text files line by line
% o* O. \3 i7 k//*********************************************************************4 n5 l, ~0 j. d- ^' j- q( j/ O
# q+ A6 D. w1 f7 V! L5 F; X
import java.io.*;  z3 Q* Z+ S" P  N! A- n8 X% w

; l) ?5 n% p& T' Mpublic class ProgramCompare
* Q1 }3 H/ c. ^; _# y{1 W  n' w$ g1 q5 F* J
        //-----------------------------------------------------------------! _# U4 D+ _6 j/ h$ I9 T* B
        // Constructor
8 X# O( ]& o2 a) r" M# d* t        //-----------------------------------------------------------------
8 E1 ~& e( K/ B) ~# p        public ProgramCompare()% }. i+ [1 J! x2 r, o5 F" _6 a0 F
        {
1 O& Q1 w/ K/ ?4 K        }
% `3 A9 x, ]% j3 P0 n/ n6 K: G. @  N* H
        //-----------------------------------------------------------------
6 |- L/ a  [: l! U( c        // Method for testing that class has been reached  q* o; F3 q8 `5 s2 o
        //-----------------------------------------------------------------       
6 }% b  N& @) k1 q7 x5 ?/ d! }3 b  j- `1 ]2 s. t9 r+ U
        public boolean ProgramCompareReached()         ) l- o( D8 T; y  p3 ^  u
        {5 ^5 i( |1 |9 q' R' Y7 k& B4 \
      try
$ i% B* o2 U" s& U% I! D   {         0 b7 @& Y. P  J# m1 p9 l
                        7 m& ^, @$ }2 s, A& F
                //********************************************************************
1 \# t" i  @/ A                // Try-Catch Statement is used to handle exceptions - such as file not found * `/ f4 m1 F7 m  H# L0 o
                // Reading the files will need to be placed inside a Try-Catch - just like this one!2 h/ r% X* q% X  |
                // For more information see page 534 of the textbook( G( ]/ B2 i! l
                //********************************************************************# v4 F  v, T# h6 i: H
                    
$ o' W4 D6 M+ e" m4 o+ x: G        }
; u/ O" d; J, X             catch (Exception ex) // Exception caught here and message displayed to the screen 8 c" _$ l* ?" E- F
          {
5 b4 Y) B1 Q: I4 y, S* C* Z                    ex.printStackTrace (System.err);) Y6 d) d7 ~2 m) [0 K) d/ X" C
           System.out.println ("Error message goes here"); // Replace this error message with your own         
+ z3 t3 O5 Q8 X        }; `& T1 E/ d. x7 Z2 H% p
                return true;1 ?3 i+ m) f, X- Y, R6 g- Q/ {* Q
        }8 e+ y5 J4 E& t2 p1 O
( G5 o8 Y- _, x9 b/ P
} // end of class ProgramCompare9 r. g9 X7 E( T9 n  v

/ G) D. X0 ^7 I  B( W2 m//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
) N" e; y0 ^5 }. M' I; x  N! u//  ProgramCompareMenu.java    Provided by: DRS9 @! t8 {! Y% q
//( R' [/ V6 k2 w+ c* x
//  Calls AuthorisedUsers.java and ProgramCompare.java# ^1 b6 W8 R5 q: T" R* }, |
//8 R% ^- n' J- a% R
//  Driver shell for Assignment 2.
! U7 G* D; g) W# l" h0 H//********************************************************************
/ i5 W$ f9 \) N. D1 t  `; E! m- E- r8 M! [3 W$ l$ z9 h4 |& [! W
class ProgramCompareMenu
6 t; o5 x$ ^. ~+ G{
8 H7 r0 k# d' b    public static void main (String[] args)
' i0 o2 g. W$ W9 d# b            {
' Q* L% W3 ^; U& T7 `: {/ [                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable! @' q# G( P( E  V6 \! Z. ]3 f3 i
                ProgramCompare reached1 = new ProgramCompare();
: ?6 _4 d1 d/ {9 h2 K5 h                AuthorisedUsers reached2 = new AuthorisedUsers();        6 ?% v) G7 u/ B- L, V
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());1 W* D! v2 f, @' i0 c& l$ t4 k+ S( J
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
% C' Z2 y+ _$ ^2 c8 h' @        }
% k( u8 G- ^* `/ K: ~$ `}// end of class ProgramCompareMenu
0 t* ~! @0 k$ a/ z4 l5 ?0 f% V, |1 g  L! R* b  E4 m
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
( Y+ A& M7 @- Q& E/ o/ A8 H//          AuthorisedUsers.java          Provided by: DRS
1 A3 h( R; _! y# y//               
3 Z; Z% q$ f) P* H//         Program shell for Assignment 26 ~: i( f. L6 T- q5 l4 F
//8 i8 M$ _- D7 r2 D, b
//         Represents facts about an AuthorisedUser
5 _3 `3 r# |2 p//********************************************************************
+ }  b3 R5 _/ G. d6 y8 F/ p% Z
3 y& `$ @2 W5 x6 `4 }2 e1 Fpublic class AuthorisedUsers1 u. W' Z* j' e# S3 [# C
    {0 S1 h  @% r) k1 `& B2 M
& @6 v; g9 b' @  j$ y1 n
        //-----------------------------------------------------------------9 m9 `: Y1 K/ _: w1 s- G6 u  K
        // Constructor9 H6 i/ H) W7 _0 G" z
        //-----------------------------------------------------------------' v( j& V; l5 s0 {/ ^
1 I) Z" F8 `" ~( _' s( b+ r
        public AuthorisedUsers()/ k0 b# u4 {) P* Q! D2 |
                {/ h' H' X/ t( y* _! l
                }
+ n, H8 I# d& ?2 f  l4 W* v
9 o6 L# Y" z9 x1 b- j! s" j4 _        //-----------------------------------------------------------------
7 [$ k, b% j# v8 I: a) s        // Method for testing that class has been reached
/ V" y. t( E! L% e/ F" A; S9 M        //-----------------------------------------------------------------        ' X4 G+ [. q" W7 v1 Y9 Y
        public boolean AuthorisedUsersReached()8 m6 h1 F* ]: P# w+ J/ L
                {
$ c. B  s; x1 d3 |; b  T2 n                        return true;                        8 ]: U/ }( G+ Q1 c! x
                }7 s# ^8 U5 g: V& l. J
                # q1 f- N0 l* w# B% l. ?
    } // end of class AuthorisedUsers
+ Q& U9 a8 }# t1 C5 I6 r; T//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming" Y2 b' |* T# P2 b0 s
Shanghai - 2007
3 l# q- h! b( Y  X8 D1 lAssignment 2
0 ?9 j% U4 [7 w% x( t9 O0 k( b1 {* 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)" l, A" o, u  A
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., }/ k; C' D) Y
The staff must be able to:+ r. i) F0 r8 q3 {# V! d. d
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
. O6 R2 f" n, |4 i0 D7 C1. 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.9 n* V. j( [5 N5 m( l& D* ~
 The interface should provide a menu so that the staff can:
7 U$ ~1 l4 R8 o( C* [3 d# la) Enter the names of the two Java program files to be compared
- U# L- }+ _5 ^7 Z+ g2 X: g1 w For this assignment, it will be assumed that the two Java program files are in the same folder as your program.3 ^, I) \. Q% T3 B9 @
** 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).% C# t+ d- W& \5 K+ t
BSA104 Business Programming – 2007: Assignment 2
% M$ D4 l/ a4 J- I& m' Z) I: lPage 2 of 5
" P. w0 F2 w8 E1 e8 ]1 W* ?b) Print out to the screen all the lines of code that are the same/ Q( s# H: ]: h) U6 v0 A* j$ y5 e
 Include the name of the file and the line number of the code being printed for each of the two files
4 u$ ~8 P7 d8 F: G  cc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
6 K& s+ M3 w9 h  U: _0 [8 t the name, username and department of the user7 V1 _9 {7 m4 b$ E$ z
 the statistics of the comparison0 k6 F7 H+ @' H4 M8 {! q# w
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different8 K. X* U  @: L
 the recommendation for further checking
) m2 p2 ?7 m# V" |9 _. A- 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
2 {( H( M1 k  _" A the names of the two files compared& I' l, ^) {* H
d) Leave the program (exit)& a2 K* I/ ]$ [, C
The ProgramCompare class: (Total maximum 20 marks available)
" ~* |. k' ~& o( |) S2. 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)
& X0 |( N  u; m0 ^: N9 ca) provide an error message if the files are not found or there is a problem opening them+ O4 o5 U/ l' g" K( l! F
b) compare each line of code
2 C. x5 j4 d5 ~c) print out the lines that are the same
0 @3 ^+ _* Y5 J* l8 k) fd) count the number of lines compared / lines the same
" i3 O" ]+ v7 Y3 RThe AuthorisedUsers class: (Total maximum 20 marks available)
0 _0 g' O) M( a, w, M; y! U3. 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)
$ j4 k# {' j2 ]4. Provide methods to:" }6 a9 T  [. P, i  R
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% }$ T* S- F  r- r- h0 ~, i6 |
b) return the name of the authorised user6 }  c% m+ h- d7 q3 \
c) return the name of the department of the authorised user9 B/ ^$ {% I3 r' p  \% k5 |
Individual Data (Maximum 20 marks available)8 D$ D) B* l# M  H: 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.
* B: D- k, R' y8 hDocumentation (Maximum 10 marks available)  b  a2 L" u+ D8 _7 n" U, X6 w  i
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.0 g2 K8 f. |8 q/ k$ |& H- N" j/ g  A
BSA104 Business Programming – 2007: Assignment 2
7 o! c) k% Y. rPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了" O9 U1 I8 l; R) ?+ l
不过你要翻JAVA的类库说明。你有下载没有?
+ m. V$ s' m& I. S% _0 P- ^查询关于对比的函数。貌似关键字是contrast,还有compare' L, j' s4 I' o8 u7 R
+ m* r3 g* o2 @
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
' ~& I/ ^( v# C# r7 B痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。% |* I! _' Z7 e0 G& _6 h
可以下载到的 是 jdk-1_X_0-doc
; A& N: G! [# s& c  N" B0 s; b9 S+ ~$ ^; `$ k" F; n
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-25 16:14

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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