找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1692|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 - o \% f6 m4 P5 |" _3 l: Y+ G6 q: O7 D : w( h6 K) V& P, K
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************& U7 F* b3 k, z/ n& T: X! K! i+ F
//  ProgramCompare.java         Provided by: DRS
! r( A( e: y; Z2 \6 N8 G0 C1 R0 E//
2 l' n, U& z$ d//  Program shell for Assignment 23 `4 L+ Z. c8 t5 W8 _  J. G# O) z
/// T' q$ z& `5 B+ J: d
//  Compares two text files line by line
0 o0 e  D3 \5 o: r0 A+ ?+ p8 j//*********************************************************************
8 r& U# y& }* Q! _& }) G2 b: g8 x3 n4 z5 ^5 X3 p9 Y4 ]# X3 P. G
import java.io.*;) {; w3 d' P* T5 \. D4 S; z

" \6 ~/ \+ q; R) {public class ProgramCompare: ^) h* ~( e# p5 g0 H, x
{- k: _0 d5 m! g& j1 h
        //-----------------------------------------------------------------
0 Q  I, }6 v3 C. u+ J: T        // Constructor
0 c* Y# }  E8 D+ R        //-----------------------------------------------------------------' b$ a1 z0 C: @& A3 R
        public ProgramCompare()+ ?' r& r" x6 I, G( i2 G# P% T
        {
2 j4 y& R8 d/ g, N* t8 W4 {& J        }/ }7 ~% B; }2 _  k7 P
$ j$ D. E6 V: b) Q7 P  C5 O8 g
        //-----------------------------------------------------------------
- F0 ?. k9 U0 P: F9 r% S# s        // Method for testing that class has been reached% A- W' u& g$ e" j/ I/ {7 K. O/ s
        //-----------------------------------------------------------------       
8 B* S$ V! _, j9 d, h+ ]  h0 N+ [4 I0 f
' I: I, k+ W' x3 b  o  K        public boolean ProgramCompareReached()        
& |+ P2 l! B" I- Z) b! m        {
% E! V/ p4 ~, I- ?( z9 w  `9 Z      try # H3 o2 L1 ^5 W% W" P+ g1 a; `/ u3 f
   {         ; |+ L' Z& q! q; q$ H
                       
8 f- t2 U) K7 H  H& ^- [; w3 l                //********************************************************************# C9 r3 V5 |# b2 I
                // Try-Catch Statement is used to handle exceptions - such as file not found
/ l3 g8 H: D+ y1 ^! H* K                // Reading the files will need to be placed inside a Try-Catch - just like this one!1 E. X6 A+ c# u( B3 u% [8 K
                // For more information see page 534 of the textbook
7 a8 D7 t4 N! c4 a$ n                //********************************************************************% ?2 g4 e7 I, |. S, I
                     1 z- H) n5 k. I
        }2 \6 [; F$ l" b- e
             catch (Exception ex) // Exception caught here and message displayed to the screen
  k7 [3 F% c. X: B          {; ~6 u3 l2 F1 \) h! y
                    ex.printStackTrace (System.err);
! G' a( u3 L7 L! Y           System.out.println ("Error message goes here"); // Replace this error message with your own          / F& C; F, B7 L! w  X2 |
        }& X$ l6 X/ V4 a0 @( ~* f
                return true;
# e' r8 G- R4 H, w' Q: Y( {& N+ v$ h1 v        }
$ A9 v2 q8 R7 _2 K6 n4 e0 G/ G2 {/ F. U6 H% U# H& i
} // end of class ProgramCompare
: E: X2 O/ f5 G2 ~7 [
" o* D3 n3 {/ M) [//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************$ K: t* ?: L* B- C) c' u
//  ProgramCompareMenu.java    Provided by: DRS! S, n7 g$ Z! C8 U0 z
//5 L- z1 d, |, b! Z
//  Calls AuthorisedUsers.java and ProgramCompare.java" r; \) \4 U# l6 k
//# a* f  {/ ~& p
//  Driver shell for Assignment 2./ ]0 V0 E7 k3 J- t
//********************************************************************
8 D0 J3 J' d% J- U  C4 U! H2 j% N
7 h  U& f1 p7 r; M9 Mclass ProgramCompareMenu- \$ d; J6 O8 s: k$ o+ I3 h6 @
{
  m, W: H( |, K/ E5 r    public static void main (String[] args)
, s/ H7 ?1 j, u4 a4 m$ t+ K* I* A            {
$ C- D; {5 |! C                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable* I5 b  P  s" x  S  S! }  r  z1 j( D
                ProgramCompare reached1 = new ProgramCompare();
0 D6 c: @1 X& a                AuthorisedUsers reached2 = new AuthorisedUsers();       
" s% ~( U1 e4 g1 u- b                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
! G8 E9 Z. a( N& W                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        ' O! I" U% a( [
        }2 ^; v5 C' k0 u5 w: i6 Y( a0 y
}// end of class ProgramCompareMenu& W2 ^% M/ y8 j: G. g6 M
% g/ f, Z3 Z8 X% s  {
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************6 L( }( j* f7 {: }2 }: d: m
//          AuthorisedUsers.java          Provided by: DRS
2 K3 u/ n. o  U0 k% |6 g+ {3 }//                . v' W0 P/ A3 q, r( S0 k. T
//         Program shell for Assignment 2
& P" i/ f1 E# ^* a) i/ \//3 d" P8 n$ y$ Y$ @
//         Represents facts about an AuthorisedUser6 T- ?) b) G* h& c7 g
//********************************************************************+ p1 L4 z$ i/ N7 H1 m" x; l$ R. G

' r) r# b# W8 {1 l1 K0 tpublic class AuthorisedUsers
4 H1 E) Q$ l1 i& `    {$ G! C' @5 n' A) o& a% j. q. F
" F8 N! N# u  Y; Y7 C7 x
        //-----------------------------------------------------------------
1 G( ~% U1 i9 C" [0 {        // Constructor7 L8 `$ W3 A+ m+ A7 [2 I! y, y' r
        //-----------------------------------------------------------------
, z2 z/ |+ j' \6 r
8 P2 @3 l9 a7 c        public AuthorisedUsers()% }6 q. ~* ~# _
                {
7 b) [2 F  x6 u                }( z$ w8 J- a$ N: n. a5 L

" u9 Q9 f/ _7 w3 _# x        //-----------------------------------------------------------------. E) S# H. p5 I- b8 ^; T  V
        // Method for testing that class has been reached
# X. g, y2 C9 z" T0 H  J( }. r        //-----------------------------------------------------------------        % L+ ?8 A+ y- ~% t
        public boolean AuthorisedUsersReached(): t% ^- r5 N% y9 G4 n
                {
& m+ G2 |6 m& T; e. K0 T5 _6 @                        return true;                       
, {% l; s/ v. G% W0 d                }
( c& n* t( H3 y. a/ L* e& W; K5 Z               
' o7 W; ?$ K7 H* f    } // end of class AuthorisedUsers. _/ G& k- K! t3 T4 W3 A1 {
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming' j1 {/ q% ]$ x0 O2 U9 d
Shanghai - 20076 T2 a1 l: c$ E: D) D
Assignment 2
7 `5 i  b/ l8 ]- G, WDeadline 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)
7 Y/ z4 Q# T  ]# @" l1. 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.
# P2 \  \8 y  k" }* KThe staff must be able to:
0 F7 W/ m" q, _ Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
2 D& x. |8 q% h3 l# y& g$ s1. 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.
' r% ~' D5 H, C6 d+ p The interface should provide a menu so that the staff can:
- ~0 s" t; W' O( z3 U+ e. ha) Enter the names of the two Java program files to be compared
% ]( V  E1 U9 a+ V For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
- P/ y- ~% ^- w2 q/ D  ~** 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).- _/ R5 `, h/ _$ Z% F
BSA104 Business Programming – 2007: Assignment 2
! ^7 y- b! S0 w! oPage 2 of 5& V* i2 V+ R3 ?3 q- ?
b) Print out to the screen all the lines of code that are the same* Z, o& n( X4 s1 z' v
 Include the name of the file and the line number of the code being printed for each of the two files
1 f7 T  y5 t) _( C- B! M3 t4 rc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared5 V. S5 U  b) G. [0 V
 the name, username and department of the user
# f8 f" G% \; T+ J5 x# S% z0 \ the statistics of the comparison9 K8 w# v5 p" n. E' l& ^" f
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different: m2 g6 N6 Z; z
 the recommendation for further checking
# @: k; I3 P, ?. o- 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
( ]( i; p3 J3 t+ ]0 C the names of the two files compared& x+ ~# Y! z" X$ L" l5 f
d) Leave the program (exit)/ g! l6 w( Y3 X
The ProgramCompare class: (Total maximum 20 marks available)0 F7 W  E  B2 z3 V. \4 h# `
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). s8 H2 X0 w9 r. y
a) provide an error message if the files are not found or there is a problem opening them5 g$ b9 S# e9 d# }- I; @
b) compare each line of code; j; w! `  j1 H% J- ~/ _/ h  C
c) print out the lines that are the same! J% _+ H; c5 l$ L" V, H' w9 o
d) count the number of lines compared / lines the same' {+ w- v: s5 m2 Z  i3 u& O
The AuthorisedUsers class: (Total maximum 20 marks available)- C2 U) y& d% T$ L* V0 O2 ^; \
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)& D0 k! `4 A$ K5 N0 x0 [3 ^
4. Provide methods to:& j/ F+ ~0 h) p; Z
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 match0 A$ y1 ]" ^: c( B' h
b) return the name of the authorised user' r% O6 J; n8 T; u  _9 u
c) return the name of the department of the authorised user7 M4 ?  e* A0 I: ~
Individual Data (Maximum 20 marks available)
. w8 M: `, A; U5. 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.
! I' h2 }0 h9 L. w( p5 P) LDocumentation (Maximum 10 marks available)
: P" |% u% Y! `* h6. 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.8 `$ I- l( ^) }% Y1 I
BSA104 Business Programming – 2007: Assignment 2( G" [0 Z  r3 j
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了" t$ o2 x+ b6 S( F7 z( W
不过你要翻JAVA的类库说明。你有下载没有?2 j* L6 W, F9 s! ^
查询关于对比的函数。貌似关键字是contrast,还有compare' v7 G$ [2 Z4 O$ o7 s4 t5 q/ {
$ f1 {6 ]+ n2 c$ b: A, Q8 Q, Z
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
4 {% Y# q  ]$ y$ _* N9 d  @& \) J! E痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。4 k0 o2 o. J9 |& N  Y5 y: x( `
可以下载到的 是 jdk-1_X_0-doc
$ X& h$ [/ \; W' K# j2 M
0 D- _7 q& u5 H! ]/ h" p2 G0 x  Q[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-10-2 08:34

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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