找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1369|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 - @* a7 y( E4 p* J2 D) y , |2 d# \5 d1 @' h6 X* 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 | 显示全部楼层
//********************************************************************** w+ u' t" C5 P: i- q) F; m; X
//  ProgramCompare.java         Provided by: DRS
5 O3 k" b4 d, ?. P//
6 q+ b: ], B- }! e//  Program shell for Assignment 2
) R/ f1 J- B  R//! @9 H( l6 G5 T* I
//  Compares two text files line by line8 Z3 d; {5 `% n: B6 U/ q8 B+ b
//*********************************************************************
4 M9 _3 g, D5 q3 Z& s8 ~* C7 H8 M+ k* K) |
import java.io.*;" o# M" l' i! Z( z. R. g4 j

0 m5 R$ q" R' G6 s4 W) J; Wpublic class ProgramCompare
4 A, g; o0 U8 V( ]: A0 R{' y& |7 n. ?6 S% H8 u
        //-----------------------------------------------------------------5 o" ~2 V4 B1 b6 Y2 d8 J
        // Constructor- }0 O) `/ D, D; f0 A5 e
        //-----------------------------------------------------------------
; W" S: J: d5 U0 f        public ProgramCompare()/ X5 G6 x  c! W! J+ {
        {
! \. t5 C5 ~1 m+ k1 j' h        }3 Y) W2 P( M. U7 i

: o! ?1 a) j- I3 y( y$ i        //-----------------------------------------------------------------
3 t  r) K1 \% `- O, g) ^; U        // Method for testing that class has been reached8 K& I8 l  A9 M1 }
        //-----------------------------------------------------------------        0 U  ~8 U' N* b
% M0 ?' m1 _8 h
        public boolean ProgramCompareReached()        
4 m& Y: r/ y& f# [" m5 h        {
; q: q& T6 @' D# M2 d6 y/ ?      try
, r8 D2 e4 V1 e9 }7 r# ~1 d! x   {        
3 H: Q* e, m3 b6 o5 i6 b" w                       
1 Z5 D8 _. M: x2 O( H8 }' D; `                //********************************************************************
; k, {# ~/ U+ w1 t* D                // Try-Catch Statement is used to handle exceptions - such as file not found
' ^: ^2 ~$ Z( O* ?1 E3 E                // Reading the files will need to be placed inside a Try-Catch - just like this one!
3 `* Q3 j9 [2 c  R' |1 n5 M                // For more information see page 534 of the textbook4 ~9 I* Z$ P. \! z, Z8 e
                //********************************************************************
/ B& @& {: j7 v; ^* S3 M, c                    
3 a( y3 _1 [+ w. ^        }
* S+ p$ d% U+ V% N  J             catch (Exception ex) // Exception caught here and message displayed to the screen . v( ~' A8 j# W% Z2 N# \
          {
* f9 R6 G$ y6 x3 N( [1 V  F7 w. N% D                    ex.printStackTrace (System.err);4 u: R4 K$ F/ `+ u; w0 R4 l$ w
           System.out.println ("Error message goes here"); // Replace this error message with your own         
3 E- V3 Z0 L# c        }9 s% i0 T" A# j2 F- u+ U: _
                return true;
7 ^+ K+ X. J- b3 x/ E2 i- i, J# i        }7 g7 Q  ~' l1 C4 t) H( e
0 t2 b) P$ E, l: n! [6 a4 g
} // end of class ProgramCompare
; c2 M: {8 A& k2 n1 L$ w6 S# a! K3 j! H* r
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************/ N* f/ s' X- A, a" I0 ?+ h0 |9 _
//  ProgramCompareMenu.java    Provided by: DRS9 B& l5 a" [* j0 ]2 N4 v6 I" w5 _
//
3 i1 S9 @/ p* F7 k) I//  Calls AuthorisedUsers.java and ProgramCompare.java' n$ J0 Z/ k  s& A- \& K" J/ D
//- u" {) v% h6 Y* W  Z: i. x
//  Driver shell for Assignment 2.' A! P3 ^2 G/ m8 e
//********************************************************************
' J* b/ S8 ~) Z$ |+ G5 x- {; O) [% Z5 m" U, r! [
class ProgramCompareMenu4 r$ g2 y) X2 C% A  {8 ^# \' T
{
. y5 M- M1 q* U7 A    public static void main (String[] args)4 U* E( P: r# y% m8 h' G
            {
- V$ i2 x. j9 ?) l" Q- ^                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
5 D1 J# k6 E$ @9 [+ B                ProgramCompare reached1 = new ProgramCompare(); , t" G) c" x" G, G: r9 }
                AuthorisedUsers reached2 = new AuthorisedUsers();       
9 ?) m+ F& F% d6 t8 W                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
+ E; N7 F* h1 x$ M& \                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
# \: r( n* }  S2 t: O        }, b/ f  ]) L/ t  X
}// end of class ProgramCompareMenu" w# _8 o$ }5 G3 Z! k+ F3 x3 z

- E; c7 L( D! W//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************6 _) j5 h) Z2 w/ S
//          AuthorisedUsers.java          Provided by: DRS8 _$ W; m, D/ k( n9 R
//               
+ ?9 a2 X2 |2 T# O8 ~0 d" h//         Program shell for Assignment 2' L2 G) E% X& ^9 H4 Y! ~' F
//+ r1 m7 \5 s& a& ]
//         Represents facts about an AuthorisedUser
0 I. c# Q" {! p3 ^; U//********************************************************************
5 _* q8 @' P6 K5 Q% _9 n9 S* K1 |% b& y( W% M* u7 g7 \
public class AuthorisedUsers3 R/ P) W& x  Y+ \. C' D7 h
    {
7 N9 R! J! Q3 O* F6 W  Z5 |, v8 y5 ~
        //-----------------------------------------------------------------$ F' C- |- _. y  H4 |
        // Constructor! `! L3 `& o2 X7 Q
        //-----------------------------------------------------------------
5 }; x1 Z$ j8 f5 _* g, G8 G; f% C% O( `4 ]8 g1 d/ @' `
        public AuthorisedUsers()
/ J' r2 J* i9 f3 T/ Q# G) @                {
8 H( v* [. y1 e1 L7 m% f! s6 F                }
# B! O9 N+ t; N5 C4 {: d
2 [) M- g+ v- {# m. |        //-----------------------------------------------------------------6 b) n; `) d# @$ F
        // Method for testing that class has been reached
4 ]- h' f9 Q0 b1 a        //-----------------------------------------------------------------       
/ Q: X. p0 x/ P0 R( n" l& ~        public boolean AuthorisedUsersReached()
& ]& S9 q+ a& S/ }7 s                {% L+ p# d7 T2 P
                        return true;                       
9 M5 X  _5 |* d3 A; v                }
: ^$ z" f  j" Z( P' x                , E# Y1 w, |8 R4 N8 [/ W- B3 b
    } // end of class AuthorisedUsers
. c) t: f* }2 G2 k8 Q! Z5 ?4 o//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming  }( g4 P" l8 V
Shanghai - 2007
2 g$ p* K& e; ~" I$ q8 _# b8 EAssignment 2
- @& |# s; W- aDeadline 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 J2 ~! T! o  p- H# M
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.4 i; m: L, l" \  F
The staff must be able to:
1 O" ~9 S4 A- w) h Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.! B* m4 L" _( h. H9 {' B2 G
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.! M% h' D) N6 [" d% f# A& _+ l
 The interface should provide a menu so that the staff can:
$ m6 m$ b% v3 E# e/ h# _/ ?4 f) k7 |# pa) Enter the names of the two Java program files to be compared
3 P0 V, D* o0 a. P3 f3 F For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
0 T" b2 ]* k: W, `8 h* I( ]3 Z** 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).0 {1 w& |. E6 B% V6 l) Y4 M5 Q
BSA104 Business Programming – 2007: Assignment 2
8 r* M+ }: U8 s# j3 y8 APage 2 of 5
/ I4 [/ m# G$ w8 G( K/ I; C2 Ib) Print out to the screen all the lines of code that are the same
  O' V2 ?) |  `$ o Include the name of the file and the line number of the code being printed for each of the two files2 R, G) e0 \1 b* X3 t+ S& V
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
! N% j7 \, k7 C; t6 l% P the name, username and department of the user- Z4 p# c0 z  x2 C# [( T
 the statistics of the comparison5 [' P2 u% k, I0 y* Q
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different8 c( V: M3 B6 r- h7 v3 f
 the recommendation for further checking5 s. X( J3 J8 [- g4 V% d
- 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
3 a# E2 V9 L9 z$ {1 Y/ Z) {5 } the names of the two files compared# N4 e7 g$ p' c: O: V/ p
d) Leave the program (exit), G( \3 e( E6 b; R8 o
The ProgramCompare class: (Total maximum 20 marks available)/ g$ M: R9 O4 j
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)
0 H. A' d) i6 n# J4 ]9 [a) provide an error message if the files are not found or there is a problem opening them
. v+ T7 _5 K& x! }* Ub) compare each line of code
" H; o- S! t8 h. ?* n) o0 Q) zc) print out the lines that are the same1 [5 O3 E0 Q; ]; B: `# h: g, c! |
d) count the number of lines compared / lines the same5 p% B7 ]" p( T+ B8 D- b* S; f
The AuthorisedUsers class: (Total maximum 20 marks available)* c1 ?3 @. i) D
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)$ E2 @+ Y' J- P# _
4. Provide methods to:+ O3 [) h. I% H1 y& ^, E3 G& 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 match9 f: D* N2 O: l- o; q  B
b) return the name of the authorised user
6 ]2 ?( ?6 \0 z' {  z" w. `c) return the name of the department of the authorised user( w! P% K8 t% i7 c2 B
Individual Data (Maximum 20 marks available)" }, Y3 \! U1 V' V% `
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.
6 X# B5 J8 W. {. H. ODocumentation (Maximum 10 marks available)
4 u8 R: i9 Y2 W5 z6. 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.) P: k5 S7 I  v3 L! _: N
BSA104 Business Programming – 2007: Assignment 2
  X# G3 q0 V) l4 U  DPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了: t  q" }1 I0 ^0 A
不过你要翻JAVA的类库说明。你有下载没有?9 x$ T7 C' J! t1 W
查询关于对比的函数。貌似关键字是contrast,还有compare2 c6 U/ ]0 `: L
" f5 j% J. d1 l1 b' Q; O
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -2 N) g8 A, o( H, P+ Q2 H
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
' _. b. [3 h  Z1 x( h! {0 a可以下载到的 是 jdk-1_X_0-doc
7 V( P6 H; B, G% Q. a$ M0 w. S
% v8 t( y+ M, y/ ^5 D' t& a5 b[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-6-9 03:36

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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