找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1394|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 9 I( g: X. R% X+ Z% L, x {2 e, ~% T9 m' P* D, E; R$ {6 N) c
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
/ i, {4 O8 |5 t% U//  ProgramCompare.java         Provided by: DRS0 l. C( G0 J6 B7 i9 X" J9 N
//
3 H8 S. _2 N, _3 n//  Program shell for Assignment 20 s* ?0 b% }" x6 M( Y  O% O
//
( ~8 h0 m+ k3 t- J( g& r, k//  Compares two text files line by line
8 i4 I; A4 |" r5 f9 p//*********************************************************************
; g! @* L7 ?: @/ q7 F
. [+ l" W; z, G' K! ]# c1 aimport java.io.*;1 ]; ~; z9 p5 o
1 q: B6 ^# j3 ]" M# O, }
public class ProgramCompare# a- R# y( Q5 o7 L: _$ h
{6 S* Q$ Q. l5 }
        //-----------------------------------------------------------------
: X! s, f% Q+ S+ \4 u1 K: m% l" `        // Constructor) i7 Q- {0 V! f% q1 T: q- L' P) }
        //-----------------------------------------------------------------
, p3 ?7 ?6 }) R) `7 R: j        public ProgramCompare()
4 W4 J. T- a" z: E" K        {- z! U: J- Y7 }7 L) n  l6 d
        }9 N( N2 N* h# S, `% V4 B
- k* `! F  `& A  e7 n. a
        //-----------------------------------------------------------------
$ b* u5 o% r# o/ l: K9 A& f  `3 k; i" B        // Method for testing that class has been reached
3 j1 t! ^4 p+ f& T        //-----------------------------------------------------------------        4 n7 c! Z2 U; G  Q& `) [% x$ D4 g
7 J, S& O9 m' `( C6 V+ B
        public boolean ProgramCompareReached()         7 h) s$ w- p0 `* v
        {8 R2 l% d6 f5 o* X8 P; |" p
      try * R' g( t& F; {+ f& ^
   {         3 ]* D4 w& K  v# C9 F
                        + t& ~  n% @9 F4 H8 w
                //********************************************************************1 D' m5 I$ n  j7 c6 O
                // Try-Catch Statement is used to handle exceptions - such as file not found 3 M" Z. T2 e! r" m  D* ~
                // Reading the files will need to be placed inside a Try-Catch - just like this one!/ }+ Z" |9 {6 \! A% ^
                // For more information see page 534 of the textbook: u8 H6 Q7 u; U
                //********************************************************************( i& S8 }( ]/ U; x) J3 \5 C
                    
, V: N9 Z, S# z$ k        }
- q& r: ^3 @' c/ t+ o8 Y1 b' C             catch (Exception ex) // Exception caught here and message displayed to the screen 3 V1 Y5 [1 q; V- |8 z
          {( ^  M$ U- J+ V  r8 B/ s
                    ex.printStackTrace (System.err);
) n: P6 M) D; I0 d. H           System.out.println ("Error message goes here"); // Replace this error message with your own         
, W" C: w/ M1 J& `( R4 H; k' {. w' u, ^1 Q1 \        }
& a+ G" k! [4 `, d: t! u                return true;9 L0 [$ r, Z- Y+ w
        }  x: L' r( N1 `) D3 U
3 H& ]  N6 E; l2 {
} // end of class ProgramCompare, `: d4 n6 l: N* Q5 q
4 X- k4 o. f! X) D$ b) Y3 x4 H3 _6 D
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************2 y6 b" O! }2 w
//  ProgramCompareMenu.java    Provided by: DRS" Y$ N( O' `7 X* S  k
//! v- G% [4 k" Y6 X9 e
//  Calls AuthorisedUsers.java and ProgramCompare.java5 \4 N4 S' O) D  k
//
+ K. ^  M, Y5 d3 E//  Driver shell for Assignment 2.* w; ^# @  c  v9 v
//********************************************************************
& Y! [. W9 ~: Z& G4 t* B
1 F) g" |. g) T" W! Vclass ProgramCompareMenu* P7 t1 h3 E5 c6 M: J
{8 d% }) |. r5 {& a6 o
    public static void main (String[] args)
9 H/ q% Q& u5 U! O0 G            {
8 ~6 e" c# ^  U* s4 B" T9 j                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
+ ?6 z/ I0 z* p) I8 |                ProgramCompare reached1 = new ProgramCompare();
1 b6 n+ B% x* J3 o$ }                AuthorisedUsers reached2 = new AuthorisedUsers();        ! {5 t0 x8 x9 g
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());: n' i8 m/ M$ h6 R( C2 x
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        7 t3 t# w+ r% c. a. T+ h
        }3 Q, g1 c& z+ k+ }+ r, J1 {7 m
}// end of class ProgramCompareMenu3 q1 u5 O, O7 C: J5 j" H# t3 p
; u1 z+ m" @. y, s% n1 |" \# K1 ]4 H
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
/ T4 \* |8 _& _1 _$ T//          AuthorisedUsers.java          Provided by: DRS
5 ?. d$ }; T1 i9 G5 P//               
" W5 t1 t+ @! M' f+ R8 i1 I  W//         Program shell for Assignment 2# k4 l7 |' F/ z: E% |& ]5 q
//
) f9 A. E" X+ K7 x* Z//         Represents facts about an AuthorisedUser: f* `* s8 m  k" P6 h+ e. o
//********************************************************************' h) o; k+ X1 \
- [4 G, e$ ^& ^  a
public class AuthorisedUsers; {9 G7 H4 }! S/ b& ?
    {+ f: L7 b4 W/ v+ V9 ?8 b- P0 H8 M

" a' ^+ Z+ W5 R8 B; d        //-----------------------------------------------------------------
! m" Z# w! ?! @, o- t8 E' t        // Constructor6 c. s. G, F6 ]- B# m6 G( R" j6 O3 K
        //-----------------------------------------------------------------3 }5 ~3 P3 r1 L: N" r+ w
& y% G7 [. `- ~1 I1 u9 F
        public AuthorisedUsers()
2 C; |. y7 H3 W- T$ b                {; _) m: J3 \( y% L/ b( J
                }
$ a* k2 w( C) S, V4 ?$ f6 k2 {# v; }7 J, X: z
        //-----------------------------------------------------------------/ L$ x+ r2 ]) n; S( y
        // Method for testing that class has been reached
& w" @# F( U) d6 g5 k- z        //-----------------------------------------------------------------        0 E, z+ q/ }: Y. n
        public boolean AuthorisedUsersReached()
7 K9 \9 k; U; ^* `% R8 D' W                {
% ]. m1 X6 H7 f% h                        return true;                        * l) m: a7 t& ]/ a1 X
                }9 M' J" S- }, q- l) T2 \! \, [
                : B" w3 g8 c" ?- U- C% {. P/ x; L
    } // end of class AuthorisedUsers' G5 e2 I3 {/ d5 y, T& ^" z% t
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming  I+ [5 [/ @% w, f
Shanghai - 2007
+ [* @( C* K$ S6 t0 v' M9 dAssignment 2
( ?( ]9 n" c+ G  K: v9 L$ _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)
% w! U% K  }% v: q1. 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.
9 n3 T' d- ]* k4 t, o; z( LThe staff must be able to:0 x) T  T+ b/ w! h; y. `, L
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.9 s6 R- x8 K+ Y1 u6 S
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.
2 n- k1 k* @, p6 U) W The interface should provide a menu so that the staff can:
; X" x" W+ A/ B# x5 Qa) Enter the names of the two Java program files to be compared8 t! v* h8 M/ A$ M
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.: u1 v& f. y9 p, ^* y
** 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).
, i- K0 P8 }3 W7 Q+ rBSA104 Business Programming – 2007: Assignment 2
: e- {# N5 f* h) y' t: K. l7 MPage 2 of 5" M. Y3 F* A  _' d& @# q: `
b) Print out to the screen all the lines of code that are the same
$ O7 h0 o% O9 l Include the name of the file and the line number of the code being printed for each of the two files
  f; C# j8 E" i1 a: B* Z' Z$ g% @. _c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
4 j5 _/ {  |/ }4 R; ?' K the name, username and department of the user* {  T2 O: K% H' u  b% ]" L4 q0 q
 the statistics of the comparison& V3 L, f+ f" G) R2 |3 N4 L" v
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different- q1 y! |6 D/ v! H0 Y9 `
 the recommendation for further checking
, c) s* v( O5 {9 l9 f0 x0 l- 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" K( i  l/ [0 ]0 B
 the names of the two files compared
& \/ T/ B6 \" O6 V  _' L+ Qd) Leave the program (exit)
0 {% }! u' |6 n$ nThe ProgramCompare class: (Total maximum 20 marks available)/ g+ P1 U2 I) O
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)6 G2 {) n* z4 N) W5 J# d. ^
a) provide an error message if the files are not found or there is a problem opening them
; m) T) V0 d9 w. S( M' s8 n/ J! \b) compare each line of code5 }( {$ a9 U! R6 f! Q
c) print out the lines that are the same' r  @; X! A0 l# g, P# ~
d) count the number of lines compared / lines the same
6 L* C' @5 i, f% D9 vThe AuthorisedUsers class: (Total maximum 20 marks available)
. v( `$ |+ _1 V  i3. 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)
  p  }: C: ~' D; G1 b4. Provide methods to:
) I9 Y4 k- m" 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
7 r* q: Y8 ~$ z! P$ [; ob) return the name of the authorised user. I% D, C) q) j
c) return the name of the department of the authorised user# X; l' v/ J/ F3 j7 G: T
Individual Data (Maximum 20 marks available)8 `9 V) V2 H+ I
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.) Z+ q' W9 u3 f
Documentation (Maximum 10 marks available)
7 l( B! b' m9 ?% }4 V6. 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 H# g$ i, q' Q2 ]4 i- b) v7 }
BSA104 Business Programming – 2007: Assignment 2
. H1 W; q0 d. zPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
, m) Z& E$ }( M" v# s! ]不过你要翻JAVA的类库说明。你有下载没有?
: m5 @2 k1 `1 g/ {3 i- Q" ]查询关于对比的函数。貌似关键字是contrast,还有compare! ?6 j+ {1 E( x

) R3 ^8 n4 E8 r[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
8 w" J+ r7 o; N+ p2 M痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。$ ^8 O# Z4 S4 h% h
可以下载到的 是 jdk-1_X_0-doc
  I3 W( x% I1 A# M) Y0 g8 C" c
; D. u7 B. m& @/ @+ ^, {* _[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-20 03:20

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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