找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1331|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急) g) F/ S& q" B K9 ^7 Z0 Q: p 2 ]) _' ^/ b- l5 e6 ~" J: {- q
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************8 d2 [& R5 O1 g1 C( z* C& M" Y: C5 ~$ z
//  ProgramCompare.java         Provided by: DRS# @' B% m% J* m# M
//
5 _( \' S6 ~# d. W" J" I6 N) ~. b//  Program shell for Assignment 2
! a3 Z$ S/ w* r//
, P; e! J6 H& s/ ^  `//  Compares two text files line by line' }6 D& n9 \2 H* |3 A3 B5 ^( i
//*********************************************************************# O9 e* I* @  ~6 n: }
& i) x! i/ ]" ^3 b7 A
import java.io.*;( s6 p3 f: M5 q& a% f- ]: g+ ?/ r

2 ]! T4 W7 H7 x# epublic class ProgramCompare1 c& z' ^3 w+ y! e; R
{
# m5 ]" l7 d/ U7 D% ^        //-----------------------------------------------------------------
; `/ f/ ]5 `7 |        // Constructor- U# L* Z  i/ ?
        //-----------------------------------------------------------------
$ h0 x6 P7 m* {! a4 |        public ProgramCompare()
0 H" n3 N' B# A" M3 h: d        {, f: p  e3 _, C2 ?7 q8 q# q5 d% R
        }+ }. P5 g6 m) H
# ^) a0 U( B1 \: D9 [& q
        //-----------------------------------------------------------------+ X7 Z, _- D6 \8 J1 @: i
        // Method for testing that class has been reached7 l* N4 {! E) \
        //-----------------------------------------------------------------        # E. D) P6 T* ~# Z2 o: K$ f
) U) b( s, A5 N/ W) B- g2 Z2 f2 x$ x
        public boolean ProgramCompareReached()        
- ?) {8 M1 n8 I' Q1 m6 m        {
+ P) Z. Z$ \9 s# f3 k: e* V      try ! Z" L. ~! Z9 U8 ~
   {        
) N* x* \5 g; a$ ~" J. m! G                        & s4 z  S2 p( a$ N" Y
                //********************************************************************
) X7 J' N' i0 L+ w                // Try-Catch Statement is used to handle exceptions - such as file not found 5 x2 P- T/ G8 x# k- h& v' {/ @* z  B
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
. E$ {4 z6 Y. P                // For more information see page 534 of the textbook! l3 W! j" d( \0 J
                //********************************************************************
7 Q2 ^1 x* |* `8 h4 n; y+ |% h                     * j& Z2 O& c" H7 O3 L
        }) M! \$ ^; W# ^, z  e
             catch (Exception ex) // Exception caught here and message displayed to the screen
3 r' P+ z7 M6 l" W; i* a, ?3 i          {8 q8 J1 [6 r, n
                    ex.printStackTrace (System.err);
; J. w7 v8 V5 t1 c4 F- i           System.out.println ("Error message goes here"); // Replace this error message with your own          & U4 M2 e6 y' X% U
        }4 P& I5 f' J9 k
                return true;
1 K* A' H/ O$ q: X6 ?) z' `; m" i; P$ x        }: A, M% A" ?' `3 B) @
% l; T+ D0 I% r7 F1 D$ S
} // end of class ProgramCompare7 A! |. `; L. I5 P3 b
* Y% `! V2 P$ s) _& h  V
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************" G% V& T6 @7 d  U
//  ProgramCompareMenu.java    Provided by: DRS  A2 g! s: r$ d- [9 T0 ?% y( @+ r
//7 u+ q9 R. N5 E0 `. j$ m  o
//  Calls AuthorisedUsers.java and ProgramCompare.java
9 V3 I" e" {4 r# V6 a+ B//2 ~( L  `2 s! k
//  Driver shell for Assignment 2.
' T8 {: d7 m! z5 g" [! j' b3 j//********************************************************************4 h+ D! c* ]; a
' d( r/ y5 m7 Z% v
class ProgramCompareMenu& R# I4 i5 A4 _$ n1 }
{
: p5 w9 U' _$ k( s0 d    public static void main (String[] args)
3 V- S, z$ a+ A$ t            {
# I. x3 T7 k, e! R                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
. A6 U: y& [* r1 o) M3 Q1 r                ProgramCompare reached1 = new ProgramCompare();
3 U# i, I7 s; i, J                AuthorisedUsers reached2 = new AuthorisedUsers();       
0 H# R1 o1 v. o( W5 B3 A7 }                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
. ^6 C2 ^, X4 W3 A; }4 ]. Y; P& b                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        , H% N5 g: @  N2 k# `
        }5 L! q- Z1 d  G( L% U6 E
}// end of class ProgramCompareMenu
" N4 ^& k1 h# ?$ L" w; M  g4 P- a; j) W4 b
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
# f: D# e# _: R. Y$ @//          AuthorisedUsers.java          Provided by: DRS1 |& F/ M3 L. M2 ?, p% K
//                0 ]9 y7 d( r; |
//         Program shell for Assignment 2
) C; g2 o2 q9 `4 g. j7 y. r4 x//& |' t& B& ^" q0 D! D4 H, U' R  ?
//         Represents facts about an AuthorisedUser
7 Z1 n5 ~; [, W' [; L0 J2 Z0 K//********************************************************************
7 W$ b$ y( J, t. F( f) c$ y8 L+ G' W) J8 _+ t5 B( N8 d$ `3 E$ Z
public class AuthorisedUsers
- _! `) n& v7 m5 y    {; z; o! p( e, `& |5 P8 B
- d6 V2 |/ L' R5 ?* Z# ]* V
        //-----------------------------------------------------------------+ k" q& p; V1 A% x9 I# ?
        // Constructor+ i; [% |" n& d2 {% ?( i
        //-----------------------------------------------------------------+ a. x% t+ P) d$ P  G2 E, K
  i$ g; T; e! i0 q% ]
        public AuthorisedUsers()
4 p4 [3 F9 _5 b+ B( y6 }0 Y                {
" z3 d: B9 {( m- m. S4 p* s4 y                }
  ^% m  I3 q) q$ ?& R$ k# T% ^' Z; m$ C
        //-----------------------------------------------------------------8 V9 W  y+ l( q- ~# U. k
        // Method for testing that class has been reached
/ U! D# h: n: ~3 _4 S        //-----------------------------------------------------------------       
- [6 e+ B3 Z/ w7 y- X0 c        public boolean AuthorisedUsersReached()
! q# G1 G' X4 X+ B$ n& f& D                {% M: r! Y9 ]& @; L& @
                        return true;                       
1 I( ]5 F2 [) L1 d- D; V                }
: r. F0 {- o# c                ! q5 D$ t) A- X  S4 ~  K4 @3 L
    } // end of class AuthorisedUsers
! \7 B6 t" x3 @; w9 u//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming# J7 x; B( }8 Z# [: r
Shanghai - 2007; J3 g7 ?" F& a
Assignment 2( n! U9 P' I; }' 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)4 z; `% j4 t. |7 O
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.
! t0 |" q0 g. O1 t7 {The staff must be able to:
6 |, `* t4 a  q& ] Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
2 y' \7 w+ n- s1 [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 {4 Q2 b/ @' X; e
 The interface should provide a menu so that the staff can:
" ^" p# a4 u$ V& ?# Ia) Enter the names of the two Java program files to be compared
* M& Q+ b6 ~" M" C$ b For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
5 x( N! Y/ k2 S6 |. o** 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).2 |! E  y8 _7 a* \
BSA104 Business Programming – 2007: Assignment 2
3 b, x0 v! }# c: N& ZPage 2 of 5& A. P6 V5 h. l+ p) w6 N6 s
b) Print out to the screen all the lines of code that are the same0 N! g9 N$ ?$ @& p) \2 f0 y1 b
 Include the name of the file and the line number of the code being printed for each of the two files
7 W- m3 ^9 o) \; Z, R4 y" Fc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared* v3 t! T& A9 w* j
 the name, username and department of the user- b  V+ i4 P) k0 d; X
 the statistics of the comparison4 ~) G* V/ o0 S  R0 O8 b
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
3 L& r. F7 I5 d: Q( _7 v# S the recommendation for further checking
  u/ N! B/ {  j2 x& b- 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 closely0 A% @$ d- N# @( z& E" |
 the names of the two files compared+ N: U9 n* m& L8 f
d) Leave the program (exit)* f% c2 ^, i2 a8 E2 ~
The ProgramCompare class: (Total maximum 20 marks available)
3 [6 `! _) n. h2. 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)/ ?) D7 M; |' B+ Y2 m( ~7 ^
a) provide an error message if the files are not found or there is a problem opening them
2 g  F9 `0 w+ Q. Q3 v: Db) compare each line of code
% @+ m' X/ E' s5 s1 Y% Lc) print out the lines that are the same5 k* C1 P. t  J( d
d) count the number of lines compared / lines the same
3 n0 |! K& d7 T+ f  KThe AuthorisedUsers class: (Total maximum 20 marks available)0 k0 g" u8 S2 ]7 F: U
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 f1 b& k' D# k4. Provide methods to:
2 {" I: [+ c8 M' Ha) 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
8 Y( C! P- F8 X3 g2 e9 V1 {( Zb) return the name of the authorised user3 T, {! N: g1 ]; [4 e* V9 y. u
c) return the name of the department of the authorised user9 D; _8 ?. G% e3 l+ c9 L
Individual Data (Maximum 20 marks available)
: o5 M" S1 h* a2 t  T/ E8 v5. 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.
/ |& M+ P! V% E+ p" b  I3 i' zDocumentation (Maximum 10 marks available)
2 m' @, l7 ]4 q6 a! U6. 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.
9 P! e8 _4 [1 R! h3 kBSA104 Business Programming – 2007: Assignment 2: s, E9 \! b! M' P' T2 Y
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了* q! K3 q) z% O' x3 K# [
不过你要翻JAVA的类库说明。你有下载没有?- s; E% h  E2 n$ ~) j
查询关于对比的函数。貌似关键字是contrast,还有compare
# Z. G8 O! P$ n; @8 Y  u; O1 W  B3 e! I8 L2 S
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -+ s9 P# O! P9 O4 L5 ?0 |# F: k
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
( g& B! M7 Q/ _" B" P可以下载到的 是 jdk-1_X_0-doc
7 a6 N) a8 B: ]0 F
1 r+ O8 V: l) l( Q. j! m, d, u[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-5-31 08:21

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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