找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1745|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急) o3 S/ T: y6 m# g$ h 0 T, t8 z2 e: i- R6 ~+ S/ A
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
3 J$ i5 K  w- R" l# l/ ?3 K//  ProgramCompare.java         Provided by: DRS
2 {9 w" [% x( z7 L/ F//' c2 m. D, u4 }! v" A/ U+ A8 X# |
//  Program shell for Assignment 29 b8 [9 a/ C. p* T( [
//( s6 V$ Q3 M' n5 L$ F$ m
//  Compares two text files line by line
) V/ F' Z, F; v$ _, y- \! g9 r5 ], k" h//*********************************************************************
, i" _3 Z% P% I  v
; Q; G  l- U' r, a9 P1 Cimport java.io.*;
: N/ K4 z! a6 v, F7 o
- `" n, Q: j3 e  v+ bpublic class ProgramCompare$ [3 \( j, g) O; H4 R# ]
{
0 d! a2 _' ~, e+ R4 [        //-----------------------------------------------------------------
, v! H3 o* t2 P4 v& F! M        // Constructor8 r6 v  ?' _1 O9 t
        //-----------------------------------------------------------------
7 }0 r: l7 b0 o3 c( ?6 W        public ProgramCompare()
+ V4 k+ g  s8 ~" x7 X3 r7 b* T        {
4 W) m6 V3 I- p& Z% p& [. g% i        }; Y- w! a: P( I- D# U- T

# H* W# Y2 N' ~2 l% d        //-----------------------------------------------------------------7 M, L! N; u; k# F3 O' f
        // Method for testing that class has been reached
4 K$ [4 ]. A# G9 L) B        //-----------------------------------------------------------------        . c6 m7 R; F" _  B1 j/ {; @9 R3 w
2 u2 v5 @8 p- N; ?# |
        public boolean ProgramCompareReached()         9 ~: x, z4 {3 `' Y
        {# R& e- T; }4 E6 K/ |# |" P
      try
; b/ f( N, G! l9 S- m   {         % x  d; ~7 ^- @( g4 O- t/ T
                        1 S4 I  A, {+ s1 u9 e. g
                //********************************************************************. c* M$ W$ S6 l, M% z8 O  d9 _
                // Try-Catch Statement is used to handle exceptions - such as file not found 6 I; S: w) V" x! ]
                // Reading the files will need to be placed inside a Try-Catch - just like this one!$ c$ |% h9 }4 \3 a0 I
                // For more information see page 534 of the textbook
( l9 ?& t3 Z: {8 f# R                //********************************************************************
' \1 d" o, V& c) w5 Y                     : ?. C# i) J% i! F: G1 t
        }
3 t' E2 L% j/ B; Y! t7 l             catch (Exception ex) // Exception caught here and message displayed to the screen 3 J5 w. W6 a3 d, l' i: o
          {6 S$ S& z; x& B8 _0 n  S
                    ex.printStackTrace (System.err);6 a+ ^) Z: n' a1 ^; [
           System.out.println ("Error message goes here"); // Replace this error message with your own          - t, q- P6 J, Q) M. r; a
        }9 d* J9 T, C5 k- F9 x# t0 l$ |* g
                return true;3 z2 @- y8 L3 |) M2 U1 i
        }. q7 h8 {  o+ P' O. r3 K

) a0 m0 p8 v/ X% j; O1 G+ f} // end of class ProgramCompare6 x$ g+ ~" u4 k- }

) {( E+ ?6 \% T0 K3 X//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************. X* e% ^0 p2 `4 y, v$ ~2 u
//  ProgramCompareMenu.java    Provided by: DRS( k. n. R  X2 n" {
//7 u: @0 I5 ~$ c  @
//  Calls AuthorisedUsers.java and ProgramCompare.java" h6 g& J$ c9 u  k/ @' r$ ?' s8 t
//
. K  \$ O  K8 \# `. c//  Driver shell for Assignment 2.) }' S, r" w' L4 _- q
//********************************************************************. I. l; {( B" X% K' P3 i; m

- N  |1 N7 h8 Kclass ProgramCompareMenu
0 {$ A! r8 y" @% B: X' w2 E+ i{
1 A8 r% j& n( n' c# x3 x5 |    public static void main (String[] args)% }* w2 {( u. I, B
            {; d5 ]/ }- M6 q" E
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable5 C+ Q$ x" |: W# `( R5 z  P. _
                ProgramCompare reached1 = new ProgramCompare(); % u' {) v4 U) C+ k% i3 \
                AuthorisedUsers reached2 = new AuthorisedUsers();        & f; {  x! ?3 q8 O/ M( z
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());$ D/ A7 T+ M4 s7 r2 V0 ^
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
# R" c, N  W8 z7 l1 K) g( i        }
7 X$ i) P# Z4 ?# e- _! T}// end of class ProgramCompareMenu, z+ s& r* k; q, S- |
. Y* y& z7 f2 r- z0 y
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************* e# g; N+ E6 P5 Y0 l9 [& ~1 J: p
//          AuthorisedUsers.java          Provided by: DRS
7 ^* g7 T! P+ s4 A* w//                2 y& _! w3 K2 X6 ^; ], |
//         Program shell for Assignment 2% G8 _: c& m7 i! p7 \
//- ^8 \$ a" q4 I
//         Represents facts about an AuthorisedUser  G/ P& R* n: g! D9 @, D
//********************************************************************
" M0 V5 o& z7 w
1 r  _" E. [, }$ P! n! R2 n6 Ypublic class AuthorisedUsers
% ]/ a# X3 O; b  F9 P1 }8 e# P    {
0 D! }* a0 T; Q2 U& n
" w2 y" T2 W$ S# c1 R& G4 d        //-----------------------------------------------------------------
$ H- Q3 M6 Q5 w! K( s        // Constructor
- ?( `8 L' ^& S7 E        //-----------------------------------------------------------------1 O4 P# f& n+ f, H! h0 [
* \, ~+ F! @7 M/ F4 ?
        public AuthorisedUsers()1 F' s  W# t) D+ }% A* g8 q
                {
) V. x  S$ q) J. \5 n; [8 [6 y                }
! b- M; F7 P4 ?
2 n8 L- d2 |8 j6 W4 Z        //-----------------------------------------------------------------
! R' _  B; q# U" ], f6 B$ X$ {" q        // Method for testing that class has been reached$ k: M  Y5 A; O' b2 E$ R+ ?$ s9 N
        //-----------------------------------------------------------------       
% [/ f. b0 l7 f  I8 x( |4 f" u        public boolean AuthorisedUsersReached(): j  P) F' y% D# I
                {
' r1 {4 W9 A! n! k4 L                        return true;                        * C( U7 Q& W/ j9 i; x
                }
' j; e/ z) S8 V/ K$ F$ w* z9 O               
6 X$ |5 m: ~: |6 I' q# G" S    } // end of class AuthorisedUsers
0 U1 d7 d- h6 v  ?& f//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming" b3 B/ r; |9 L$ {# A8 P; c) p
Shanghai - 2007
! P0 e8 Q$ L5 PAssignment 2
7 ?: G* t1 }/ U7 x7 y' K" fDeadline 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)8 m! E$ @+ Y/ R5 `1 D* U4 l; h
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.
5 E6 P3 n# M' U- m, i) N2 A  D8 q+ NThe staff must be able to:
9 ~- h; T5 k' `# w7 {% l: v Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.* I& z9 O' T3 h' P
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.
7 D" p9 [& L* K0 n: B: {( W The interface should provide a menu so that the staff can:
3 M. S' x; O- R, O9 N3 Y0 ja) Enter the names of the two Java program files to be compared
5 y5 e; a  _, p. P& e+ Z8 b For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
% @7 u) B9 Q- I$ q& C+ i; v** 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).! y: Y7 s7 L0 D. D4 s" ]) o: c
BSA104 Business Programming – 2007: Assignment 2- ]) v  C* ], I) f9 |
Page 2 of 5
# [2 U; Y& G0 K# B' `- z0 ]0 mb) Print out to the screen all the lines of code that are the same
9 v* v$ D2 U5 ~7 u! P Include the name of the file and the line number of the code being printed for each of the two files$ O; _: i& `. o5 m7 y9 f- b  t
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
) `, K: W+ G# P) {! w' h the name, username and department of the user0 s# X0 M6 o1 c; H# O( y5 G  {
 the statistics of the comparison2 N/ |! J! z' I
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different) }, w3 D) Y% \# G& q% T- c
 the recommendation for further checking
4 }- H' c! g, H) I+ C- 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/ A$ X( C, `: W4 h0 f! j( v* {
 the names of the two files compared8 T$ I! P7 U# i0 |' y2 }
d) Leave the program (exit)! M5 d' a; d6 @# A1 w9 s/ n
The ProgramCompare class: (Total maximum 20 marks available)- ?' s# V0 v' C: M* M: r; N5 A
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)5 A/ [5 Y- Q0 J) J7 a
a) provide an error message if the files are not found or there is a problem opening them
( e  J- I6 W6 U; y+ wb) compare each line of code
2 |9 X0 a9 w, \9 p  n: C3 _1 i8 oc) print out the lines that are the same
: R$ i1 }) N+ x+ g* Pd) count the number of lines compared / lines the same+ M2 J' \& h' B8 y. `
The AuthorisedUsers class: (Total maximum 20 marks available)
. q& `( W( _" O% R4 S8 p3. 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)
/ }; x2 N  c( w/ O1 A: w9 l2 ?0 ~4. Provide methods to:
; c( b+ K# Y  r& V% |5 Q1 I# `0 Aa) 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/ S2 e* v8 d% R& i7 F
b) return the name of the authorised user( f. P3 M' u7 }
c) return the name of the department of the authorised user! E! }  D( [# j. `1 l& q# K/ M
Individual Data (Maximum 20 marks available)
( F3 \: z! u2 \# U3 q5. 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.
0 ?# L% G# o3 z- xDocumentation (Maximum 10 marks available)
  P' \, q) m; ^" X* E6. 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.
% O+ I7 E7 f2 o. L* RBSA104 Business Programming – 2007: Assignment 2
' w) T: l8 _% Z7 C; m; LPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了9 W+ y9 e# I! b9 G$ G
不过你要翻JAVA的类库说明。你有下载没有?  m3 {0 w5 P5 m* a+ Z5 h
查询关于对比的函数。貌似关键字是contrast,还有compare
, O/ C- j# X8 x# {' L  J# j7 V, W" g, F
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
. b% f" @$ d& C  b痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。  X3 i% b' w9 k8 m; D+ ]
可以下载到的 是 jdk-1_X_0-doc
4 `0 K7 v1 h$ w8 L! B% }! `4 I& J8 M. I& N# q" w1 w- ?/ X
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-21 16:15

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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