找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1828|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 $ o G6 e% y5 a" x1 [& S& B: w( ]" r: \0 @* Y$ F# X4 V/ [* D
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
. c1 e& v$ e6 w& p//  ProgramCompare.java         Provided by: DRS
( ]7 b4 a8 B6 [( M8 s! R- I//
: S9 K2 h7 J6 d//  Program shell for Assignment 2
3 U% p3 h( A  d//& `: t" d- ~9 L7 B! [! t
//  Compares two text files line by line
% @+ P) z1 B! v: L//*********************************************************************0 o5 C5 w) i! E0 d; Z2 b: Z3 b

9 f4 E- K/ U4 C$ pimport java.io.*;- e9 f' u5 X/ C5 f( |6 t

$ x5 V3 G% ~1 ?9 _: \/ Npublic class ProgramCompare3 v2 s! P8 Y7 k2 g
{0 ^& F' q% G* Q( X- I" e
        //-----------------------------------------------------------------
' R; u% p7 U4 G  p" a) n* B$ I! |. x        // Constructor7 W% r6 t. `" x% ?5 r
        //-----------------------------------------------------------------
; L4 I0 A# _  ]. V5 o        public ProgramCompare()
8 z9 W9 N+ S2 T) ?" }        {9 g0 h' g/ M: g+ T2 i, ?+ U9 D+ D
        }" q4 r4 g7 w; o# R
% _5 f8 C0 U5 L! U! X$ Q; ~
        //-----------------------------------------------------------------4 V+ C% S, n2 Q4 y
        // Method for testing that class has been reached
) f# v/ h) ]$ R/ F6 v0 X9 e9 }( K  W        //-----------------------------------------------------------------       
! C  U+ i3 q: B2 K7 r% _, q% R/ k
        public boolean ProgramCompareReached()        
1 @+ U  Y" L4 C1 x2 V4 S. |        {
. g, P9 n. x$ f2 g% z" J      try
; Z% ~% ~* ]" M3 I# ^   {        
2 i" B# k! y% O; \, X                       
& Q% k7 Y( z: G0 m: w- @  L                //********************************************************************
% w. n/ m' i" x' t                // Try-Catch Statement is used to handle exceptions - such as file not found ) K6 ]# F( |& a# ]  \+ d/ }  ^
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
1 l( q: e4 w6 ]! f                // For more information see page 534 of the textbook
7 h+ X: ^  }* Z: f                //********************************************************************; V! X8 D6 c* I2 T
                    
2 V' \3 H3 C- ?        }( y1 i2 ~7 w6 G/ V$ n
             catch (Exception ex) // Exception caught here and message displayed to the screen & d6 o* E! K3 P6 t6 n% v, r
          {2 c* V$ H! g2 U6 V% r* {" L
                    ex.printStackTrace (System.err);  s" ]' u! w7 Y! q0 ^$ @4 `
           System.out.println ("Error message goes here"); // Replace this error message with your own          9 p9 T+ G& f0 K$ j& \9 r
        }
2 w4 N$ D4 c# K9 _+ C* n                return true;! l* A5 G" c$ k( w
        }5 ^- Q/ t' K% N1 a6 t2 G
# s( G/ e8 q1 E  Y
} // end of class ProgramCompare! B* R) A: p# v5 v* S5 y' |
; G) s; W: K; y
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************. t, i7 g6 T4 s) e8 X' Q. o  y
//  ProgramCompareMenu.java    Provided by: DRS: m$ I4 R% D' s9 s0 V; R% e2 t6 F) D
//  Q4 v7 t& F1 p: L
//  Calls AuthorisedUsers.java and ProgramCompare.java
, q! [/ K0 o# Q+ f//
1 O8 W& H' _3 c2 w$ e) h+ X//  Driver shell for Assignment 2.
8 s1 n$ s/ `" C. A; v//********************************************************************1 y5 I, k2 c% ?

  Z' ?' E/ I% B2 p6 zclass ProgramCompareMenu
' Y* p1 ^6 A% d/ O) W{
9 Z" `& z/ ?$ @3 B# O  S/ X7 y    public static void main (String[] args)
4 b) B# h0 @. \) _# u& H  A9 B            {
8 I, T7 m# @8 e# ]8 t                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
1 Y. x* o# @' h% E                ProgramCompare reached1 = new ProgramCompare();
7 \" j0 E6 y. d) S3 Q                AuthorisedUsers reached2 = new AuthorisedUsers();        9 B1 t1 y% S1 _  q& g3 E8 H$ w0 G
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
7 Y* z# @% E( g% t' M# w: [                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
- s- G( z  G1 O, T; |3 G        }
8 p. K3 X* H% ^3 o; y# b}// end of class ProgramCompareMenu
8 u1 y' I. L7 [6 U+ |+ ?+ j0 \" S6 \. y- E8 B3 v
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************- t: z( J) y* ^. E0 g
//          AuthorisedUsers.java          Provided by: DRS
* {& x$ R  W$ u" C. z7 h//               
( C" m0 B- r( I/ g, N//         Program shell for Assignment 2
9 x1 f/ l5 w. O  D//$ S/ [) b  w9 }- B. z
//         Represents facts about an AuthorisedUser
) f2 ?, O" m" s7 P//********************************************************************
/ L/ D) v0 l" A" p$ j+ S8 J
# A$ l+ f6 @3 P8 ?$ v( mpublic class AuthorisedUsers
  Y* t. t, \  J/ L* b4 n  F/ R    {' v! O1 H6 L6 |8 v' S- k' g: {

: ]0 u$ H% C! ?" ?" ^        //-----------------------------------------------------------------# g" O2 s2 I6 h6 f& B
        // Constructor
' d( J9 O8 [% Z) s- L1 f, t! L        //-----------------------------------------------------------------" O, [/ i/ K  o6 W+ W7 Y4 k

% g: n# }, R& Z$ f        public AuthorisedUsers(). t" @1 x# N1 R( t
                {
3 S: r3 q4 f' n2 Z5 y                }9 M. M' M. W+ P
% U3 ?6 J: Y4 X
        //-----------------------------------------------------------------
& @# ?4 E" f8 H8 D( E$ n; u0 {        // Method for testing that class has been reached
% Q$ q- k7 R# G+ M1 N, n        //-----------------------------------------------------------------       
; Q( Q* F. O, R7 [+ B% V        public boolean AuthorisedUsersReached()
' R0 r7 y) S# `- b                {2 N# P8 L9 D' D, i9 Y. V* S8 p7 ~7 G
                        return true;                       
4 H$ a1 K* |3 ?: f! ]. ?4 C: E  L                }
/ ]9 o# {: P% f# D; ~6 g/ k4 g               
" `: f) V! {% E  H    } // end of class AuthorisedUsers# s* S& t8 Z4 }6 K. ]/ `
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming7 X, }  |7 J) V! I
Shanghai - 2007
, x4 B/ g* h: o; O$ nAssignment 2
+ X4 a  y( M7 P) HDeadline 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)
0 C/ Z6 n3 D0 d5 A/ \$ M1. 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.
# i% C! u& t. V- y/ GThe staff must be able to:
2 A/ P3 u' c+ ~$ K Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
9 l- M( b$ ^7 @+ b7 s2 i1. 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.0 p4 w5 c: y( P8 T/ B: Q5 y! H$ |
 The interface should provide a menu so that the staff can:" U& S. K4 u3 {  S; S2 r6 t% }: K
a) Enter the names of the two Java program files to be compared
( {0 r) o; s1 V2 \ For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
7 W, c" i" \# q! [/ t& T** 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).
( g- g: o8 \1 t4 U7 o- D7 w" v. YBSA104 Business Programming – 2007: Assignment 2: A* X6 G: e( g+ v
Page 2 of 51 r! p7 v( B- t5 S7 o( Z
b) Print out to the screen all the lines of code that are the same
& K7 H8 J  h# L  e; L Include the name of the file and the line number of the code being printed for each of the two files
& M* N, F1 B/ ?; {* ?7 n; G* cc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared3 A6 T& z6 Z/ S6 t- Z) y! d
 the name, username and department of the user/ O, l* f8 ^* U3 g
 the statistics of the comparison. _$ m5 I! e  E9 l, ]! |, r
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different# W& z( m# b" n5 w6 @
 the recommendation for further checking/ R+ p, \7 e6 i/ |6 B8 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. }% q) o# E# G) w/ X, x& f
 the names of the two files compared
% b9 s9 z8 _- p5 T. w/ Sd) Leave the program (exit)
( O% {7 l2 K8 T7 D/ J3 n6 vThe ProgramCompare class: (Total maximum 20 marks available)
+ [/ p/ b; X4 N5 F' ?& u2. 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)! d* k4 `  I% W+ g/ @( s* L# j
a) provide an error message if the files are not found or there is a problem opening them* Z) h! I# V9 ~, g, t# Z
b) compare each line of code% D6 \; D$ O2 [0 u. G
c) print out the lines that are the same
! m# }5 W* v3 T% c1 x8 jd) count the number of lines compared / lines the same
! Z9 n4 U1 g1 NThe AuthorisedUsers class: (Total maximum 20 marks available)
' v% j6 V/ H9 ]! `0 k6 z2 [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)+ {% k9 y1 @+ f9 ^
4. Provide methods to:
) ~* ^5 G  k, m6 [0 La) 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$ F4 d; y* |; O( d
b) return the name of the authorised user
+ ~4 k. n5 X4 b' Z# q8 Pc) return the name of the department of the authorised user. _( _: [" }4 T
Individual Data (Maximum 20 marks available)7 _0 g) b, ~4 b6 F4 _- m4 f5 s
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.8 x5 Y- ]8 u& w% v& a3 k: Z
Documentation (Maximum 10 marks available)- L; A4 ~  t$ V' S; a2 Z3 M8 }
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.
1 k/ o8 i( P- kBSA104 Business Programming – 2007: Assignment 2. P$ h( b  E) h% G
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
/ ]2 X4 g  e* K# S1 |不过你要翻JAVA的类库说明。你有下载没有?
" ]% i9 E! i# `7 r+ v) \7 v查询关于对比的函数。貌似关键字是contrast,还有compare
8 Q! y" q: d; \0 R
* }7 I* D& g  D* p: L5 a8 i[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
5 p) S, V. c' J+ p痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。' h8 n5 K; K, |$ E8 V- m
可以下载到的 是 jdk-1_X_0-doc
4 G+ S1 a5 R9 e, ]/ v% C& q* U0 P: O1 k: n! T
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-11-15 10:35

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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