找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1310|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急0 N# ^+ P; Z/ r$ q- l ( S f6 r: w$ ?; n5 O
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************7 A( B' S6 {: \( j7 G- S. Z
//  ProgramCompare.java         Provided by: DRS) P9 D0 S8 k$ H- g6 b8 O* [
//( e2 l+ ~) Z; u0 `3 `! P
//  Program shell for Assignment 2: x0 Y  p; ]2 I3 Y8 U/ J0 e
//
2 J" `/ i7 S4 d) D//  Compares two text files line by line
8 U) e& y% E8 W) D$ m8 Q//*********************************************************************$ R4 W3 K3 ^7 h9 n6 U

" j, U: b$ q9 C4 l( L. ^+ b0 Pimport java.io.*;: V3 h  t! F# W% w# s( X0 ~, D$ f

9 s3 R3 j; V" W5 Z+ Xpublic class ProgramCompare
. C% j4 L$ A/ k{, c6 g3 y- z, L7 S2 T2 q3 a
        //-----------------------------------------------------------------% ]* t9 C1 V$ {* V, q1 {
        // Constructor
9 `  ^6 `- v8 D) P* F        //-----------------------------------------------------------------+ Q+ \: h  D# @5 R+ ?. {
        public ProgramCompare()
4 }) k) }" Q0 f6 r3 c+ f        {* X0 y. }4 b2 [# T! Z4 `- Z, N1 i
        }
+ F# ^/ X% U) K: W# a  W9 P+ F2 M( v' R2 i+ O
        //-----------------------------------------------------------------7 K0 K7 u# V* Y' U- f4 u- x/ `& s
        // Method for testing that class has been reached
4 t0 k3 \1 I0 S& v/ |  m: O6 C        //-----------------------------------------------------------------       
0 I$ n& T; V! p
; T, K; [+ Z) q3 F  e/ k% [) A        public boolean ProgramCompareReached()         + n8 j# z, y. x# L2 A1 S9 D( O
        {
- s2 O$ o. u! W! b, s( i      try
/ j. a/ ~' E+ o* n2 @9 b   {        
( e6 W+ ^2 ~) N6 K; {& Y: n                        ) Y3 h0 v6 k; v! `2 q) A8 l9 F
                //********************************************************************
  \$ ]. Z9 s! \' B- e4 `% z                // Try-Catch Statement is used to handle exceptions - such as file not found 0 F3 u  v& U$ k% c4 b1 D' l8 k& u
                // Reading the files will need to be placed inside a Try-Catch - just like this one!- T* a5 I: l' Q1 O# w$ ?3 ]* H6 D9 J
                // For more information see page 534 of the textbook
2 |! d' r7 [/ e. `$ {/ d& [                //********************************************************************. v2 k% y  n% Z0 i3 Y
                    
+ N* ~7 E* G8 y        }3 N/ z0 r0 u* w9 d9 z: v
             catch (Exception ex) // Exception caught here and message displayed to the screen
5 P9 q: l# _# U$ N: a; W2 [7 q: _          {
9 x# f$ z# H8 b6 l7 b+ E% ~- F& [% O                    ex.printStackTrace (System.err);
3 E1 R2 F8 T  `           System.out.println ("Error message goes here"); // Replace this error message with your own         
8 b& D' c4 `  g& q  k. a4 |        }
& ^( `( p- t) @  W8 L                return true;
- y* O, j3 J! o; K8 m1 V        }2 U8 M/ |- f5 U3 Z$ x/ w2 Z

' w6 N* s3 [% u+ g5 e+ J4 k$ C} // end of class ProgramCompare
7 B8 E9 q3 J$ R& f: B7 l$ Z) t% _& v1 B' j5 R: F0 n3 z9 x
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
) X. V6 \( p1 B. U+ k% ?( ?, T8 b//  ProgramCompareMenu.java    Provided by: DRS5 i6 T( m# ~) J; a% v6 m' r
//( S- X5 E/ a: Z5 p
//  Calls AuthorisedUsers.java and ProgramCompare.java6 @/ q# L; z$ W( J0 X1 Q% f5 \
//
7 f- D5 Q7 q9 I" n* L  t& Z//  Driver shell for Assignment 2." g) K* t3 T8 H& p: Y
//********************************************************************
: a& j2 z3 l7 T( B3 K3 b1 i/ Q; X! a5 P. z+ m8 h8 o2 i. p
class ProgramCompareMenu
* c$ m9 ~5 |' V$ L% @{
0 n: W) X5 O* S    public static void main (String[] args)  P  i8 X! j' {% r4 u
            {/ ~5 d; Y7 a! O% h3 T
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable0 ]* P# }3 m4 f8 p
                ProgramCompare reached1 = new ProgramCompare(); - `9 u- I3 {# z4 o' o3 `
                AuthorisedUsers reached2 = new AuthorisedUsers();        9 l. A2 q  B* f, ^' e, V4 {! D
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
1 G; B% {( @: i9 `, Z' P                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        3 C+ x8 W) Z3 y. r" o: s
        }% D1 L/ \( g, h, {/ Q
}// end of class ProgramCompareMenu
! p3 {) c9 P. @2 d4 ?, J* r; n2 }
7 i* {1 z4 E: o# t* N: \$ W; X//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
( r8 x) ]7 ^6 {( w//          AuthorisedUsers.java          Provided by: DRS
/ H& c6 F" ~/ [4 f//                8 ^  R2 \% s* W# i( j
//         Program shell for Assignment 22 a" l& r; C& F' U* I; V$ P  n
//: F0 ?" t8 B; o& S' m1 D& Z
//         Represents facts about an AuthorisedUser
4 e6 m3 b5 I6 s$ [* \& v//********************************************************************! n: Z* }# E' Y7 G* f  q' a3 x

# F" r4 `: U- h3 jpublic class AuthorisedUsers, B/ l# S3 \" v
    {! ?% b( s0 m, P2 s3 y0 `

+ `! E7 d+ F! p! l% |        //-----------------------------------------------------------------
' e( o5 Z5 `* X5 s( q! ~" J        // Constructor: |$ n- B: c- N2 H* N1 _: d! o, {
        //------------------------------------------------------------------ W0 z* j: [0 d6 N

' W& v0 y1 i( y        public AuthorisedUsers()
' c, d# l+ B8 r& r                {
9 `: U, F- I! i4 b! z: d                }
# z; p( `' H1 E. k5 C" b
. _' u" }/ P% s+ h) z% ]        //-----------------------------------------------------------------
6 G9 b9 p( D: K8 G& {* ^        // Method for testing that class has been reached
) S, d& |) t% \7 n6 k9 E        //-----------------------------------------------------------------       
% n% @1 e9 t0 X9 P$ I4 P' S, V; \        public boolean AuthorisedUsersReached()
; n7 c3 A# g5 d( _* [4 r                {/ @- n5 k; J4 N0 D
                        return true;                        ' T0 T- N  }; s8 X9 _+ s
                }# n- n& p  E" q0 V4 l: U1 D3 V& p8 A
               
' d8 X. f6 g0 g4 o    } // end of class AuthorisedUsers: }& y* P, J$ c7 s% T
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
  m) g& \0 d  M- i1 \% HShanghai - 2007
$ x9 r3 M- l, i7 z, H2 r( zAssignment 2, m6 g' B; H; ~; N$ p6 J
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)
: i  w1 _/ x6 D- b, R1. 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 I$ d% D+ |; i# M+ }/ IThe staff must be able to:
, Y# U# E% C  }* f, g! \/ ]7 \' j Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
( N6 t( u) F4 m+ ?/ c, b1. 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., T0 N  @2 J9 |; }+ P
 The interface should provide a menu so that the staff can:
- K- i6 s0 m- t4 X9 Ea) Enter the names of the two Java program files to be compared
' F6 b( P4 B% D+ f0 V0 N- V: M For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
. r& S3 z4 c% J** 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).
4 @- c% V) l* r4 a$ q* \& @! ?BSA104 Business Programming – 2007: Assignment 2
) Z& D" K* u  K+ C$ B9 h# |7 @, t$ ~Page 2 of 5# ^7 g; l( N% c2 |3 N' e; K1 o
b) Print out to the screen all the lines of code that are the same' ~6 A; h  ~  V) d, }# ^
 Include the name of the file and the line number of the code being printed for each of the two files
/ c9 _- c- d) J' Cc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared( K2 @/ v9 q; ]/ A
 the name, username and department of the user
1 o, k$ C& b* z; u) L% V the statistics of the comparison
0 M( M8 E+ Z9 i( |) ]  @- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different, e. a& z/ U& b& f. t7 S/ j* M+ v
 the recommendation for further checking2 K+ F8 |& k" v5 P  M1 A+ ~' z
- 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
7 f- n: [9 V% }. Z4 v the names of the two files compared3 d" m6 X. f% y9 ~$ C
d) Leave the program (exit)
' S8 v+ J* k* l+ k8 OThe ProgramCompare class: (Total maximum 20 marks available)
9 g% p; B9 Q. @0 o3 x- Q4 e+ a2. 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)3 X# X: p8 E; }. |7 E- T) p. V+ b
a) provide an error message if the files are not found or there is a problem opening them" M1 |2 t4 B. w- ^
b) compare each line of code$ D/ w8 {6 K8 H
c) print out the lines that are the same
8 x0 u* P0 s/ ^& L* g  Fd) count the number of lines compared / lines the same1 h  W+ O' f7 d2 f  k9 W- S' g
The AuthorisedUsers class: (Total maximum 20 marks available)
: V, s+ l! S7 V) 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)
# a) L6 f8 A; T# U4. Provide methods to:
4 g9 W9 D4 C* I( E! x2 Ga) 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
+ i8 m$ k! b! r8 f. Sb) return the name of the authorised user
/ M0 L. M* [! F, G. t# p; _" bc) return the name of the department of the authorised user' n% D0 @/ {) I& j, p' ~
Individual Data (Maximum 20 marks available)/ N6 p" ]$ }3 K3 N$ Y+ T) c$ l& @
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.
' C5 _  t$ G2 X6 t+ I$ G% B( DDocumentation (Maximum 10 marks available)8 j3 t/ ?: k. M, z$ J/ I
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.+ q$ N: V% R" |6 X2 e& `: t0 ~
BSA104 Business Programming – 2007: Assignment 2
- Q( r( y- Q' |7 KPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了+ ^, {3 t; |6 k  e
不过你要翻JAVA的类库说明。你有下载没有?  f4 r$ c0 ?, I( |
查询关于对比的函数。貌似关键字是contrast,还有compare
8 }" y) ~) `7 Y) }1 e9 ]3 o: t9 f4 V" l
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
/ y9 e* u( B0 _/ g3 r4 }痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
, y4 t/ J2 B9 m% o5 [$ L可以下载到的 是 jdk-1_X_0-doc
; y; a+ ~  M+ p9 I6 T& M" ]* x# K2 c
- |5 O2 ?" A# k$ `. |[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-24 07:15

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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