找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1228|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 6 C: q' k: T, h( f : }& F9 I8 I5 l8 U
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
; r* s- `0 L9 `& [! C4 L//  ProgramCompare.java         Provided by: DRS. W6 W* J3 E! D
/// s+ \2 B2 Q- b
//  Program shell for Assignment 2) s0 S2 I$ n. K
//4 V5 U2 s! X3 n
//  Compares two text files line by line7 B" p/ d. W; J8 ^
//*********************************************************************; E- h. H' a4 B) [4 R* ~: @! w9 F

0 q) c* D: w  t2 ~import java.io.*;3 }  }7 W. U/ m5 W2 i  I  u& ^

3 Y$ }0 @& ?! Q" xpublic class ProgramCompare
9 N9 k- e# ~8 b1 @" G. z" q* s4 w{5 b6 o* T( M6 o) l$ `0 X9 R
        //-----------------------------------------------------------------
0 p' Z2 ?/ D  s8 c; q0 T. Q) \        // Constructor* s- }& J, _0 n+ V  V4 h) G
        //-----------------------------------------------------------------! x- [4 P, v4 T( p3 Q* T( m3 Y
        public ProgramCompare()
8 L1 V4 Y) H0 G; R; w( c- B# N        {
9 R! A! h  P8 y/ ^        }; L; N4 n4 }! n6 y$ l. C1 e1 }6 R

! h' `  W. b1 u/ q        //-----------------------------------------------------------------
' o7 U$ _1 K4 s+ E        // Method for testing that class has been reached
- M8 P7 p# s4 N" b  |9 y( m1 r        //-----------------------------------------------------------------        . z- B8 R* e7 h; |5 N, t$ p

7 T1 {; q1 Y& _8 N0 s8 x' k+ P+ r2 v        public boolean ProgramCompareReached()        
" T, M# r: i- U  f6 [6 O" u& u        {
( X: s! K7 w2 y9 ?0 M2 J- n      try 5 ^" O8 b2 Q3 K0 R/ ]9 v1 g$ F
   {         % a/ b# f, q. D+ l+ U' d
                       
6 ^6 R  p4 _2 r7 [                //********************************************************************
; m' l3 X/ t6 B2 y. A                // Try-Catch Statement is used to handle exceptions - such as file not found 5 M2 t- Y5 @( I% x) T. s% M
                // Reading the files will need to be placed inside a Try-Catch - just like this one!8 v% p( @  Z8 c5 x
                // For more information see page 534 of the textbook
: G! `, f# w! s# ^* @                //********************************************************************
* a: V+ }$ o* j                    
7 c/ k. v5 v! R3 F. f        }' t3 o+ P9 x) m% E. j" ~( d
             catch (Exception ex) // Exception caught here and message displayed to the screen 7 D3 S' w5 `  n7 {" k- E& q- _/ M
          {
6 }8 ?- S( O) E: B4 J0 B                    ex.printStackTrace (System.err);
, Y2 i+ L4 F% P% I2 o) L- c           System.out.println ("Error message goes here"); // Replace this error message with your own          5 p/ p- d( N5 T
        }
9 `' f+ F' O$ s: H; w+ R$ P) a! I  n                return true;
; n6 k! o& E& H0 Z7 |6 T        }
, F9 b- z2 r7 _6 H, m1 x. J5 h" q5 I5 t# Q3 p: v8 a0 _3 f
} // end of class ProgramCompare, T; _& x  w: U1 |9 O

% S1 G8 y4 Z3 l  `& F) c//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************+ Q7 T3 G6 ~( s( L* {& I1 B. S
//  ProgramCompareMenu.java    Provided by: DRS
! I: h2 @6 j3 p/// w# [! M+ l* S& Y6 b4 ]1 P8 c8 O! f1 w
//  Calls AuthorisedUsers.java and ProgramCompare.java) s2 j, R7 K( m" L
//
. G& M# t' I3 ^2 g. M' a, o/ b//  Driver shell for Assignment 2.
2 l% P% [8 [2 r& M//********************************************************************& h9 `2 i/ [" `- j% f
, u. X7 O% t' q2 ~1 p, P! u+ O, C* b
class ProgramCompareMenu8 e- s. b- B! ~8 v7 E1 h
{
# m9 L7 z6 A, t9 H: `    public static void main (String[] args)
. c) V! m8 b- O! a8 K# y( l            {
4 S5 q) n. f3 v9 O8 p$ Q                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable8 o5 V* E$ ^9 ^: M/ ]& g
                ProgramCompare reached1 = new ProgramCompare();
# u2 ~7 ~: U& i% E) u                AuthorisedUsers reached2 = new AuthorisedUsers();        ) A+ `! \2 `8 |0 K) Y% G
                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
" W/ p7 I; B# F5 F                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        9 n: _! P& B7 F  W3 b
        }
5 N0 R- X; h. Q# z}// end of class ProgramCompareMenu
  d+ r7 L. N& S0 O9 R- P7 s. n3 Z3 b/ f4 n$ w
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************4 d# }8 d% B+ l
//          AuthorisedUsers.java          Provided by: DRS4 T  O" T+ J# q- E' y' X2 N- ?1 W
//               
* s3 N1 X% _+ U) r! N//         Program shell for Assignment 2
  _/ I/ P2 G2 M1 f' |//
7 U! \8 h0 B* C  M& D& |//         Represents facts about an AuthorisedUser
6 ]: h2 I& l" _  Q; r1 L" f//********************************************************************
4 |& ?& K; [) x  L0 q1 ]& [7 q
3 s& `; ^7 M5 qpublic class AuthorisedUsers
' a0 ?" Q" T/ D  }    {( w* [+ {' B7 F7 \$ X3 u
0 v2 |: ^& O" W1 T, A2 a
        //-----------------------------------------------------------------! g1 o9 H$ Q2 |
        // Constructor) _" T; o, r  k5 h) b. [
        //-----------------------------------------------------------------
0 J: P0 y- g; O0 q/ }9 }; a# u( O  T
        public AuthorisedUsers()
2 G1 n9 [8 t; R- O4 _  R& b" c' T                {: o3 ]- h# ~4 n+ W$ Y3 h
                }
$ [1 A- g* U3 Z, b8 v
, ~- Y+ O+ a* L  o; o3 }7 l        //-----------------------------------------------------------------) n6 x  W$ Y5 G! N) S3 Q6 c! V
        // Method for testing that class has been reached
; @4 M4 r( L0 Q; `8 i7 ]7 l        //-----------------------------------------------------------------        " x! A  o6 |9 }
        public boolean AuthorisedUsersReached()' E% {, w. P/ U* \' G2 Y
                {& _- o5 Q# Q! I* M  f
                        return true;                       
8 U9 \' m" H6 N4 ^+ P- i                }
' ]' d' H; z9 o1 i* D                3 d' k, Y* O4 o0 X6 P+ [0 _( K
    } // end of class AuthorisedUsers
5 X0 G2 P9 G% @  m) U0 n//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming8 X1 [- M8 A  k
Shanghai - 2007
6 D# \( G. J2 H  GAssignment 2
/ g' t8 V8 ^+ H6 `4 lDeadline 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)! s5 \' r" L& C
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./ H& X+ L1 K8 V4 b, n) ?8 ~
The staff must be able to:3 e4 ]& w; C0 T6 [' c
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
/ Q, Y; r! T) ], V' {) l1. 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.' l: W0 p! D* ~" I' m
 The interface should provide a menu so that the staff can:
  ~( }9 M. D! ~, Y( ta) Enter the names of the two Java program files to be compared/ u/ |" z8 i  S% S; I
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
- P  |# r2 M& @4 a** 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)./ W. O- h, \! Z( P0 d4 X! [: s. Z
BSA104 Business Programming – 2007: Assignment 2) z5 t7 `& t6 a0 I2 ?; e/ {9 m
Page 2 of 5
5 P- @! X" Y  |6 Ib) Print out to the screen all the lines of code that are the same
+ u- a- l5 }8 y% W- F! H9 y. H Include the name of the file and the line number of the code being printed for each of the two files
* k0 p3 x% G: L5 Ec) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared7 u" j7 _' ~" s# ?
 the name, username and department of the user
5 u; [* Z/ a0 S8 g# D5 J the statistics of the comparison
, x6 [. R1 [( z8 h6 [  Q% E% R+ z- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different7 D+ X5 z5 I# n& u7 C) ]  {
 the recommendation for further checking/ Z  F" l- n3 |' j) R5 e7 H# x
- 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/ T0 U2 X0 R/ ?% x) B
 the names of the two files compared- B& k: D0 P# ?3 B
d) Leave the program (exit)
% m; I& O2 y7 b4 H, QThe ProgramCompare class: (Total maximum 20 marks available)9 f$ `, ?( }( Z$ B7 Q5 _
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)* G& W3 A0 V2 g% M" \
a) provide an error message if the files are not found or there is a problem opening them
- a$ Q/ K( ?, U  R9 k/ qb) compare each line of code# I. J9 C0 p# U- H" h
c) print out the lines that are the same3 L( M% Q6 \& ~0 Y; u; C
d) count the number of lines compared / lines the same
' G0 J* }5 K$ vThe AuthorisedUsers class: (Total maximum 20 marks available)0 ~' O4 d% z' y' G7 i5 a
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)! N8 e' E* K+ c
4. Provide methods to:6 N1 B1 G; D+ H" W3 `7 [
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# Y# u& D! e9 Z$ g$ S/ ~3 |& m
b) return the name of the authorised user2 F% |% h& o" O1 Z
c) return the name of the department of the authorised user6 W- d1 \# `0 Z3 n- S
Individual Data (Maximum 20 marks available)
/ N1 i/ A) X( c5. 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.
# {6 J! h/ `0 {" NDocumentation (Maximum 10 marks available): E3 @1 \9 O9 w3 m2 ~
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.
/ D* I1 q: R& G5 M$ cBSA104 Business Programming – 2007: Assignment 2
7 f0 [$ |1 S5 G! E0 X3 gPage 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了: F; R- }3 R8 Q( L
不过你要翻JAVA的类库说明。你有下载没有?
+ f7 E7 o7 U1 g查询关于对比的函数。貌似关键字是contrast,还有compare. C: e# J, G0 K1 [
" o5 D, T% q$ ^, h
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -- q% q" L4 y: t; L0 Y% c5 ]
痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
% x& n& J4 _' ]) k可以下载到的 是 jdk-1_X_0-doc
8 ^1 ^, O$ t5 N: Q+ `
1 }1 H  o3 z5 i: D8 x# R# P[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-4-22 20:21

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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