找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1718|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 7 y5 b4 y- ^! b% Y4 i& E7 m7 o% X5 G3 v
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
2 U# L& l( Z! X7 g0 ~/ q2 B1 x+ ]9 O//  ProgramCompare.java         Provided by: DRS
1 {7 f: |# f8 Q+ W! P2 z//# |4 d/ }0 J7 g/ E6 z
//  Program shell for Assignment 2
& V) e8 }6 j; H# [+ x//
; E6 }/ Z5 }' M. ~: R//  Compares two text files line by line6 U1 w1 e6 W0 }7 b  ^0 G4 Y
//*********************************************************************
, I4 Q0 ]$ T3 K$ v7 a" a5 s- _/ @
- @. x9 H/ V0 D% himport java.io.*;- e0 [2 @8 V9 ?
; ~8 V# X0 g7 s
public class ProgramCompare
1 F1 x# T3 k" i{
8 M( f7 ^! q0 A: C1 P6 u        //-----------------------------------------------------------------
0 ?' M3 Q7 l$ `: t9 h3 A: R        // Constructor# d+ J6 L2 V8 W8 ^! V2 \8 o' Q
        //-----------------------------------------------------------------; E# F6 `- `, y1 C0 ?: |
        public ProgramCompare()
" d2 ]! M- V, q3 P. A        {
0 D: g) ?! T. j        }4 e& u9 ^/ e+ s) ]7 Q! `3 S

0 I0 X, y9 G4 e; c3 `( k  e6 L        //-----------------------------------------------------------------
1 ~; T$ k( a$ x8 Q5 M& i# A" u        // Method for testing that class has been reached
" }) ]5 y# W  z        //-----------------------------------------------------------------       
! e2 I8 ]9 o8 u' v- B* i/ y# M1 `, ^* j& v3 Q
        public boolean ProgramCompareReached()         ) N9 q" G6 S* |5 o  L$ F! i
        {
. B4 L3 n4 K2 ], V, I) b3 S7 l      try
  x8 C0 A6 R) t9 }2 s, [8 N% w   {         - Q1 R- z! y) l1 K
                       
5 U8 e1 n, N$ g                //********************************************************************5 n# ?% {4 K% T: M$ z! s# ^8 r
                // Try-Catch Statement is used to handle exceptions - such as file not found ! J6 l9 ]" L8 ^! @: U
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
* Z9 o7 V5 Y# {/ Q& M# n# }/ u, @                // For more information see page 534 of the textbook4 P/ C. s* \6 H5 g. U/ C$ N7 \
                //********************************************************************
( C0 c7 A% b# _, D- g4 ~0 k; x                     4 w' P  M) w0 b; k' R7 }
        }0 V& O% F/ m: D0 [5 h
             catch (Exception ex) // Exception caught here and message displayed to the screen 0 n' R$ i  ~4 q" G
          {. k$ l" t4 ~! x
                    ex.printStackTrace (System.err);
2 h$ b6 [5 ]: l           System.out.println ("Error message goes here"); // Replace this error message with your own          # _( S; w4 V, O8 K. w) c
        }
1 P; p9 {. i6 }3 {                return true;) l1 [* i7 Q" \2 k) R7 Z
        }( o$ h. x, M. f
. I" N5 n% D6 b: H- i  G
} // end of class ProgramCompare" @1 ?) Y# |8 m+ b9 R* `+ e# B

+ T" _0 T* [5 e7 E& q/ f' L8 w//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************. q* L5 ?0 @; g! B6 f) N* E: m7 Q
//  ProgramCompareMenu.java    Provided by: DRS. L& F" Q# t. ]$ l: P$ E# I, [2 |) v
//$ b5 w: O; C- ~( q
//  Calls AuthorisedUsers.java and ProgramCompare.java1 c  }. D9 u. E# o3 I" w. h) N/ p
//  u* N. U& t  p2 [0 O8 n! g) Z$ E: G
//  Driver shell for Assignment 2.
' j# G2 ^$ a; x2 Q//********************************************************************
- k9 Z7 r5 T4 ?( Q. n
$ h1 }9 \( t* K0 O9 C8 ~3 zclass ProgramCompareMenu9 M4 q& X* ~- n$ B" N
{3 u& q% ?  @' J0 q
    public static void main (String[] args)+ E4 ]+ j9 i( Y9 Y0 z. c$ Q6 s
            {
: P! E6 C" e& ], j9 W# B                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
4 G/ j2 u3 ^$ h# _* P) h) m                ProgramCompare reached1 = new ProgramCompare();
; z. O8 J9 y# v' L                AuthorisedUsers reached2 = new AuthorisedUsers();        . P1 v( B  c6 X4 \
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
  t! e: x- D) c4 o: ~1 M9 U  n, z                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        $ p- A+ y) K1 o( B
        }
% u: A/ Z* y# P# ^}// end of class ProgramCompareMenu. z, R, |2 }% p. J

0 u' u' ~: s% J; W3 r, _8 z//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
! a, N) `. w+ [6 j6 e' z//          AuthorisedUsers.java          Provided by: DRS
2 A' B& h2 B* u3 Z# a8 Y& n9 u//               
# e: f1 z/ e/ B7 m$ s- ~) k//         Program shell for Assignment 2" S; D) [6 e: ^  @
//
, Y5 B- ]$ l: l, ?7 t//         Represents facts about an AuthorisedUser6 L8 h" w1 `1 v* }% I
//********************************************************************
* m7 P% [% u) w; N* U; c6 i# r! o) N/ L. T
public class AuthorisedUsers
, R/ J1 I" I% v/ d0 |    {3 r! |& n" t. W3 \) t; R' o
# T  j, D+ ?8 [+ z3 f
        //-----------------------------------------------------------------+ H5 x7 f2 K7 A0 s# [
        // Constructor" Y! B2 n5 R  z+ X6 h! v
        //-----------------------------------------------------------------: g1 L* A5 X6 ]6 c' r3 B& C
) T9 @6 s7 U1 h7 k. k8 E
        public AuthorisedUsers()' g* G; ~( O" Q5 n
                {
7 C3 B/ ~5 m4 X! I                }+ W1 _: m& K' Z' @6 M
8 p1 W% v# j( O0 o1 B
        //-----------------------------------------------------------------7 d: c7 |0 d% R$ X) `! h
        // Method for testing that class has been reached
1 l  I- |/ N0 V, }. ?) u        //-----------------------------------------------------------------       
6 F$ V: H3 F, a3 B) l        public boolean AuthorisedUsersReached()
! P4 I/ Y4 J7 j. x, ~* V                {0 N3 P: o; U- M8 W3 J, m- J* t
                        return true;                       
$ {9 V( C% u, ~% G  _                }8 G2 X9 s+ m8 q& G  r
               
& |, h, ]3 w# w" x0 g' b2 L8 v    } // end of class AuthorisedUsers
3 O) }  }) A" o# g4 a7 Z% x//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming+ s- m5 L' R- L9 \5 A. H
Shanghai - 2007
, L1 x' N% R6 O4 E$ L- F; Z4 sAssignment 2
8 b8 r2 T0 z. H, t8 MDeadline 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)" c8 V8 j0 j! B$ V5 {3 v
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.
; Y( F0 I8 [) E0 C, MThe staff must be able to:
6 V* _5 E" m. J Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.9 _, r7 B9 B# c
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.8 c, v1 Q+ ]. J, \9 c
 The interface should provide a menu so that the staff can:
8 ~$ |# q4 {6 L' T3 J: u- oa) Enter the names of the two Java program files to be compared, x# w9 B' ^* i( J8 @1 r: d1 W
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
: J* F% X3 `; U5 Y  C/ L. y3 u4 d** 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 ]' a. Q0 J$ PBSA104 Business Programming – 2007: Assignment 20 G# i/ c+ h1 l+ s$ [. q$ n1 r% {
Page 2 of 58 _3 o3 N4 b+ |; A7 r
b) Print out to the screen all the lines of code that are the same
% F* y) N+ _3 n0 ^ Include the name of the file and the line number of the code being printed for each of the two files
& {2 Y7 g8 s. Q( ac) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared4 K' T8 e/ R9 [8 _# x
 the name, username and department of the user
. I) F- Z: Y( T- a8 C6 v the statistics of the comparison* a& M/ W( v1 {2 ~: F
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different% ~) `2 F0 ?3 z- N4 K
 the recommendation for further checking
5 R( D) z) I+ D. P& S- 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 F( H4 ?8 n4 H4 Y  L; X
 the names of the two files compared8 r5 Z( A: D7 W! i9 p5 S
d) Leave the program (exit)
, [% y2 O( r! F0 k3 ~% E, ZThe ProgramCompare class: (Total maximum 20 marks available), I6 X' N% p- z: [
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)
; \- S' o9 ?% J: U  Ja) provide an error message if the files are not found or there is a problem opening them
6 F" d: S  @; c$ c, Rb) compare each line of code3 Q5 {, F% t5 j) t
c) print out the lines that are the same
# M+ E2 C4 ~) Z: l: ^d) count the number of lines compared / lines the same7 R) x+ d3 S5 N% u
The AuthorisedUsers class: (Total maximum 20 marks available); o3 L, T) d3 D9 n) }
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)
: i% Y$ \9 R% v2 W: j( a" g4. Provide methods to:5 e4 `' ~: j+ @, `. ?! [: A
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$ J+ K/ T* T, q0 c, A
b) return the name of the authorised user
+ C- p5 [, P' z, k/ u# E' h5 rc) return the name of the department of the authorised user9 i5 K) ]: l( s9 h( F
Individual Data (Maximum 20 marks available)
/ N( ^  t2 X" S0 D- [: Z3 W5. 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.( L2 o% ?- O9 z# n% p) m
Documentation (Maximum 10 marks available)
- C" K0 |, n" P1 ~* {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.5 G6 Z1 v: C/ D0 f5 c
BSA104 Business Programming – 2007: Assignment 2' i1 p  i; Q: K# U# S8 o8 E9 m
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
8 ~1 o& k: P: P; f1 X; [, {* Z不过你要翻JAVA的类库说明。你有下载没有?
/ C% W6 A7 x; ~/ R0 P查询关于对比的函数。貌似关键字是contrast,还有compare4 T; M' a3 g8 o+ ?  T! y
3 h6 m7 J2 a/ V5 e
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
) H% U2 U, P3 E痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
6 u- T/ q# j8 ]6 F% v7 |# B7 [% d3 }可以下载到的 是 jdk-1_X_0-doc1 Y) H# P3 z5 k+ y

2 z8 A% X& v! e& ~  c[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-10 23:21

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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