找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1509|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急$ v9 U2 e/ `. n7 U# I5 ~ 7 g5 ]9 _& C p8 v5 i: w# i
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
% ^, S: t( [; L4 o! h: c//  ProgramCompare.java         Provided by: DRS
* {1 m& \$ y3 I//
1 {3 ^, ]" D# M" z5 v//  Program shell for Assignment 2/ G( I8 T5 Z  ~
//3 Y# [# A9 N3 g7 \
//  Compares two text files line by line& n! N/ s& Q  I7 R2 O7 t" |
//*********************************************************************
7 K6 M# u$ [3 A
/ _6 g* M, g) Ximport java.io.*;
# p( b) h7 t- v4 Y/ ~6 K$ o! c8 Y/ a
public class ProgramCompare
" r/ y% c7 ?) m+ G% Z{
' i& e3 w% C( |- q        //-----------------------------------------------------------------
0 [" |. ]9 U5 e. n9 s        // Constructor% `- f! O2 j( c
        //-----------------------------------------------------------------
5 H& J5 O( D* g8 O, m; d        public ProgramCompare()
8 n. d( h& f0 s) Q* l+ \        {
8 x; @& g- a9 w1 l        }3 ~0 u: i; ?# \. S: M/ W* l7 ]

' E) ^6 a4 e8 r, T, k% u1 ]/ A        //------------------------------------------------------------------ G5 ^1 r8 a, a- _2 v5 a
        // Method for testing that class has been reached
  G3 p# z! M- D* L) C8 V6 U        //-----------------------------------------------------------------       
5 p9 f; m  o) E$ W& R6 D2 _0 ^8 p3 z
6 i* P2 `3 K- L6 M/ k3 y        public boolean ProgramCompareReached()        
" W/ @) g' ^2 m1 P        {: s) l. g5 ]9 I
      try
! e* y" W* a& B+ h   {        
# P. |# F. `7 M* [! m1 O                        9 x! l0 Z4 d5 D" u
                //********************************************************************: i+ v  L9 A( ^( r
                // Try-Catch Statement is used to handle exceptions - such as file not found 6 ^6 y( [- l) [
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
; e! ^0 c6 C" {                // For more information see page 534 of the textbook
, S6 l# Z& P$ A; @                //********************************************************************
* E& k9 Y3 c/ ]8 {                    
# f# s5 M! v( s2 J5 C7 M        }! m$ Z' @" ?( q% h5 [2 Q  \! n. A9 D
             catch (Exception ex) // Exception caught here and message displayed to the screen # p7 K3 f6 d9 [$ D4 }
          {# F  p+ f1 B( p
                    ex.printStackTrace (System.err);
  b. d. J: A: b           System.out.println ("Error message goes here"); // Replace this error message with your own          # ^" E# \. J0 Y; s9 ]; a  L
        }
( N. e: P% o8 Q                return true;
2 y+ `5 R: ]/ p, f2 ?        }0 ?3 s" q0 f' Y8 R) D8 k/ ~

6 a/ E/ `' o$ m' V- t; B: {: E} // end of class ProgramCompare
7 j8 t5 j1 D$ @( r' Y  ?( I& N9 M
. E* o" W# e4 `8 b' T//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************& {4 j: ~! T7 u) E! Y
//  ProgramCompareMenu.java    Provided by: DRS! E/ P+ g' R& A) ]6 x
//& B* a1 C1 }/ P7 b3 X
//  Calls AuthorisedUsers.java and ProgramCompare.java
- E6 \' z, @( l//1 I  g3 k' H6 g! ~- K
//  Driver shell for Assignment 2.6 `+ R/ p; j8 ?7 p8 o
//********************************************************************: V$ a6 z+ W' I+ V3 ^
8 d$ N5 D+ q2 \3 X8 A; D8 M
class ProgramCompareMenu" k# Y5 i0 z/ q
{
6 v, U) L9 w! H: }+ ?2 x- z    public static void main (String[] args)
$ g9 S3 p4 }5 W4 C- e            {5 o0 Y) e1 [# \* s
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable8 o6 o) K% L0 D
                ProgramCompare reached1 = new ProgramCompare();
2 C" f. w  ]" g                AuthorisedUsers reached2 = new AuthorisedUsers();        ) |$ M8 E3 v9 v3 s" m! u: i
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
7 w6 a: f8 k1 J) ?7 B; {                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        : P" ~4 M2 A& n# n) y' }
        }
" Q: u; Z! M" l& w( O0 ~# _}// end of class ProgramCompareMenu
  `7 t& ]% o5 I! i, `* h8 k# h$ @" b+ @) m5 ^  _) i" p5 U
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
0 D7 a. t5 z! K5 i//          AuthorisedUsers.java          Provided by: DRS
, q6 S2 ^* y# S9 A; m# M3 D1 R! s# D( ^//                * f1 j# i" I4 j2 ?6 Z9 M
//         Program shell for Assignment 2
, M+ y$ O1 V/ }# Q# C//: S" _) ~* ]8 e( V
//         Represents facts about an AuthorisedUser
- Y$ @# ?/ E" e, L. {//********************************************************************" X- E5 E8 w; l, M$ z  Z  d2 \8 u
" K6 M; ]( m3 q- o. B  }& b2 ?
public class AuthorisedUsers5 V$ ^) [  v, Y/ G& Z+ o
    {
3 P3 T, p( D0 v( f
6 o/ [- S# Z8 {: y2 \        //-----------------------------------------------------------------6 I2 h3 @3 P( \' ?( x: z1 e% m
        // Constructor4 k0 H8 N. |+ O
        //-----------------------------------------------------------------
" Q2 i2 {) v' w8 S
0 b( r# m: S; h$ d% t3 W- ]6 |4 k* a% H        public AuthorisedUsers()
; M' @/ s  T7 B3 H: B7 S                {
$ ]7 E" a* [  L/ t/ M1 H5 P                }
4 Z5 K- L# q# z
3 k; j* M3 M% s  K( ?! ]  a1 x        //-----------------------------------------------------------------. v, J+ o: O+ X7 K5 P$ }$ d- l3 [
        // Method for testing that class has been reached
9 ^. C5 z9 w& N* i0 p6 p0 _4 H' B        //-----------------------------------------------------------------       
& N2 `8 C1 e1 R! F" T        public boolean AuthorisedUsersReached()
% _# v: V" e2 X- i4 j# s' t                {8 ^% K+ m" h( w/ G! E2 i
                        return true;                        7 O- _' n+ X9 @$ Y+ z& C
                }
% V* s+ c. T  c5 l                + `# J) R1 I' c
    } // end of class AuthorisedUsers+ P' Z2 |9 f7 G7 Q. q% _: m7 Y
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming. j% ]" z0 u" r. k& g  ^& F: a$ m
Shanghai - 2007
' D0 e" \: I9 [Assignment 2" F# D# t6 C5 Y: o! N- a( `6 B
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)8 n' o/ ]; m) G# A% u3 U: w
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.
& K3 S1 o& A9 l# z* @* b; {The staff must be able to:
% J, U+ \7 K3 h# D" `; V Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.# Y# Q, z: {: i* @# n
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.; S$ F9 o) b% g9 M( B
 The interface should provide a menu so that the staff can:% V) U- R2 N" a' R
a) Enter the names of the two Java program files to be compared
4 E9 D, S" y* u4 X7 U. L For this assignment, it will be assumed that the two Java program files are in the same folder as your program.2 Y3 G- p# r8 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).
" D/ r& }# A2 v& u' `+ XBSA104 Business Programming – 2007: Assignment 2
' T( h5 [, B2 t# I* u6 E" j4 L) APage 2 of 5! F: C5 C0 V6 V* [( K
b) Print out to the screen all the lines of code that are the same+ S6 v; h- E' q% n8 T. M, V# ]
 Include the name of the file and the line number of the code being printed for each of the two files
. x, Q7 u  f- b! n* tc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
& c7 o/ b3 S" N4 O8 l# A5 n+ h the name, username and department of the user
* j* J' T$ [% S3 p+ m the statistics of the comparison9 \$ i7 O  V) d& ~
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different3 f! Z4 F! r$ f
 the recommendation for further checking0 T3 |( T" i" S* m7 M; g3 a0 o
- 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
5 R! \% w3 ?! d8 V the names of the two files compared
& l$ h( p5 m/ M5 L8 bd) Leave the program (exit)
- k8 b4 B' z/ g) KThe ProgramCompare class: (Total maximum 20 marks available)
* m6 N8 z- U# M9 [) K7 M2. 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)
) p$ @5 v# f9 r& w9 ~4 ra) provide an error message if the files are not found or there is a problem opening them
4 V. I4 `0 E% {0 _5 b0 t  Qb) compare each line of code1 k  B5 F( M+ ~
c) print out the lines that are the same9 \: T' {. O8 [* h$ q, w2 I0 Z
d) count the number of lines compared / lines the same$ c! h8 ?( M# a  T8 Z, c* [( b
The AuthorisedUsers class: (Total maximum 20 marks available)
. `2 k4 i0 p: i+ ?6 ~+ W" ^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), Y& l* l( s" j# O  ^, D4 ~2 X
4. Provide methods to:; s6 X6 ?( f% h4 v
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 ]9 S% r4 |) rb) return the name of the authorised user
0 A3 D, \% j) Q! @4 yc) return the name of the department of the authorised user
; M9 v5 U/ @( v+ i7 WIndividual Data (Maximum 20 marks available)0 r5 h: Z  q0 A) Y$ B0 ?
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.
3 f8 \: N, {/ j5 o2 T8 aDocumentation (Maximum 10 marks available)
+ R8 p) W; }/ |% f: d6. 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./ S5 D2 d2 i5 S' G
BSA104 Business Programming – 2007: Assignment 2* @2 T+ S; X* [4 K) ?/ M1 a
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
1 t1 M0 S7 b* ~不过你要翻JAVA的类库说明。你有下载没有?
& A5 G/ g, W# \! _查询关于对比的函数。貌似关键字是contrast,还有compare
3 {* y7 [. E3 K4 |0 R  U9 S1 T
3 f/ O( @" w. n+ T8 Q[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -6 m8 w. X& G" L
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
0 }+ ]& o( N/ }+ N7 ]可以下载到的 是 jdk-1_X_0-doc/ P4 F2 `7 N6 ^$ O

: K' z7 {' B& w! T+ h) [7 ?1 S! e[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-30 21:24

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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