找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1326|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急5 d. D& U9 `6 @1 v2 g: `( d ! h1 L* V9 V$ m8 N5 q! Z/ p
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************% B0 h* \! r5 |% x1 j) J) k3 O
//  ProgramCompare.java         Provided by: DRS
, D( B1 K1 R3 p8 l7 i6 N//
# w5 T  ]* l6 ~% |//  Program shell for Assignment 25 u6 Z- c. z$ Y; Q3 n
//
) P  \% [* Z/ E* E" B//  Compares two text files line by line3 ~2 d: l4 q3 w& q% k) J4 t
//*********************************************************************9 f8 Y# b. B+ S  U: X' k1 v* ~
$ c, ?# |$ n9 {! n& S
import java.io.*;
& C% O( e/ `7 Q) V, f) A
0 X! R9 l! r& b- e/ {% Y% a- ipublic class ProgramCompare
6 g; m+ X3 Q# n( Z5 i7 d7 Q/ J- B{
3 _2 d* j7 R$ \. w8 y        //-----------------------------------------------------------------2 ~9 j9 U1 p% [0 D: `: {5 e
        // Constructor8 ?  T9 e8 ], q( r* t" f
        //-----------------------------------------------------------------
0 Z5 n) K, x& j( s        public ProgramCompare()3 W# m; w; O2 ?. Y
        {  X/ r' e% H8 E
        }
# h2 G" o$ ?% z" I9 b  y! f+ }9 p& A; H/ r. |1 R5 S' A, B4 l% X
        //-----------------------------------------------------------------* J6 s) X* w9 J% X7 Z; l: Y2 T
        // Method for testing that class has been reached
: y) I, c, d3 ], A4 v, U        //-----------------------------------------------------------------       
9 X$ l' \* y! G8 w: i2 y/ T  M- e
% Z4 |2 Q' Q0 ]9 @4 u- C5 \        public boolean ProgramCompareReached()         ( n- I4 i+ M8 n$ @: W( r. W
        {
: ~$ f0 ]! K: V+ s+ b# X/ Q1 z      try
) p6 {+ V. N! [   {        
3 \- m4 e3 \) o! [                        * ]9 M+ u0 s$ M6 `. ?6 f+ V9 i
                //********************************************************************
( G4 a+ B3 u+ z                // Try-Catch Statement is used to handle exceptions - such as file not found 6 D0 f& D/ A4 n: z1 D& _6 W
                // Reading the files will need to be placed inside a Try-Catch - just like this one!4 ]. |1 W/ V; A% K
                // For more information see page 534 of the textbook
& i, O2 s' q6 w! D: G" D6 _                //********************************************************************& K( t' G& h# M4 g. |. h2 N# L: P
                    
# ?7 v8 e  |! k4 x3 f2 w        }. ~" o/ k+ P1 T  o* ~6 [$ R+ i: N
             catch (Exception ex) // Exception caught here and message displayed to the screen
: _7 L% L$ I5 H          {0 d; u4 U0 k) \% g8 Q' ~" u% z
                    ex.printStackTrace (System.err);
/ H: q6 ^/ k+ q           System.out.println ("Error message goes here"); // Replace this error message with your own          $ {) J  n2 w5 F8 Y
        }
# v; D5 r+ `' y' z8 X& A                return true;3 Q3 c7 o6 U8 a& C
        }; q/ k2 B* P' F1 c# b2 l. Q

8 ?! s# Q' N2 R} // end of class ProgramCompare0 m0 w1 V5 r, k7 u) ~0 N: w+ j

+ g- H* r/ I- r; Z//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************- v$ j: s, `/ R9 w8 j
//  ProgramCompareMenu.java    Provided by: DRS( I/ R. P) j6 F! c4 b  @; ], q7 H% s4 b
//
- m- n% J$ ]% f1 I//  Calls AuthorisedUsers.java and ProgramCompare.java
: r! j6 z) f. N, n+ N6 b/ k8 H# o  F//
6 q( S" j* m5 F% l# y//  Driver shell for Assignment 2.
( y% U, z0 |. U; I+ w3 [& u//********************************************************************
" K, s1 k0 e2 U2 A- C! D$ B7 T; |% j2 F& I
class ProgramCompareMenu. {* t5 I  X! A9 O" @! u; R
{6 s% r5 N' T2 b4 a" O6 n
    public static void main (String[] args)
4 I( p* @9 T% `: j/ u& K* s            {+ h! g! g$ l) O
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
  i1 @' }7 l3 Z- K4 Y. `                ProgramCompare reached1 = new ProgramCompare();
. G: o* Z0 W# u5 o                AuthorisedUsers reached2 = new AuthorisedUsers();       
7 W6 b8 A, t0 |/ U                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());+ N; R9 ]- x% c/ O
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        0 h6 r/ ]3 u( j& z' |
        }
3 @! _" u, i6 R! K  T% d* ^5 v}// end of class ProgramCompareMenu
7 F# @' `; f+ n7 h  k- ~: o4 q% y5 @% e1 Y3 w
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************1 c" M* l& r, t0 }
//          AuthorisedUsers.java          Provided by: DRS
0 C/ {/ `( e% N* ^) {  z5 y//               
" V6 \! g* p) O! g( Q: M" b2 P//         Program shell for Assignment 2& r0 S8 H) r( F1 I2 l8 u
//
% [. V* v  a6 h# x, S//         Represents facts about an AuthorisedUser+ \; O: ?+ J6 K5 x: c
//********************************************************************
8 u7 E0 ?) b6 B# u/ z, \9 Q6 j$ A4 [3 S8 |4 F
public class AuthorisedUsers
! d7 i" W0 E' Z& O+ b5 s# L3 e    {! Y- h3 z" n' V

( B8 W& T+ g3 F9 h: _2 ~        //-----------------------------------------------------------------2 a' z) Q' ^8 I# ~( c
        // Constructor7 I0 ^" |9 B# f: w. A
        //-----------------------------------------------------------------/ m. f8 a' |4 C4 c; I# w8 a$ Q
& X% a! I- G0 `/ i# o
        public AuthorisedUsers(). X) W2 w: S* h) c! L  \
                {
- M5 R- @: n  W7 ]6 i                }
( C3 A& f3 i3 M: M# b( H. i% h2 c$ h8 q6 G0 N
        //-----------------------------------------------------------------
- g8 d: T1 ^; D        // Method for testing that class has been reached
) t8 s5 o. d3 X( \. F        //-----------------------------------------------------------------        1 g' G" Q- H& m& L
        public boolean AuthorisedUsersReached()
; r, t* {8 t: P                {
7 {! u# e9 M* D6 F1 M5 l- ]                        return true;                        3 v$ E: Z; W6 i
                }
) e/ ~# @* C5 \4 W4 w1 R               
- h9 Z9 {3 @/ ]0 Q- M    } // end of class AuthorisedUsers
! q$ M! r# x5 T; o' ^1 a( c3 x//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
" _4 f9 @: t: E) u/ _  Q7 c+ b2 CShanghai - 2007, K2 c: _* H  u' W) A' B% L$ q
Assignment 29 }. a( G# n+ A; p3 k6 z
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' C3 Z# K# C& e/ F" W1. 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 I& u$ e2 P( |# J7 d1 sThe staff must be able to:0 D3 g. Q3 G4 Y  J9 y
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
7 I4 E6 A5 @4 H  c) A1. 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.
& e1 h+ H+ R/ f- Y( y/ O, S) C The interface should provide a menu so that the staff can:
: G- S  H3 n6 [5 J. M; I5 P- Qa) Enter the names of the two Java program files to be compared: e. f0 x8 Z" U- ^2 Q; w) l
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
7 X8 P$ R1 ]4 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).
- G2 m: ?' L/ ZBSA104 Business Programming – 2007: Assignment 2
3 s  G( I* y' b5 l4 FPage 2 of 5; j& F, D) ~7 o! a" O& _, j
b) Print out to the screen all the lines of code that are the same' d4 n8 X2 c6 C0 @* p0 D1 @1 ?
 Include the name of the file and the line number of the code being printed for each of the two files
$ R5 ?  ^, M1 nc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
- p) c; m; M- o/ i7 R the name, username and department of the user
2 d9 z1 |" X- o the statistics of the comparison- x0 o8 |: B5 N- V3 h0 x+ n( w6 s
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different% p, n& [8 N! A; e% x
 the recommendation for further checking
: b* ~1 F- r/ y- N8 K- 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+ R% V5 Z; o: \
 the names of the two files compared( }0 X' V" J# ?+ q  a8 G/ g
d) Leave the program (exit)
9 O/ u9 p2 N$ B! G, r! nThe ProgramCompare class: (Total maximum 20 marks available)1 Y4 e6 O  k: u+ y: ^
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)& U! z3 ]8 d) X! F) _
a) provide an error message if the files are not found or there is a problem opening them
4 ~5 r' D: O4 v. D' Q: \7 Bb) compare each line of code
- @& g8 j( d) D: O- yc) print out the lines that are the same
' a; n3 K# A. j) \d) count the number of lines compared / lines the same
, z; S* g/ e% J. Q. `3 uThe AuthorisedUsers class: (Total maximum 20 marks available)* j3 v1 v9 X$ t! d) v3 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)
0 ~3 V. y. B4 T$ }4. Provide methods to:# R+ _* v% b- Y
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
1 v. P  P2 W1 sb) return the name of the authorised user1 ]6 s1 m% A" R! q, p2 J
c) return the name of the department of the authorised user
3 _. B3 Y) Q+ n" ?Individual Data (Maximum 20 marks available)
2 [3 ]& Q2 P' }6 K4 }8 l3 H' o$ J5. 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.
, e) K. p! t! R9 a3 T0 ^; H8 d+ x' JDocumentation (Maximum 10 marks available), j8 |0 s/ n" v
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.
) d/ m) g5 x0 C0 e. R$ BBSA104 Business Programming – 2007: Assignment 2+ M+ s" w" M4 }" M" |0 A
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
+ |5 p- X5 @1 U  z! V% D* b不过你要翻JAVA的类库说明。你有下载没有?
. B- c( F' T4 T6 m: L查询关于对比的函数。貌似关键字是contrast,还有compare% R" ]% O' b8 x
! p$ u; G3 T" C+ z
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -7 @- l7 e$ T, z, R& o; {4 c6 n
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。0 x7 P, m* J, m1 n
可以下载到的 是 jdk-1_X_0-doc) {5 A/ I3 X1 [# t

( s0 t  m0 F) d8 k0 F[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-30 00:21

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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