找回密码
 注册

QQ登录

只需一步,快速开始

查看: 959|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 ! r/ ?" Y- U0 X* i ! f& i0 G# {8 k) @% Q9 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 | 显示全部楼层
//*********************************************************************, I3 z  e& g$ N0 h# ^5 u8 b
//  ProgramCompare.java         Provided by: DRS
: I, B: w8 x- @: f, R" M//2 l! g1 e% |% z* P! A2 Q2 _& V3 j
//  Program shell for Assignment 21 I0 @2 c+ U* R! g: n' O1 h, S- l
//
- y2 J, S) }$ D//  Compares two text files line by line
5 S5 |( Y0 e0 H0 F. ?$ m//*********************************************************************& S; _( V5 [8 r+ f

0 X$ \3 ^. C% T6 simport java.io.*;/ x& p+ h" E4 M, e8 C- ?" @% }
9 I7 K$ ^0 D, S
public class ProgramCompare
# D. H" ]6 S% ^8 b5 s- E9 h5 v{
; Q+ h6 R, @* n. `3 y$ C6 ]5 P# R        //-----------------------------------------------------------------8 u9 G7 u4 S6 d
        // Constructor
+ s9 A" Y$ i% ^0 W        //-----------------------------------------------------------------+ M  p( I( {& y/ ^
        public ProgramCompare()) v  v! `7 z) g" H4 [
        {7 W: `- X- L8 o1 G& Y6 ^
        }' @# v0 a! g4 w# b5 b3 x
7 y" o" Z9 O$ U1 f7 G0 x
        //-----------------------------------------------------------------
  c4 K3 {0 R( A' d        // Method for testing that class has been reached
% @; c( _, ?  \& Z, W4 y" G        //-----------------------------------------------------------------       
. w* A  S2 a1 j' F3 ]2 u8 l) x3 }. a- A; O
        public boolean ProgramCompareReached()        
4 g" N$ c) ]5 m+ N, _$ a# ?9 [4 w        {  n. y+ N6 \, t# _9 b
      try
% p2 W6 ?* K2 w* j   {         ; S5 Y/ c2 u4 a8 i
                        ) b4 W' v7 v- a0 ^# a# ^
                //********************************************************************& ]( }& g! R4 q4 x
                // Try-Catch Statement is used to handle exceptions - such as file not found
6 |9 }5 L+ `7 ~( w" F1 Y0 J                // Reading the files will need to be placed inside a Try-Catch - just like this one!% I, t9 M' G* A6 T) M, [
                // For more information see page 534 of the textbook
' C8 n9 e$ b0 ^! b- T5 s                //********************************************************************
( _( u; n" w& ]; U9 F0 v0 n                     & p& g- s+ a6 p  K2 L9 I5 E! n
        }
1 v1 @- R. y- s2 q- C) [% t$ n             catch (Exception ex) // Exception caught here and message displayed to the screen % ^3 Z# M  P; A  T
          {! R; N5 d1 Z1 _2 z0 g8 G3 k
                    ex.printStackTrace (System.err);
: Z% ]8 a: ?0 _& ?           System.out.println ("Error message goes here"); // Replace this error message with your own          ) i- d) @; H# @7 U+ V! v7 H
        }
5 C1 ^* N7 e  z% R4 ?2 _                return true;* t1 l) m( }8 ~* p8 H
        }4 w4 I  U% E5 ?4 G
% l+ u; l: c/ v
} // end of class ProgramCompare7 t- ^2 F8 I: Q- |
8 N5 m9 K7 N/ V3 Y% k7 {
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
1 j% c) D; }* n- \$ D) D6 W//  ProgramCompareMenu.java    Provided by: DRS
5 y7 e- ?6 {# j1 g+ A- Z; `//
* l% O7 L8 ?  M; ]  K% ]//  Calls AuthorisedUsers.java and ProgramCompare.java+ p4 O  G% X+ ?" E7 A! _
//. g* j) w5 Z+ Z$ R% T
//  Driver shell for Assignment 2./ o& M+ h8 l! m
//********************************************************************$ j" \* L( T8 x; K
' C' }* W; g) a5 g0 T! Y9 P: T: X
class ProgramCompareMenu
! F5 K/ [& C7 l; ?5 {  @! D{
, ~) [7 a# |( j: y3 z& i( ~# ]$ y    public static void main (String[] args)
/ ]! ~$ p. ~6 s, T( i            {# i' c9 t/ `. X& k5 q6 U3 I
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
; e7 D  H( v( \1 \                ProgramCompare reached1 = new ProgramCompare();
& B4 h6 C! _5 K' |/ G- f  v                AuthorisedUsers reached2 = new AuthorisedUsers();        6 A$ V! m8 j7 o, u/ p# m3 X& A! T
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
2 w* m/ s; J! v0 Y                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
, p- G% u1 @5 l. B2 l$ i: g# q5 ~        }
6 d* j# b- ?7 a+ o1 ?}// end of class ProgramCompareMenu
7 P+ A& F' x( R) n  }6 J; g, j; g  `, r0 a, J+ r$ c7 A
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
2 e+ M8 r3 @) P3 r' o# V//          AuthorisedUsers.java          Provided by: DRS
6 X2 S- F( c4 q1 e" V6 Q//                : z1 e7 j, N7 u% t$ J8 C
//         Program shell for Assignment 2: j4 F) z9 z; R. F
//- z% E$ k# O; J3 D- t. ]: j0 s
//         Represents facts about an AuthorisedUser
- {- m0 u$ |( I$ f5 J//********************************************************************, e3 Z+ @3 N+ X( g5 j  i: u/ b
/ B5 `$ |, s' F# L4 x- j
public class AuthorisedUsers
  p0 H2 h2 `0 d4 G: X5 N    {
* h& t9 m+ E3 c2 d7 f9 I- J" W2 c4 `2 d' Y
        //-----------------------------------------------------------------+ V4 ?& ]$ d% }- {2 l- T
        // Constructor' ?5 u/ _! V. h: i& ?" m* O
        //-----------------------------------------------------------------
+ F8 A0 c; J6 Y4 v! m, }
! F* @: j7 Y4 D- ^2 ?# x# Z        public AuthorisedUsers()
0 T" \" ^( ]% q2 g8 h                {3 W' `5 @3 W/ m
                }6 f% d6 ^/ l* w1 s
- J' J: Z6 F. T: L; T/ C3 H
        //-----------------------------------------------------------------
- J. b  u; H5 t: E% y/ }        // Method for testing that class has been reached" v6 t& r2 i# ?% F' p6 A, a
        //-----------------------------------------------------------------        " q9 q7 n, c$ N# B" ~
        public boolean AuthorisedUsersReached()+ V& s7 u9 c) a2 v6 h
                {
( p+ w- o9 P2 M; J                        return true;                       
+ b  _5 l" J- p( I, \1 X                }- F5 ]0 ^1 A7 t& Y) Q: i) u
                0 C; R+ t3 ~* h
    } // end of class AuthorisedUsers- m% d. y. E) q  N
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming! N5 ]( K% ~# O# j$ p
Shanghai - 2007
3 E9 X( K# k8 l" O. X9 oAssignment 2  I% |9 F/ ?' Y/ Y% F' w
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)# d1 ~2 d% B& p# Q
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.
, Z' j4 r$ e) L, SThe staff must be able to:; u: u) D* m0 M5 ~" m- z
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
6 v- G8 O2 j4 k% }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.5 S8 z6 S  B0 E; E$ D2 W
 The interface should provide a menu so that the staff can:
2 `" N- b. w8 a# b4 s4 wa) Enter the names of the two Java program files to be compared
2 O( u) s/ G! N6 ~- [ For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
8 g: F+ S) j, {( s9 v5 ~$ 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).0 y* j. D6 B# Z3 a" D, q
BSA104 Business Programming – 2007: Assignment 2
" I/ B3 }$ _7 v: y# G- fPage 2 of 5
5 c; K3 _5 H$ l9 \* Cb) Print out to the screen all the lines of code that are the same, _/ c: z7 S! G% J
 Include the name of the file and the line number of the code being printed for each of the two files" s- V- a4 X8 i
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared) v0 c( g4 j$ ^) m6 V
 the name, username and department of the user+ S9 n1 v' K; P- u1 P4 x
 the statistics of the comparison
$ f" t7 G4 @% J* ^- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
  _# ^, O0 q* o" B$ Q4 N6 T' H; I  F the recommendation for further checking% T' [7 u6 _& f6 n; P
- 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* p: ?0 u  E$ z9 O  K$ n5 {  T
 the names of the two files compared1 X3 l9 l3 ]$ S, ^4 [8 r! `
d) Leave the program (exit)
( ]/ {7 c' d  X) MThe ProgramCompare class: (Total maximum 20 marks available)
, H" x( B' C" h3 C. {0 O) ~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)& `" j4 a' s  f6 e+ ^+ ~2 r+ o
a) provide an error message if the files are not found or there is a problem opening them
' w& }9 u3 f3 D0 pb) compare each line of code
7 C+ i4 A* O+ a  O2 P& ^c) print out the lines that are the same" e& R8 g9 Q1 z  v
d) count the number of lines compared / lines the same! A, n4 ?. j' s( M
The AuthorisedUsers class: (Total maximum 20 marks available); R/ q* ?: R9 s* x
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)' }+ g/ K- {0 ^# _6 T
4. Provide methods to:
) T" G0 D  g2 d8 {0 @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. R6 ?$ }& ~4 m: x; u) r
b) return the name of the authorised user
/ @) w/ g/ Z& Jc) return the name of the department of the authorised user
+ ], A7 \" x( q% i* p( w; F$ N- HIndividual Data (Maximum 20 marks available)) T: Z# ^9 x# W( Q8 ]- k* W8 Z
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.- b' g) F8 c  t" A: \7 n
Documentation (Maximum 10 marks available)
7 U, ^: T. |1 \' o7 c3 Y' X6. 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.
* `; m& P, k) eBSA104 Business Programming – 2007: Assignment 2% N& }8 Y5 P0 X6 s. o+ W% K( `6 _
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了+ `! g" J" T/ V: D: R: t
不过你要翻JAVA的类库说明。你有下载没有?; y. x8 \  ^1 U, M
查询关于对比的函数。貌似关键字是contrast,还有compare: Q# M# C# j1 q9 v. S: J( j

! f' C3 k9 P' x  x& {; b6 [[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
( L7 V$ v  U; i6 u, E0 I& W8 F痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
/ a. L' D* l- D, O: w! a可以下载到的 是 jdk-1_X_0-doc
( F) x  r3 `+ Q+ E
/ ~* ]) h/ i4 V8 v, m[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-22 10:38

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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