找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1433|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急4 _, v ?9 k5 c 6 ]6 o$ m$ u% \1 [6 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 | 显示全部楼层
//*********************************************************************' N% E2 R+ ]1 Q/ c3 ^
//  ProgramCompare.java         Provided by: DRS8 K( v, o8 k) T' A% [9 C
//' {8 q1 D6 Y6 D7 x! [; A. b
//  Program shell for Assignment 2
/ U+ w( E4 X, {+ [! C//
5 u* ~' ?! D9 {6 @- e0 \& E//  Compares two text files line by line
6 H# m6 r/ h) ], V9 G//*********************************************************************" M; ]6 v4 Y6 R( a6 j) n2 F' N4 m( T; Y

+ m! v, Q+ |! v* C9 e. |- r' Kimport java.io.*;* k& T  S8 H. X  o2 G- y9 J

2 O8 ^$ A; f2 T8 x) \7 ipublic class ProgramCompare
* v( p6 ?4 C: l" I. g2 q* h! Q0 P{
$ ?# A" ?: ^6 X, a0 L        //-----------------------------------------------------------------
% s+ [" Q+ k! R! W        // Constructor
4 _. N% q2 C# M7 ~# J        //-----------------------------------------------------------------
/ t9 J! x7 W5 y9 k$ J0 k        public ProgramCompare()4 p5 @" N* ~5 G4 f, M6 m
        {
! |; w$ F9 p' L. Y8 Z  w/ f( j        }
* z" x6 b# v5 S9 [, m2 r
% c* K: ^% {4 ^# n/ y9 A        //-----------------------------------------------------------------
3 c5 u' s! K/ }  |8 j5 B  L! C/ @  w        // Method for testing that class has been reached! N' o& H6 d% {
        //-----------------------------------------------------------------        4 t  g: ^* W3 _
( h5 a3 i; s' a
        public boolean ProgramCompareReached()         % s, O6 R: c9 I' w& b
        {% V* @- T% u, F% O9 j' v! h
      try
2 h, d- ]4 F0 |! a# m3 l  ?   {         ) q) J- C/ q& ~& T% @9 }
                        : B! K, q; e" O3 ?6 ]6 `
                //********************************************************************
' \" Y7 J) R8 i9 a  `                // Try-Catch Statement is used to handle exceptions - such as file not found
  y2 y* ]; y- o* y& z                // Reading the files will need to be placed inside a Try-Catch - just like this one!
( \6 M# `: W# c2 y5 J# k# t! j- J                // For more information see page 534 of the textbook
$ B1 d7 p8 e" S/ z2 x! U                //********************************************************************+ V! f2 H) B' p- l5 n% F
                     * f# v8 j& w3 z* A; m0 S
        }
6 p3 c3 L# o8 d# H( |             catch (Exception ex) // Exception caught here and message displayed to the screen , v' N5 q2 |# w! {& }2 D
          {
; R3 e; C% C6 R' [                    ex.printStackTrace (System.err);, u' t$ @& l8 a8 h% }" @+ Z
           System.out.println ("Error message goes here"); // Replace this error message with your own          # ~& A/ e; L4 w; {7 K; @2 J/ ~; P4 r
        }
& D6 N6 Z& q  L# J. q                return true;
5 z, ]3 e- b( F' S0 j! L        }
! u# K: ~# Q+ V7 T: F4 }( |) `+ a6 K  o. J) N; B; r5 L* M5 ^
} // end of class ProgramCompare
, S9 p- P2 S1 u4 u0 d& C
' k6 }; A. j* t4 N//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************3 P' G/ g  |7 J. H  j/ j
//  ProgramCompareMenu.java    Provided by: DRS
& R& q) v) N6 {* Q8 L//
9 G2 i9 v4 h8 `: ]7 f//  Calls AuthorisedUsers.java and ProgramCompare.java; I1 T) G: e/ d3 P4 C- p
//8 }4 E: w' k/ {# }0 H2 D! g
//  Driver shell for Assignment 2.
9 @$ P( v' V+ ^0 G//********************************************************************) o8 `: \  m' n
3 |8 h0 i6 G3 Z0 A
class ProgramCompareMenu3 P3 Z4 j$ j  C
{
7 Z7 v) h5 [* X- C7 v" g4 {    public static void main (String[] args)+ Z7 X0 S5 G6 H4 _4 Q8 f
            {
/ H5 b$ }7 h9 U. d' C2 O( W                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable; d& S; Q3 B  d2 y0 `2 C+ e
                ProgramCompare reached1 = new ProgramCompare(); ' m; C, ?9 h/ i, M8 {
                AuthorisedUsers reached2 = new AuthorisedUsers();        ) C8 `! H- o$ l& y! Z' m
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
, c/ O8 K1 `: e, Z0 P: j                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
" V" m. m1 ~' [+ |        }
- l9 w  ]) d7 d6 `$ J  [$ X}// end of class ProgramCompareMenu
- s7 o% k% m; d. n& P& Z7 q5 ^5 \7 \- b# N2 s: D
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************! I6 s0 X" G! M! z& Y
//          AuthorisedUsers.java          Provided by: DRS# {$ e' `: I% b& t6 M  d/ f1 ]
//               
. G- e7 U6 g3 ^$ o2 J: m$ j) p& P//         Program shell for Assignment 2( S$ V: ~# V/ D
//" y7 c+ x% \$ J% @. m" [8 ]' a
//         Represents facts about an AuthorisedUser
; G$ a6 m& v& A6 n//********************************************************************8 t: M; Y, n/ g0 M

9 T5 r& x: `: X: `. Z" J+ A: O( q  npublic class AuthorisedUsers. d9 Z0 x& `$ h2 }; Y9 Y# ]
    {9 c* m6 r1 p" k! u9 L. n

2 `' w* X) m6 J0 H  |4 F        //-----------------------------------------------------------------7 v' M& h" z$ D: X- j
        // Constructor4 N" l4 N& i, e4 {- s( X' _
        //-----------------------------------------------------------------7 c( w& B" n# H) g, [: i' t

6 B, p0 D- q5 M/ B2 `        public AuthorisedUsers(). ?. d$ q/ H- J3 A2 x
                {% }4 ~. `9 a& g8 R
                }
$ D( g8 E, r9 O5 ]" \- U1 t3 d3 n. P) \2 F7 V: g
        //-----------------------------------------------------------------
/ b* ]# j: o" l2 F5 C        // Method for testing that class has been reached9 s1 \6 z: Y5 R; A! S+ L
        //-----------------------------------------------------------------        ; \6 u4 Z) k8 I( k9 C# E5 _6 J' I
        public boolean AuthorisedUsersReached()4 B' Z) A/ E" g/ [) d( S7 }- }
                {
7 M# }( q, e' k( p) f                        return true;                       
( }* b+ i; _  X, ?4 V                }' B: B6 K- Z; s
                6 S3 M0 D0 \$ X& [; y4 Y- d9 X9 i
    } // end of class AuthorisedUsers
" A, h1 A" U; J% T* a% n; Q" _//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming5 k! c8 F9 q3 H& g% d# Z7 [/ o
Shanghai - 2007
# z6 g$ L8 C' h" q: t5 R# j6 @) P7 hAssignment 2' u) @0 G& k; `' s/ 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)9 Z& b: o3 m: W. x+ Q. v& z
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.
( }& _* A" G6 f8 W5 oThe staff must be able to:
* r( J! |7 N  B% p9 v( z! h" u Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.- m/ ?4 {9 C+ o7 D; _$ 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 d4 j8 y& u6 _- H3 u
 The interface should provide a menu so that the staff can:
5 X/ h' I2 j! i( G! W7 H5 I6 ]a) Enter the names of the two Java program files to be compared# t5 H# M- [" i; c
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
! ]2 w( d; H( w. A  m2 A** 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).8 S: z, z% {( |- I
BSA104 Business Programming – 2007: Assignment 2
5 W8 i6 |7 j" n! N0 @3 E2 LPage 2 of 57 ~0 p" o- V$ e# b5 y
b) Print out to the screen all the lines of code that are the same' ~! M3 @" @0 h0 }" l
 Include the name of the file and the line number of the code being printed for each of the two files
. [( j# X) V/ g6 y- Zc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
& t4 X2 o# A% G" s the name, username and department of the user, `  Q! `8 E" O
 the statistics of the comparison
# L7 I7 Y% c- U0 X+ z, Q- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
  X8 U0 P1 Y: q  C the recommendation for further checking* G3 F1 [! `: o! w1 e
- 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
& u* u' {9 P) o# h4 ]  Z( N1 G the names of the two files compared
9 r( s5 a. \- sd) Leave the program (exit)
* P4 `; k3 i* G9 z6 }The ProgramCompare class: (Total maximum 20 marks available)
: D# z! A" ^+ [- {% O1 A; n2. 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)
  r  j& X2 I' o) J( x% Ra) provide an error message if the files are not found or there is a problem opening them
- F! w  K3 S. k6 O6 Gb) compare each line of code
7 N  x% v( \! @! bc) print out the lines that are the same6 l3 i+ T2 r/ U- ^; Q
d) count the number of lines compared / lines the same7 ~& ?4 O. E  c: q% {
The AuthorisedUsers class: (Total maximum 20 marks available)- Z% \# ~, Q* S8 L5 D2 b, b+ |
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)6 c$ u% U, C( m8 M5 ~: w6 c
4. Provide methods to:
" z+ b+ ~- V1 B1 Q  Ca) 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  }/ \  ~, X, m3 x; e* P
b) return the name of the authorised user
( p$ K' a$ O) X8 }. _c) return the name of the department of the authorised user
* ?, E0 z' k3 h* hIndividual Data (Maximum 20 marks available)
9 w/ a5 f9 ?( ^. I5. 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.1 o2 Q; L) A. q- @9 ?/ Q% M* r3 d  I
Documentation (Maximum 10 marks available)
  @& f1 H6 B* h  Q( r: q, `. [  K6. 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.) [" \1 i: r; G# e- I
BSA104 Business Programming – 2007: Assignment 2
' W. a; Q2 X4 S. l; k" h( S  C5 zPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
% ]6 W7 b  q+ t6 v不过你要翻JAVA的类库说明。你有下载没有?& n5 r' B$ a5 w/ x
查询关于对比的函数。貌似关键字是contrast,还有compare  d3 G  {5 A8 x; B$ a& |
/ s+ E; ]+ \" x. |/ u( g2 x" t
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
9 j* O" m. l+ ^' ]9 A. C" Q0 R痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
/ {* Y! E" k2 y: S可以下载到的 是 jdk-1_X_0-doc
7 S  J: r0 X4 R/ J) n& m, f1 _& _  x) |) x& A, u- T
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-7-3 11:29

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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