找回密码
 注册

QQ登录

只需一步,快速开始

查看: 970|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 _& O0 E/ k+ {, N 1 c! u" D0 W- g& |+ u
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************0 ^5 [. Z# p% L6 |! n
//  ProgramCompare.java         Provided by: DRS
2 Z* F2 q! L+ I1 |//
1 o6 D& P3 o3 ^7 `* S9 y$ h//  Program shell for Assignment 2
8 C* ~% e. y  j6 F4 J/ `/// _+ u6 Y& d+ \# T
//  Compares two text files line by line
& p9 x7 Z: ?: M* F//*********************************************************************1 A( M! ?/ b- {1 X) h- Y

: e0 h! p, L* himport java.io.*;. b1 U/ H/ B$ i9 |4 L
. J# u' X3 _# _9 N6 g- t& P; C- k
public class ProgramCompare
! n2 G. O7 P/ b2 I6 `- r{# x8 f1 v; a4 k, ^3 Y) _
        //-----------------------------------------------------------------
, X- N7 b5 B4 Y* p0 ]+ T" p        // Constructor
9 F8 d" _) O" r& I1 ^* C        //-----------------------------------------------------------------
3 f$ `1 O1 D2 ~        public ProgramCompare()8 d( @7 n+ g- C3 c) W4 y0 d. j1 w+ \
        {
" j7 W  {1 p! U" C- K0 H0 z        }
2 @- p7 y; U, Y/ `* J6 ^, n4 p+ M0 J0 O8 D! w& p
        //-----------------------------------------------------------------  i5 w; F, i% f* w
        // Method for testing that class has been reached$ x  G! Z9 @  K6 g. ]8 @
        //-----------------------------------------------------------------        " o5 E# L2 ]1 w, s" t7 V7 k
1 B  L  P+ R: X& e% P
        public boolean ProgramCompareReached()         $ L( w9 r- X* L: F/ K
        {6 k# O, ~, U6 _2 ]; T
      try : }- ^. s6 R8 t
   {        
/ ?$ L% B! O* P% {$ j6 S2 S0 u                       
7 B1 a% b. l% D+ k                //********************************************************************
) f3 c  W' w: b, H; ?* J$ N                // Try-Catch Statement is used to handle exceptions - such as file not found
) K, u4 \5 M) `! m3 G$ p                // Reading the files will need to be placed inside a Try-Catch - just like this one!
) T$ f, N$ W* \  N                // For more information see page 534 of the textbook
& g8 @+ ^3 @) f& I& K5 \                //********************************************************************* M1 Y; f" ~0 G2 |4 n( Y8 r
                    
7 ?( G: b. u8 w3 N        }/ U4 `$ n: E0 w+ Q, @1 L! X
             catch (Exception ex) // Exception caught here and message displayed to the screen ( J  H; W* i) _2 J
          {
5 N3 D  U, [% S  A1 I                    ex.printStackTrace (System.err);
) V6 M# U* H; A; R+ Q0 H  U3 M* O% R           System.out.println ("Error message goes here"); // Replace this error message with your own         
0 }) Z- Z# t6 A5 t7 F        }2 G0 S' T# a: D# A/ V
                return true;; |/ K9 [- r* F7 h
        }
1 t$ o  v- @  K  y) H
/ B- w& \+ p. [" \" }  E; D} // end of class ProgramCompare7 d7 Y  A+ Z- D. G! [0 L' t

( [; A) B+ Q' H+ B//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************# K  n+ {; d" Q; a
//  ProgramCompareMenu.java    Provided by: DRS
3 b- A' e- M; P! ?$ {//
, Q/ o/ X9 ?8 |" ^//  Calls AuthorisedUsers.java and ProgramCompare.java
  X% H* ?7 }6 r" n2 G( u/ J: M3 F//! y( I/ v: @  B/ v
//  Driver shell for Assignment 2.6 F2 Y% B9 C0 [4 N/ ?
//********************************************************************% c, v( [& p# \& ?: _

- X  C5 B: j0 c# Jclass ProgramCompareMenu6 A. c: _/ J; y  ~! C' R
{( R- j2 u1 o. ^& P& ]) N
    public static void main (String[] args)8 b$ I8 n( P& C* N
            {; N$ x9 f9 l: ?$ o* m' @
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
: B) g& |" `- J) T                ProgramCompare reached1 = new ProgramCompare();
7 z3 V# R; T% l6 ^- g                AuthorisedUsers reached2 = new AuthorisedUsers();       
( T9 |/ _: u# F' m6 s+ Y                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
# I) h( f" G" p6 D& j2 e0 k% G/ ?                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
8 W4 B! b3 L7 M8 c; W  l4 x' l        }
' I0 e8 n, m7 B( N9 j7 F}// end of class ProgramCompareMenu
! A9 ?4 Y2 f3 c# D9 e4 i, _8 a5 D' Z0 Z" A. y" N' F- u
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
* Q  t3 p' Z, ?1 E% B1 |" w//          AuthorisedUsers.java          Provided by: DRS" Z7 X& o$ x! X. M* L
//                # J* m1 X$ m8 f
//         Program shell for Assignment 2
. M) E/ X+ U* h3 t4 I//7 |6 Q+ W" O; [$ p' F
//         Represents facts about an AuthorisedUser3 K. a$ n/ `; m' F
//********************************************************************% d6 s. q& x2 f
. o" C3 w9 y5 `) y8 R" N4 B
public class AuthorisedUsers
+ K* H! K/ C, M+ R) Z    {
% W7 Y* n: v3 I% S) l$ {6 X: o# J2 q- ]6 \( U! B: u* @( u/ f. |- D' p4 }
        //-----------------------------------------------------------------
0 y& d# M9 Z. O5 n# x3 d        // Constructor
/ d/ L) S; W9 C- W2 J        //-----------------------------------------------------------------
7 N4 }; n8 [1 {- e
( B3 h) I0 G* H: T4 N        public AuthorisedUsers()/ q, D* G5 s: y. p
                {
( T+ z! }* e" h" E# {3 u5 Q                }$ X: J! Z8 w: g  ~

+ D  |1 E8 Y8 t& w$ U/ {* ~        //-----------------------------------------------------------------
* h% g! w8 L* X$ N6 x% }: M! s/ T: P8 ]        // Method for testing that class has been reached. q/ z1 J9 B; q+ q; x9 B
        //-----------------------------------------------------------------       
, [: g5 ?4 q" l+ ?8 Z8 |% W        public boolean AuthorisedUsersReached()
- t' a! ?$ g4 }5 s& T0 }) C                {# I# ]" r  @0 ^- k3 A) p
                        return true;                        * `6 X& ~9 U/ R" d2 G
                }/ @. F$ g2 F5 \2 g, u0 C9 N
               
8 W# l, l# {( u7 G5 ~. m7 r3 ?: n    } // end of class AuthorisedUsers7 L5 ^2 B5 D4 E9 A
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
* h& P$ ]4 [% O$ t  P# UShanghai - 2007
" n( W+ J' A: mAssignment 2: k1 g, A) Z  r
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)
0 q+ I1 N- B! K9 I. }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.
' W- R5 S" c' t% U% r+ ?" MThe staff must be able to:! ]1 `# p- ~7 K" q
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.% ~6 l* X  `3 d* [  z3 M
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.
$ ~; F$ X/ m) Q- w) E8 E/ a The interface should provide a menu so that the staff can:
0 I" J/ w) ^- ^( U6 ea) Enter the names of the two Java program files to be compared
9 R$ ]( Z% W, F+ z9 I For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
( ~" g6 u9 Q4 W1 \, ]** 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).3 x# T7 D/ l) V: B/ ~( t" B
BSA104 Business Programming – 2007: Assignment 2
  y( |5 B" G: e4 y/ MPage 2 of 5: `% w; y$ }! k8 {
b) Print out to the screen all the lines of code that are the same" [6 |$ F3 q) W" D7 [
 Include the name of the file and the line number of the code being printed for each of the two files
) B9 e9 g1 E. T' Y3 N" G/ v+ E  M" lc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
0 x' i& J5 H! J2 t) j, b3 ~ the name, username and department of the user
/ u  W. F, x1 `/ T" E the statistics of the comparison
6 J, O! a- d7 }3 [" `( y6 r* c4 _- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different' ~5 T3 _* }1 j1 ?! m; h4 q
 the recommendation for further checking) ]4 M/ m; w- N, @/ j: 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
1 D' ]1 c: J8 w. C the names of the two files compared
8 H' r$ F! C/ O1 S+ @0 Ed) Leave the program (exit)
+ H2 P! p8 i. c( X( R; M( I$ y+ z# JThe ProgramCompare class: (Total maximum 20 marks available)4 U+ |+ K+ e. x* l5 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( z9 p  X1 ~/ b
a) provide an error message if the files are not found or there is a problem opening them
3 X% J/ A  u& B2 [1 `6 h, Eb) compare each line of code
- M0 ~9 L- i9 v* e- kc) print out the lines that are the same
6 A& z( Q* F1 A4 v6 L+ }% t5 Jd) count the number of lines compared / lines the same
5 E6 H  c$ f" O1 cThe AuthorisedUsers class: (Total maximum 20 marks available)& u9 D6 z- X. d+ b5 h0 k- {6 n
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)0 v7 [+ I6 ^/ H! H9 [
4. Provide methods to:, b  u  {% r2 E3 M5 D1 J
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
! @# c2 _7 Y. _, _b) return the name of the authorised user
  }% U' Z& Y. I- i0 I$ O# z1 hc) return the name of the department of the authorised user
1 \) s) |5 V: A- |# R, oIndividual Data (Maximum 20 marks available)+ S- e% q- A* J7 s2 Q
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." \  E1 G% E8 Z. O
Documentation (Maximum 10 marks available)
7 Z! k3 y2 d% |) U3 w6. 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.  \6 M: M  P1 \9 T1 I. H
BSA104 Business Programming – 2007: Assignment 2$ S  Y: [) o# d7 [6 k
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
. e. E1 M, `3 C, p. s4 {/ `不过你要翻JAVA的类库说明。你有下载没有?
: a$ a7 `5 W( S9 X$ A查询关于对比的函数。貌似关键字是contrast,还有compare
7 ~+ X" W* S( K! e- m# g" v3 P5 T3 t
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -  h* s. h) |& }9 Y
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
9 A8 q0 w) `3 I$ f9 I6 N可以下载到的 是 jdk-1_X_0-doc, m; `7 D3 @6 W
& z9 {3 E1 w+ v$ w* u* o( o: L7 R
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-27 18:05

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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