找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1126|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 3 E% g/ C6 ^$ w) Y( W# t6 m0 a/ S8 [
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************6 o/ n  g+ P* A1 h: ~
//  ProgramCompare.java         Provided by: DRS! m: ^* p! d5 X% L: @
//6 b% u* h& d& K" i3 y
//  Program shell for Assignment 2
. T" y8 X, W" ]. o$ N. b; p/ a, y- Z; Y//
, f4 c9 i% {) `; J//  Compares two text files line by line
6 k8 |& P# ?: L" d9 P//*********************************************************************
2 w$ s/ t7 `$ n) I, Y6 i/ q0 \$ S  J' o3 ^
import java.io.*;0 V; P5 U# C- F$ @

# d  q5 M- y& U6 M9 a! P4 Ypublic class ProgramCompare0 g6 q2 X0 ~% g. s
{) N- `( b( ^8 C
        //-----------------------------------------------------------------
2 o6 F5 q7 p5 C/ W- T' d- R        // Constructor2 ]5 {! R/ s. b$ K! S' l
        //-----------------------------------------------------------------
1 J5 f  `( i+ T2 y. S9 K        public ProgramCompare()7 M. \/ t: s2 q6 i% m5 h
        {$ I  O. E& q' F- Q1 h
        }5 I+ }4 ]9 w( z6 b9 }: D+ A9 @

$ |3 M% C& H+ f( s1 s2 a/ p6 O, }  G        //-----------------------------------------------------------------
8 F# `) H# @  g" c5 f, C% J- J        // Method for testing that class has been reached( x- s8 k% \4 c- Z( _& B( s
        //-----------------------------------------------------------------       
( Y1 O3 G5 R0 h' D; G' k6 }( n
4 f" v( M% ?/ r/ S3 s        public boolean ProgramCompareReached()         $ n; {! q4 L8 q6 v, _; U1 t1 u) ?
        {  I0 ]" C  a2 L; P
      try
" n' K% A( g2 F8 Z# M  ^# Y4 J" @( W   {         $ i: c2 b8 W% ]5 z' i$ T! v+ ]+ [. D% Q
                        . Z( a. j. Z# K" W
                //********************************************************************6 K3 U. v( @( t4 R! c$ i
                // Try-Catch Statement is used to handle exceptions - such as file not found
" M* F( y: [# [( g) r& A                // Reading the files will need to be placed inside a Try-Catch - just like this one!( N, s8 F; J! O: X) a% k* n6 {. Q
                // For more information see page 534 of the textbook% T8 J6 }1 h; I4 g) z( G; h1 ~
                //********************************************************************' g* g/ K. k. t& ^9 o
                    
& A' e2 ?: A4 e1 u( A        }
8 o- [+ |2 _) \! w  p             catch (Exception ex) // Exception caught here and message displayed to the screen ' R9 u) ~$ u- d, i+ O4 e3 G
          {
1 ~- b1 Q5 s/ I                    ex.printStackTrace (System.err);
) W5 L+ o: Q! h& ^- q' Z: n' H           System.out.println ("Error message goes here"); // Replace this error message with your own         
# q: q4 \# @6 I5 |6 c# }        }! O: w9 b$ E. \1 J6 G
                return true;
* ]/ ]" K, o1 n' A' |* Q5 }3 k) M        }
' Q4 X' Z$ i4 i, j
- F# ]4 ]9 b: W+ _, N3 O: S* a1 T} // end of class ProgramCompare
5 `& y( @5 {; n# g8 ]7 L% ?* ^' I# p% x, w$ p! u
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************
, @( Z- n* I* v9 c/ [, b//  ProgramCompareMenu.java    Provided by: DRS3 y) @7 e! [) u( m" S( H% u
//+ W; {& p& W" U% F
//  Calls AuthorisedUsers.java and ProgramCompare.java
3 K/ a. n1 l, `/ @//
# Q3 u% }6 d) G" O//  Driver shell for Assignment 2.
5 B9 `7 U. W: P5 a7 V" U//********************************************************************
: F7 e' n3 `9 }! P5 b+ V! N
/ \* q! q; w0 q, [0 Z7 }5 u6 I+ O2 d3 Xclass ProgramCompareMenu
' j2 K! j* g: ^& |) C{  ^9 r+ @8 A2 D# t
    public static void main (String[] args)8 H$ V7 F% s& y/ l
            {  e, E' k8 |  U& P
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable" Q5 b5 ~! c( x+ O, p
                ProgramCompare reached1 = new ProgramCompare();
5 K1 a' K/ k! B- h7 K* X                AuthorisedUsers reached2 = new AuthorisedUsers();       
2 e; n2 L) p: y5 M5 [; C# t6 K" E                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());2 f& e1 ?8 b0 p6 Q3 J
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        + l: k, o' Z" Z9 b; p
        }
  r$ q8 s/ N% t# E}// end of class ProgramCompareMenu
0 K- {, G8 V2 X' e5 C) T1 v7 J! n. Z0 D2 |0 u7 K
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
# C$ |" S/ s6 H6 t+ A5 k) i+ d2 Y//          AuthorisedUsers.java          Provided by: DRS
! g+ G2 n/ L4 z$ a//                ! R% Q, f: b+ y' K2 o7 u
//         Program shell for Assignment 2
3 H' H, D0 }- v- c" r; v; \//
; w) l; s6 V. a( e//         Represents facts about an AuthorisedUser. l5 p2 c, c5 _2 [/ t* P
//********************************************************************8 V  H$ g+ h% x+ R1 T. i
/ x0 b: H& y9 A  o8 f$ }
public class AuthorisedUsers1 l1 [# l/ S) l; n" y, Y8 X" ]
    {
6 H: ]( N6 }% z( v. h" J5 a( o! O" m2 v4 ?. u7 r
        //-----------------------------------------------------------------7 X* y% G, r! R+ P% T1 g
        // Constructor9 Q0 ]5 L( h: F7 `
        //-----------------------------------------------------------------1 Z1 d( n5 `9 Q" i3 |4 P
/ V# W: U1 m+ v2 k4 p
        public AuthorisedUsers()4 u9 C' a. \% n; t6 @0 Y/ E
                {% f; \: z( e; |- ?* U/ V
                }
- e. S9 e0 T7 ^- N9 F5 Z/ \- R
- T0 [  k0 A9 C& |! ^        //-----------------------------------------------------------------
9 c/ t* @  S) C$ H1 M+ [        // Method for testing that class has been reached
% S* Q! l* p# U- j' R% }4 ~1 l9 ?        //-----------------------------------------------------------------        # R5 J4 k0 S7 I! |
        public boolean AuthorisedUsersReached()8 O% u* [0 o" A
                {+ G7 \0 K3 ~# `2 `7 e
                        return true;                       
5 a# v! a2 b# s6 |% x1 n5 k                }4 ^$ X$ s1 F5 t0 X% ]* n
               
) u! h  ]  Y, ^# S9 f8 _    } // end of class AuthorisedUsers
/ V7 ]* z8 r/ |5 w8 b, C; O, F//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
) ?) t! c6 V. X1 x" Q7 H0 a4 ZShanghai - 2007
. k; O' {; C) I# ?Assignment 2, `/ @% `6 K2 C1 m. m
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)
& @) i7 \) Q+ \* h9 \& s1. 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.
8 ]0 Z- B  E( ?5 c2 i) VThe staff must be able to:3 f* @; r: q, ^: T
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
' i8 o$ T" g6 _  N  O1 w1. 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.& q, y8 U5 Y8 U
 The interface should provide a menu so that the staff can:
7 V* `% |& `- ?+ J9 D2 i: F8 {, ua) Enter the names of the two Java program files to be compared
  L. m4 V& ~5 w* T, j For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
+ E. F3 ?. N# R( ?** 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).
; v) g( [* F) A; W" r3 bBSA104 Business Programming – 2007: Assignment 23 P; G. P2 _* N, M& X
Page 2 of 5  P! Z4 `  K' f+ [! I$ S6 U6 `
b) Print out to the screen all the lines of code that are the same; w* G8 ~' Y9 O+ x* p. S/ i
 Include the name of the file and the line number of the code being printed for each of the two files* U% A" o, Z; B4 c, y: Q& j: L! t
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared9 i5 T) B7 k0 S5 K' l
 the name, username and department of the user! f6 f3 z0 G* c
 the statistics of the comparison  m  Q+ T0 s" C6 Y
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
* y7 p) F; F! r: t the recommendation for further checking$ ^: v* I( S" w, z
- 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 closely2 z6 a' r3 \" r+ V+ S4 }0 g
 the names of the two files compared5 O* a7 ]* j1 f9 a# b
d) Leave the program (exit)* c+ r6 D3 U. i7 f! F, r( Q
The ProgramCompare class: (Total maximum 20 marks available)
5 ~& F: G  C, k& c! H1 _* z+ D+ G2. 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)
3 S% \, }4 l! `1 na) provide an error message if the files are not found or there is a problem opening them
2 y: a  i$ B6 ]! o/ ^* ?) T+ Jb) compare each line of code
  r% l7 h+ R3 v: ic) print out the lines that are the same3 y& _: L  s8 l( j3 [
d) count the number of lines compared / lines the same
/ W& M5 y3 U# J1 m+ u0 vThe AuthorisedUsers class: (Total maximum 20 marks available)) Q8 z! f5 Q, Z( f
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)5 i% S( ?8 u. h3 R2 |0 l
4. Provide methods to:
5 h4 T3 R0 F/ j4 ta) 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 J' [: P& p5 w9 I% d9 Y( D
b) return the name of the authorised user
' G! H( L& B4 d5 C% Mc) return the name of the department of the authorised user
7 T- ]; m7 ~3 D+ ~* [! J7 ~( ]Individual Data (Maximum 20 marks available)/ |# E) {# R4 b1 l0 m* Q) q  N
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.5 B5 m1 W; C, H! |
Documentation (Maximum 10 marks available)
$ n# s& W4 s4 V$ G+ l" [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.2 L0 n+ B- T" I8 |" f7 z
BSA104 Business Programming – 2007: Assignment 2
* Y# b& z9 f( p+ nPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
- i6 t" j$ L! t' G5 B* g不过你要翻JAVA的类库说明。你有下载没有?
8 X, b2 B- ]0 ?% E查询关于对比的函数。貌似关键字是contrast,还有compare& O% L. G+ [; F$ |
+ Q9 f* \) t% v7 n: l) m, {: C8 e- [
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -/ d) h1 |/ d& Z! p2 |# W! s9 Z- g- k8 k) f) u
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。3 N' ~3 {+ _, O; X
可以下载到的 是 jdk-1_X_0-doc
* z& y' _: J( e% b0 X, |
: A3 b- R% P5 u9 _- w2 C6 F[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-3-18 05:10

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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