找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1620|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 * m: s6 I6 @% W+ R$ ^ / p/ v8 H: X: l0 H! _
回复

使用道具 举报

 楼主| 发表于 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+ i8 O" X# |! }7 |& p//  ProgramCompare.java         Provided by: DRS: r6 ~8 }/ Y* ^! }# {0 W) j) T
//
" b  Z0 L, L  p' f! G$ c8 t/ h//  Program shell for Assignment 2; }7 U2 }" Y$ W% j- N, T
//5 `; |, X5 Y$ V: Z1 i
//  Compares two text files line by line( k4 b8 n$ y6 {! L; O: G3 |% b. Z
//*********************************************************************
- q. W" C0 K! l% T& q  s
2 {# l6 H2 {- C! A0 e0 E  T5 Timport java.io.*;( e" \" S) K  g9 Z
( n$ I3 }, Z! d$ n3 i" l% G
public class ProgramCompare( L: w5 @4 H, r$ o
{, c' ~4 `7 ^/ z& `3 p
        //-----------------------------------------------------------------
$ r& a& j- ~  B, k        // Constructor7 M2 k& i4 m5 p* D0 B* K6 C
        //-----------------------------------------------------------------
4 E- W* O  D  T. h        public ProgramCompare()
8 b5 h/ s" A% U  e" i4 w8 L/ `- f% M        {! A) t7 O, _" E# o7 H
        }
$ Y; X4 k* `& T- o- T$ r5 B0 J  `5 S! a; X8 l# \9 p' A9 H4 s  R% d3 U
        //-----------------------------------------------------------------5 P( G$ \, U  r" P' D% Q
        // Method for testing that class has been reached
) ^* E* }4 A' F  r2 a        //-----------------------------------------------------------------       
# R; M5 k  m3 O  r# Q- C
2 H6 k* v/ H% z. ?0 h# q        public boolean ProgramCompareReached()         : T0 ^8 c& N6 E- E( C
        {
: K, l- m( W  D4 h/ O' W      try
; @4 H  i) Z+ b6 O- J5 E   {        
, i; x6 p. s' |$ @. a4 V1 E                        & a* |! ^- Q' v7 s. u( a* w
                //********************************************************************
" m* z3 f* W# F                // Try-Catch Statement is used to handle exceptions - such as file not found . [+ e+ J1 H/ s1 g
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
# D) {, s5 u, y( t( V# Q                // For more information see page 534 of the textbook
8 P  h$ c! y. J8 t' _                //********************************************************************
, m5 N: S1 x4 w% c+ {% \                    
7 f8 ~* g, z# I$ s" D& B, B        }/ M% a% k  g$ o1 b2 w5 u( j% |3 q  y
             catch (Exception ex) // Exception caught here and message displayed to the screen ; x5 \" h6 y1 p7 S  G6 W
          {$ s8 D  `1 k1 f6 ?
                    ex.printStackTrace (System.err);
$ I2 M2 k$ ~" u           System.out.println ("Error message goes here"); // Replace this error message with your own          - z( N. I! ^) t9 t
        }
* o5 X# Z: [# e% @+ v                return true;6 Q, @; k! S& n, I9 D7 c: m
        }
& f  J+ o" ?/ }8 n* b6 T7 Q* z7 O& W2 ?# m: q* D
} // end of class ProgramCompare1 }' |& S, c% F

. H0 b1 M+ L8 k7 N  H//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************+ P  @- @. }7 A0 h$ d, E; f& a/ p# I
//  ProgramCompareMenu.java    Provided by: DRS
- P6 D6 E4 n! L- J" R( F+ E/// e3 Q" l' o& X' B$ R
//  Calls AuthorisedUsers.java and ProgramCompare.java5 U* E0 E4 W, \' c1 T
//
) z1 d, {7 ^/ o; R: [6 E' Z5 B, v# H: B//  Driver shell for Assignment 2.; }6 x5 ^0 p! Z7 Q5 n
//********************************************************************- B* a8 n& P" }0 O0 O- i

2 `0 G) c  M6 W  tclass ProgramCompareMenu. q' \* P; P$ F: x
{4 G; x" z3 e$ e5 L" @
    public static void main (String[] args)! G4 c2 [- j# c3 |0 A7 @
            {, {. r+ j) q; h& ~/ G, e4 P
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable( S# l5 c, q+ z& i( x
                ProgramCompare reached1 = new ProgramCompare(); 8 T: U. f2 r4 z7 ~2 [/ J
                AuthorisedUsers reached2 = new AuthorisedUsers();       
8 B) _. E  `% h! `# J                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
( c, b' K% v  T! ]                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        * r) p% x( s, S; T  b
        }7 z8 y/ I" g$ I2 @/ X
}// end of class ProgramCompareMenu( b( V0 Y' ^) F. b' v) P

& ^- O( ]4 m. W6 _% t  m//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
2 s- c, A4 j+ T0 N//          AuthorisedUsers.java          Provided by: DRS5 A0 V# j. f  C$ E6 n: N
//                2 l# w! |( B$ ~( ^
//         Program shell for Assignment 2
) b5 W6 J) Y, j& }# @! z: @: c//
% b% e# V  E, V9 x! ^2 X  s) h4 o" P//         Represents facts about an AuthorisedUser
6 ~5 F% [, ]* y- o//********************************************************************
1 K" x0 z, u/ H
4 k3 }. l: T) ^; r$ wpublic class AuthorisedUsers; E* n- U) N1 ~+ M. _$ u. N8 q
    {& d( C# f( R5 H
5 J8 C2 |9 T7 y4 a
        //-----------------------------------------------------------------( {6 |. f2 a+ n* t
        // Constructor
! C: R$ }1 L) h8 p1 t; Z, G        //-----------------------------------------------------------------6 Z4 y% g: ]$ x0 c  p" L8 y3 }
5 o, l0 e/ o( S* L
        public AuthorisedUsers()
$ @/ k) p9 @# l' v3 {! K; F" W                {
, p! c5 k; \& @7 Y! B                }' B; D* O/ G4 U+ u
7 x* z9 }' w% U1 U( Y% ?1 Q
        //-----------------------------------------------------------------  y5 x* J: p5 s6 s! G) Q: s" k  d
        // Method for testing that class has been reached
* `6 ^. m" a& x$ \. O) v        //-----------------------------------------------------------------        8 T1 C5 n* f) P8 D1 m) W/ s; J
        public boolean AuthorisedUsersReached()  T9 t1 @( F# |+ D1 J8 a2 t. |
                {
; |3 P. m& p0 R$ {7 t, x; Z# b  p4 k                        return true;                        ! I5 }4 ~( ?" I5 q" }
                }
* U/ ~! A9 g/ p2 C& Z                0 x# x$ E& U9 ]1 h
    } // end of class AuthorisedUsers
+ [$ n) n; H/ I% d) K//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming
2 k$ Z% K/ b2 G: {9 iShanghai - 2007: d+ G5 j. Z  E8 g9 _: G- |% s: L
Assignment 2
6 Z- I8 E/ H7 e' `, V/ |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)
$ k9 R9 d0 H  W- S5 a& o4 e1. 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.
6 F* @! Q+ x7 Q1 f1 hThe staff must be able to:
% y/ h8 w+ b; ?, c6 h Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
, x1 s  h4 Z5 N/ s/ n1. 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.
/ J5 t, B$ v; ~' j, d' N/ L The interface should provide a menu so that the staff can:
# Q1 {. G1 a1 _# Ea) Enter the names of the two Java program files to be compared' ?, R2 q* Q5 E7 S: |6 w- a( J1 A/ U
 For this assignment, it will be assumed that the two Java program files are in the same folder as your program.( g! [, M7 C+ c: }0 Z) J1 ^2 h! \
** 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).
: n2 Q7 K$ L1 @$ v, \+ LBSA104 Business Programming – 2007: Assignment 2
9 t" a7 w4 ]" {: B$ FPage 2 of 5, t0 x: w( n& e# ~
b) Print out to the screen all the lines of code that are the same
, [3 ?* }# @; T( k Include the name of the file and the line number of the code being printed for each of the two files+ u' ?, c  }: e: h) O! J) a& T
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
+ O( C# Z8 c3 W$ r: p5 \' I/ L the name, username and department of the user
6 w6 H& k; x+ V, b the statistics of the comparison0 l( a6 ^- L! E  ?' Q# }, B3 C
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
, u, }9 X0 [5 u0 `; v the recommendation for further checking
* k8 }: C: {4 G0 i' ?" V; b& 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$ H4 {; U8 I8 J; ~* O4 l7 c, f+ z
 the names of the two files compared/ g% q4 S. z' F0 R4 Q& i0 B3 x7 `
d) Leave the program (exit)
6 T6 I# j! D2 C# X8 Y+ @. gThe ProgramCompare class: (Total maximum 20 marks available)
. \- ~. r7 d6 l3 ?4 _! z/ R; 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)
0 Z- D5 b8 w" N) Q- ^3 B& z2 Ha) provide an error message if the files are not found or there is a problem opening them
! ]5 r& ~9 z! f4 v# i3 {/ bb) compare each line of code
: c" U" M' P3 U1 N; w7 m( o$ Bc) print out the lines that are the same  @/ v9 s; V( L: H
d) count the number of lines compared / lines the same1 r$ h% m$ G: q2 }  h: `2 e% I0 }
The AuthorisedUsers class: (Total maximum 20 marks available)
9 p) ?$ M# D5 @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)
; F, @3 ^  Z5 ^3 B3 z4. Provide methods to:5 D0 I! ^& }9 b
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# p9 ~% e% N9 F  d7 j1 w
b) return the name of the authorised user5 G1 G( T' t& F' g# R
c) return the name of the department of the authorised user( N6 f4 N9 R! X0 A7 S. j, q" c
Individual Data (Maximum 20 marks available)# i, s4 F& r! m0 Z% ~0 d0 d
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.
' I% t* P; u; [" s% d* RDocumentation (Maximum 10 marks available)- \" G, _/ Z5 {( ~, b8 Q4 n
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.
; K/ K3 P% `! G+ R, TBSA104 Business Programming – 2007: Assignment 2+ C4 a) i: i/ q% h& @
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了: C7 b. N. n2 q
不过你要翻JAVA的类库说明。你有下载没有?
. l$ d+ z* a! [( V  z* H查询关于对比的函数。貌似关键字是contrast,还有compare3 E8 D% U- ?' t4 L; U8 u0 G
7 Q1 r  |2 p1 T- w" Q
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
: W5 j! T  Y# W痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。% s2 I& M+ v/ ~
可以下载到的 是 jdk-1_X_0-doc4 E3 I0 F3 X* L: w. I0 A8 U5 o8 u

0 b; d4 J# u) I  `% k1 p[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-11 08:55

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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