找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1559|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ) v+ R6 x" P t% ]9 q/ n& a& O7 E6 k# t, f0 s* \
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
) c+ n5 u) c+ R+ g9 q( n3 b! }6 c//  ProgramCompare.java         Provided by: DRS9 r5 t3 H. S6 @/ w1 U
//
& y; q# S: p+ W% K( ?& [//  Program shell for Assignment 22 S* `0 u' e0 A3 r+ h, ?0 w
//5 }  W" t9 M( ~2 P% r* g# n" P/ q+ C: Z
//  Compares two text files line by line
3 |9 c: c8 T  J9 {//*********************************************************************
+ n7 E* @+ O# e9 V8 z1 t: d7 s
" }8 q$ j) S/ T8 c; l0 simport java.io.*;
- o& G$ O) K8 f! z( u, ^9 T0 I
2 x9 q( ~  I& m) J$ r1 rpublic class ProgramCompare: n1 @0 n) L: {
{% _( z( k1 R! O
        //-----------------------------------------------------------------
2 p$ @1 Q( m% E" a$ x        // Constructor+ g5 h( P$ V8 p
        //-----------------------------------------------------------------+ G  V' n$ l9 B' t4 d4 p* U
        public ProgramCompare()
$ \/ w' A: @# `2 K4 [4 z9 |9 Q        {
  {+ j* h$ A+ T4 c7 |        }
) b! N5 [. l" ~2 P  c4 L( H
% \" i. K- @  H1 U/ ~/ L, ?        //-----------------------------------------------------------------
7 C' o7 }" v" V% q+ o+ M5 y9 Z        // Method for testing that class has been reached) a" Y2 h( p5 A& ?6 d* X
        //-----------------------------------------------------------------        : Z7 C! |( S& R' V' M6 i# r
& X' B5 T4 _0 H" s$ s
        public boolean ProgramCompareReached()         0 E3 s) L, p$ u! D3 R" J, v
        {; c) N* h0 b7 U+ Y# G
      try
6 F) q! |. a& _0 J) H% x' V   {        
% c9 l8 P; \0 j. N' Z                       
. t; o$ y, O4 R/ p$ r) O, r; P                //********************************************************************
# D" v- }+ x2 H' g5 a' V                // Try-Catch Statement is used to handle exceptions - such as file not found
  w; k3 j3 q- g" H1 S2 a6 t4 j9 u                // Reading the files will need to be placed inside a Try-Catch - just like this one!0 J. k; t2 w% |
                // For more information see page 534 of the textbook6 E, x+ J. J: @6 G$ Z& g8 z
                //********************************************************************3 G5 f6 E. D5 H6 E1 r
                       A5 z( o9 ], v) N3 n
        }& X+ _, f$ [5 ~% q, n
             catch (Exception ex) // Exception caught here and message displayed to the screen ! Q7 G' @$ T" w+ C0 J
          {% s9 V" `% v0 z5 z5 v' t; z
                    ex.printStackTrace (System.err);
2 f! S+ b$ E. d1 P$ `           System.out.println ("Error message goes here"); // Replace this error message with your own          5 Z- z0 u' f, L
        }
- a/ V# J- s4 d+ p' x! c$ C, M( e                return true;' c3 A6 w% c, E! [1 ^# |4 Z: z
        }. m" _5 G$ e8 R  s  w9 Z8 }% \" M, y

& C1 ]" U% }8 n- U# K} // end of class ProgramCompare4 f1 x4 ]; H" X, {# z
+ q: Y. l% z9 e* ~+ ?
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************0 n" v9 ?' v* W* @
//  ProgramCompareMenu.java    Provided by: DRS; Q* H$ U- v7 f7 @4 f5 W
//% e2 g7 U! p. ~: ]* D  [- k
//  Calls AuthorisedUsers.java and ProgramCompare.java. e/ y! v$ }9 H) n0 r/ @+ L
//! C9 w. D' ^) R" A& N6 |
//  Driver shell for Assignment 2.
( f5 N+ A  L9 R, y  O//********************************************************************
9 |; B# W- ^* [
( X: P) s4 C) _  ]& M* g+ Wclass ProgramCompareMenu
# y0 r" t. S0 T! @5 T- a2 c  g{" t. Z1 r" u  c' Q0 Z
    public static void main (String[] args)/ T3 \( q/ A5 N! D
            {
- b2 q5 U; M. |/ j4 E, q5 S                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
3 p$ d/ j0 B# u                ProgramCompare reached1 = new ProgramCompare();
/ U0 ~! `# R$ m/ T2 j) K$ `                AuthorisedUsers reached2 = new AuthorisedUsers();        5 @8 h" m" A# y. j8 y, P5 S
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());, }3 N1 A8 J1 e0 K5 R: J( ?6 U6 j
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
0 Y6 O8 y0 P3 h4 Q6 U3 n5 q        }
( R  D, {, V9 f  D}// end of class ProgramCompareMenu
. F$ w+ C, A! _- O9 q/ z7 w' U
( A9 d; e+ ~6 H//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************" s; g: U) @- Y; e+ f
//          AuthorisedUsers.java          Provided by: DRS. S  d- U; X  V  x
//               
7 J) y! J/ b8 \; ]+ X! _  n- M//         Program shell for Assignment 21 q3 Y7 _8 [5 J/ D7 W
//
4 J: G: Q; ?; K//         Represents facts about an AuthorisedUser! C" f& Y4 g4 o3 O& ?! y
//********************************************************************, b+ l$ b' t( t! Q( w# J( o

% }+ [1 ?6 z' x* h9 `2 npublic class AuthorisedUsers4 a3 Q  Q& l: }7 |4 K
    {
, c8 @3 F. F: a4 U$ H6 d/ b  U0 K+ k0 O! M/ Y
        //-----------------------------------------------------------------
( q! P$ j, a' C8 q+ w        // Constructor  S0 Q: @/ v$ u" X  j
        //-----------------------------------------------------------------
+ ?" e% f: s: H5 D) @% t; Z
5 t5 P: u- m0 R2 A$ s        public AuthorisedUsers()
: ^  V* P8 D* s0 F6 M                {
7 i+ ^1 y& I; G* [. h5 c                }$ |# y- T$ @( z( H/ ?1 B) q

6 @6 b4 T2 d! a* ~5 X" i, R        //-----------------------------------------------------------------
. K; y- `2 W) d6 q0 G        // Method for testing that class has been reached
! W" y1 P- L5 k7 @        //-----------------------------------------------------------------       
7 J, ^1 N( B2 H8 q( G) B1 C) ^        public boolean AuthorisedUsersReached()" s# u9 o+ O7 [. I
                {% J  i+ z( g$ H0 N  {; q+ g
                        return true;                        ; h# r  N  X4 H3 o7 H- m2 b/ z
                }
1 m6 H+ `9 _& G% X               
! h+ C: }7 y7 h; q! X- d. z  z    } // end of class AuthorisedUsers
9 B, r- M, [$ D+ p//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming/ K" C- k3 p2 f
Shanghai - 2007
* s) @- Z2 o& }' QAssignment 2. O' M8 \5 _" f7 ]; a7 \: c
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)
' ~& C' z' B% ~! t8 Y2 ^/ ]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 c1 b5 }, M1 q- @3 D1 qThe staff must be able to:
6 Y) {/ [& w7 @5 L# @: U0 h Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
1 p  E- {' e6 ~) O% v1. 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.
/ P; ?# B# Z, O9 y6 W& ` The interface should provide a menu so that the staff can:* e8 Q1 x7 ~3 V+ j" x6 x
a) Enter the names of the two Java program files to be compared
1 J3 z0 L4 g3 U4 l1 Y For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
& Q- m: k% V$ n' i7 f! n** 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).* P! h9 ^( v2 e& [" ?, a5 ?
BSA104 Business Programming – 2007: Assignment 2
2 S0 S# S) m6 k% N1 I$ _4 EPage 2 of 5, T  C9 f# O2 _, M: P, U* o, O
b) Print out to the screen all the lines of code that are the same; u# W4 D, C# o" @  S8 D1 p
 Include the name of the file and the line number of the code being printed for each of the two files& ~9 A3 n# o: a
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared2 v1 d1 _7 V8 j: u" H
 the name, username and department of the user
1 s, {2 ?. X/ p( J the statistics of the comparison) b/ H; b+ w5 C# O; i% T
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
6 N, i3 {3 |" y+ y the recommendation for further checking
8 C* j# s; N3 D! T, t# m4 r5 v- 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! D; Q3 W7 s$ T8 `6 a  l
 the names of the two files compared+ m5 w* s5 k* Q" A/ D
d) Leave the program (exit)
' y/ i8 E- g; }: hThe ProgramCompare class: (Total maximum 20 marks available)
# j! w" }% W. E7 G2. 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)# K7 Q3 `+ u( i# E" @" I3 M
a) provide an error message if the files are not found or there is a problem opening them
6 @% ?2 J- @! M2 L+ i& Hb) compare each line of code
7 r4 Y( s7 c! X% g: v3 C& [7 L1 G: Mc) print out the lines that are the same
' G' p& d8 Q; g. td) count the number of lines compared / lines the same
+ V4 s; h4 g" J6 CThe AuthorisedUsers class: (Total maximum 20 marks available)6 B7 Z5 O. r2 S8 L) 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)
7 Q) a3 [) l+ I- T4. Provide methods to:8 K  q+ t; h, s, F: L
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$ R1 g3 l* j) a
b) return the name of the authorised user$ Q$ A$ L% O& D( y$ @- P
c) return the name of the department of the authorised user
& R# |( ]: f. gIndividual Data (Maximum 20 marks available)
# v' C3 q" M4 C' I7 A' P/ Z6 P5 e5. 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.; t" K. T% N; U( s
Documentation (Maximum 10 marks available)
) _. f  u. J% \4 ]5 w( C% ~) e6. 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.  B2 h" p+ {0 t* P- \  p
BSA104 Business Programming – 2007: Assignment 2
/ h1 O' K0 {  Q4 u. {! Z  C: qPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
% S: |: t& b4 D  g) Z, K/ \不过你要翻JAVA的类库说明。你有下载没有?5 ~3 g9 s/ I7 M% l* N4 }, ^
查询关于对比的函数。貌似关键字是contrast,还有compare) w3 p, I5 e" p

/ z/ O" p9 b4 f5 h) L[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
9 [3 u, h! I, [  `6 C7 S0 w痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
, @& R( N5 j" ]* o! L! _* n可以下载到的 是 jdk-1_X_0-doc/ r, e9 U0 Y$ C

  j( Y1 ?, t- K[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-8-22 21:42

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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