找回密码
 注册

QQ登录

只需一步,快速开始

查看: 894|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 1 z/ A9 h$ }# ? G; W( |. X; b# f4 d& ]1 C9 \% d
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
* l  O. ], a4 Y//  ProgramCompare.java         Provided by: DRS
# l# u' S5 U2 S  L5 x& s* ^' _& {//
) P# q3 O6 W( `3 A, j- S6 Z//  Program shell for Assignment 2
  {0 V% H( K! N8 G//$ W3 `3 D/ d% F+ c5 _4 q5 D
//  Compares two text files line by line/ L# ?6 C( p1 @. j, _
//*********************************************************************  V- T- X1 q' y4 U

* [7 i6 Y$ R) t6 _6 X0 V/ L3 j9 |* [# K% pimport java.io.*;. E! t3 M8 K, t* t* c* j

7 d! W( l& b1 E  r2 n9 J4 rpublic class ProgramCompare" W% ^' T4 Y) M
{
9 H7 X5 z1 I) }1 e5 i! r1 p+ }        //-----------------------------------------------------------------! a1 p# I3 D; b7 b0 p# ]
        // Constructor
, y9 y. i# h/ G& ^: ~8 w        //-----------------------------------------------------------------
7 o5 U; A9 i, x$ q* L$ X6 @) C. L        public ProgramCompare()
9 y, E: P2 w& I+ i8 C5 s% [        {# H) i/ L8 `9 Z: j
        }( X( B; c) ^7 a7 N8 o/ e: ?3 L3 T
- G( y$ M5 }1 A" @; |
        //-----------------------------------------------------------------& n6 Z/ U, \9 [. G7 U# G
        // Method for testing that class has been reached
# s' c* k1 M5 N& |, l$ u+ ~0 c' U        //-----------------------------------------------------------------       
6 P9 X* U& a; T  x3 @; T- ]8 Q2 z/ D  c% ?+ v9 Q6 j
        public boolean ProgramCompareReached()         ( Q5 V, B# U% \0 E3 J0 T8 W1 I
        {
  ?, J; o$ E- F5 J6 ]% L/ b      try
* U8 ?4 a- K& [   {        
( e$ R/ C* `5 G  B2 n8 r                        8 M6 F& l0 f) L! t4 ]
                //********************************************************************2 w) z! |% x- j8 n  L
                // Try-Catch Statement is used to handle exceptions - such as file not found
# d6 m4 }3 A# i                // Reading the files will need to be placed inside a Try-Catch - just like this one!
4 w; P; A5 u5 m                // For more information see page 534 of the textbook, e* Q6 F, B, d6 Q% Z- l" j
                //********************************************************************
0 G0 f: B3 w' K9 n) ?4 u                     8 c4 t5 b5 R3 E. U3 q
        }& r9 `$ z% ~' q) F2 i3 Y
             catch (Exception ex) // Exception caught here and message displayed to the screen 5 ?" }: \: V0 A" r( J
          {
. \) P6 g5 d; q! Z/ b                    ex.printStackTrace (System.err);
& I  a( Q, X; R* F4 l           System.out.println ("Error message goes here"); // Replace this error message with your own         
) v( p( ~* k" k9 r# s        }
4 T. S3 @! Q; @4 n                return true;
% D) f3 L8 ~+ I0 x        }
3 x* g' D5 i& M/ @% V1 M6 h0 M8 V3 e% Q" D" e; ?1 j
} // end of class ProgramCompare
6 i) _+ |3 s- ?9 Z5 F5 t' ], e
$ Z' c- o: ?6 F1 l2 x//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
" _1 {: n- u* L//  ProgramCompareMenu.java    Provided by: DRS
4 c* p2 Z$ U0 u$ j! A) M7 B$ y//7 @: {) H3 p9 X( M9 `; x
//  Calls AuthorisedUsers.java and ProgramCompare.java4 t6 |6 I5 H  A7 l& J$ ~
//0 H. }" V' b$ m
//  Driver shell for Assignment 2.# k: \) J" l% N1 O6 h3 A" I
//********************************************************************
- D. o" R- Q! p: D; X+ l
$ l% c- W. N$ Y  R$ Cclass ProgramCompareMenu
- }) f) }! E% n' t5 V; }# S{
6 a  x6 A8 l) P4 o8 O# X5 G    public static void main (String[] args)
# F; e7 R+ c; s            {
7 d& Z8 u7 f; {( b3 }( H: \                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
2 u- \. B1 F2 K3 x4 L0 }# N                ProgramCompare reached1 = new ProgramCompare();
+ P) `# W, M' X$ A  ]) Q                AuthorisedUsers reached2 = new AuthorisedUsers();       
! N6 b# G. ?) E! L/ ~  G* o                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());: H; K. m+ Z4 m
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
! `8 O! b- H% b6 K, G        }4 w8 U, U* f+ M. R. b
}// end of class ProgramCompareMenu
( y% i' f8 p# S/ F& k6 \- [' |- e4 a) o+ q$ t8 {
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************5 l0 d2 N' F0 {9 o+ Y0 v+ l4 W) ~
//          AuthorisedUsers.java          Provided by: DRS, |0 J6 K/ \4 ?! r2 P, |
//                7 W9 |* B' y0 r( ]3 N* W
//         Program shell for Assignment 25 z4 z$ e* f$ s! I, D/ I8 p2 g' @/ v
//$ y: e7 k' a  G
//         Represents facts about an AuthorisedUser) c& T! p  o# ], ]
//********************************************************************1 M6 k3 w+ v9 |+ q$ K0 Z

, Z. ?3 R, n0 l+ O: bpublic class AuthorisedUsers1 h5 ]( F/ u9 r
    {/ p' Y5 k, m7 Z7 X- ~8 F* u6 ]5 p

6 S6 x" A" v8 C; [' `        //-----------------------------------------------------------------
8 n2 U$ A0 G% Z6 a8 w        // Constructor: u7 B  J* R* S1 F* Y
        //-----------------------------------------------------------------
' x/ j  `' w: K- j9 ?$ Z) I; ~# o  G, B& T2 P# Y
        public AuthorisedUsers()
7 y0 ?* C* \) K! L/ n. T                {! F/ u! O, m5 l+ s' F% F
                }. [. ^  n4 @3 R  h6 S' W

( K% V* k. p9 |+ t        //-----------------------------------------------------------------
( S7 O/ t" _$ J2 v        // Method for testing that class has been reached8 ?; ?5 B3 A; ^& v3 \' ]
        //-----------------------------------------------------------------       
$ U7 Y) |# v* r4 O, u2 q        public boolean AuthorisedUsersReached()% P) r2 ]! K3 W1 @+ r0 W
                {
7 c2 M7 \3 c+ ]5 }* C                        return true;                        ! M) D' q8 `: v# x6 |6 ?( ]8 j9 M
                }
8 S' A* d3 i1 ^( K  }9 ?                6 n% h% r  D% J+ _+ d
    } // end of class AuthorisedUsers
& a+ [0 ~% Y3 f//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming! O- Q7 B! w0 A1 x4 O# X
Shanghai - 2007
9 n" l' R# D# W8 q; U& pAssignment 2. F* ^( k; V6 R1 c8 |) I
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). y1 S( x6 L, {; K3 F% i: 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.
; B; E; i) U0 A0 a. L9 {! U' Q3 qThe staff must be able to:& }. C- v6 _* l6 m: F' n8 s
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
, N  R* {# t) X+ W' P1. 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.1 Z" R: z! P- |( k& v6 f
 The interface should provide a menu so that the staff can:% H& z) J6 h& u; f. G! V& W0 l  t  G: j4 V
a) Enter the names of the two Java program files to be compared7 H$ \/ b0 t' s8 _; c1 |
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.6 T3 d  h) B1 R5 q1 C
** 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).
& z4 ~: X' |/ J! L' ~6 z( U7 S# QBSA104 Business Programming – 2007: Assignment 2
, E8 i6 G0 x5 f7 SPage 2 of 53 j$ m/ Z, S: D1 c5 X
b) Print out to the screen all the lines of code that are the same
7 s6 E5 q0 T& }% _' W Include the name of the file and the line number of the code being printed for each of the two files" g, T( |9 H, j7 U$ H2 p
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
! m+ i2 T) |: I4 m6 C$ H" \ the name, username and department of the user* G2 `: j, R) S. x) H4 T. F1 q2 Z
 the statistics of the comparison
3 b3 x! k: \' [8 m8 C0 |- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
! @  E3 V* w; t0 R. Y the recommendation for further checking* X% [1 _; ?& @7 l3 \
- 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; F4 F( t& X5 Z$ U+ V4 F; p1 u/ ]2 `
 the names of the two files compared
: c! |- h& l" h8 `9 y" n% b8 ~d) Leave the program (exit)
9 Y3 e; V. k1 c: AThe ProgramCompare class: (Total maximum 20 marks available)& E7 z, G" c0 s% c
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)
0 S: `9 U# F8 Y  q! e7 ta) provide an error message if the files are not found or there is a problem opening them4 F( ]; Y9 c9 j# G! e
b) compare each line of code
7 e+ N( j: ]. {6 C3 u5 \: Lc) print out the lines that are the same- \0 o; r5 M$ Z0 ]4 i
d) count the number of lines compared / lines the same6 }- A; P& G% E& O" S' ]8 J
The AuthorisedUsers class: (Total maximum 20 marks available): [. K9 Y5 f, X2 j6 l
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)
3 j; K. O5 A0 z' z* y1 I4. Provide methods to:
2 D9 i5 l% k) ^: q& a$ l6 ~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
9 i6 k6 P4 @8 \6 |b) return the name of the authorised user; N$ ?% ]6 }( l! S3 q8 ?! w
c) return the name of the department of the authorised user4 H' v; _) t# [3 Y/ q
Individual Data (Maximum 20 marks available)
" e' F. W# w8 ?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. F% E4 j1 M4 D6 l4 dDocumentation (Maximum 10 marks available)
0 Y; e; f. s7 ^$ N1 }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.% K" f7 E9 H2 T$ w* E
BSA104 Business Programming – 2007: Assignment 2
$ d6 Q6 w6 d; p2 B/ ^; y; G5 x1 nPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了0 M' M, E1 N2 t) }7 f. t* R
不过你要翻JAVA的类库说明。你有下载没有?6 a' B7 U& H$ `& F* g5 m" t
查询关于对比的函数。貌似关键字是contrast,还有compare8 i( E% a5 [/ E$ R
5 p  z- z) l: K( t$ D. \
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。* U* W( N, Z. @. g0 b, m5 ?! x) A
可以下载到的 是 jdk-1_X_0-doc! [* ?* \- i- N7 y
4 \  l( d$ V& ]
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-5 08:00

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

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