找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1597|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急 . E5 @& j! Y! l7 y* l4 h( j% ] 4 r: W/ A6 r" C0 ]
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************# L& B2 q1 F6 H/ O
//  ProgramCompare.java         Provided by: DRS2 Z* u$ D+ `5 u) q7 h) z4 R
//
2 s4 E$ k" _" o0 L//  Program shell for Assignment 2
5 T3 r# f$ [, b' E+ f+ P8 O  n. Z//. u3 {6 P# o) {/ q9 x6 _. B
//  Compares two text files line by line
- }/ n7 Q" ?9 L5 r; i//*********************************************************************
3 U9 c, q, G( |! ]
  l% ]! {6 Y! cimport java.io.*;% {! h7 w3 ?6 q6 t2 f/ r

1 Y  X2 o4 @: S# i$ S1 Upublic class ProgramCompare& ?- \/ }% h7 k
{
6 ^: R' w2 F6 D" s        //-----------------------------------------------------------------
" V& w1 b( G, o: N7 O        // Constructor, j* A* ~% l8 k$ x' ~
        //-----------------------------------------------------------------5 W: G' _2 W; B& y- A7 R# l9 q; z$ ]
        public ProgramCompare()
9 |3 C# a0 q( P( }' e7 i2 u- y  R        {1 p6 k* R- j: L1 m8 N$ u" R
        }
7 |" N" Q. y4 J  X
/ [1 K1 z" V8 ^! x        //-----------------------------------------------------------------8 F7 h9 |! F" I* f1 X' U3 s- L: H
        // Method for testing that class has been reached
- t6 E8 _2 R9 N2 k6 F: A+ |& n        //-----------------------------------------------------------------        1 D0 p6 h6 R& K2 b

+ _* ~( c9 H6 r- y8 v        public boolean ProgramCompareReached()         , u7 Y- ]3 A8 u* s$ g" E6 z
        {) z& f3 n3 Y/ u3 Z
      try : Q4 p/ v6 h# D
   {         $ N" z0 y4 ~, y/ J9 K
                       
* e: t4 X; r- r7 ^% \! U; t                //********************************************************************! T" i7 W0 I1 B. f
                // Try-Catch Statement is used to handle exceptions - such as file not found
. }- I9 {7 s2 A# J                // Reading the files will need to be placed inside a Try-Catch - just like this one!6 h6 j1 Z7 j6 V) O( [8 {5 c. k" E3 a
                // For more information see page 534 of the textbook
; c, v3 g: h4 `7 t2 L6 \% k                //********************************************************************
) ?! j: t; t1 b2 Y( i- o                    
2 z/ o' g7 h: _+ D        }
, K2 u" `8 H" D$ K8 `4 s' z             catch (Exception ex) // Exception caught here and message displayed to the screen 3 E$ E# k9 e1 R3 p, K" X& S
          {7 ^* k4 P- S5 L2 N
                    ex.printStackTrace (System.err);5 Y7 S$ L1 q! S# Z; {1 j( I
           System.out.println ("Error message goes here"); // Replace this error message with your own         
/ z# A' T# n/ @; a2 w% Q        }
! h2 }) A" y6 X9 ?6 E; [- Z                return true;9 J0 z4 c; p+ r7 Z  y7 X, f' h
        }
9 a5 K: V+ ], D5 a6 M4 ^+ ^3 Y& {5 A" M: {; B
} // end of class ProgramCompare
+ _$ ^6 c, O5 }9 V& O" s! `8 M( r; m! t1 Z8 k+ A0 U
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************7 N& F$ Z- D: p" r
//  ProgramCompareMenu.java    Provided by: DRS1 i% q* ~6 Q; O' e$ D
//, t  e  e: v# c, s( i$ E( k
//  Calls AuthorisedUsers.java and ProgramCompare.java8 F3 R$ ~7 X. m: p, n. U
//
( p/ f! d) ?0 p8 K/ V% N//  Driver shell for Assignment 2.
1 G3 {5 a6 }3 ^6 \  o* W4 F7 a4 d3 |//********************************************************************; F  }: F5 H* ?
" A6 N$ T: Z+ u: ^! Q6 U, n
class ProgramCompareMenu
) J: G& C9 @  q' k{
9 H. \+ Y3 _5 z$ O1 m' l. a0 T; H    public static void main (String[] args)! `% F, f# |% z& Z: C2 \4 X
            {$ L# M( L8 a3 ^, m% \7 I
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable* t" v+ P, I) X) P- N, U
                ProgramCompare reached1 = new ProgramCompare();
2 P6 C- E( v  _                AuthorisedUsers reached2 = new AuthorisedUsers();       
0 J$ R% }( e  F( \( U5 }                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
; z* M8 P, S/ d$ a                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());       
0 `2 w+ Y( l9 _% ]6 M' L+ t9 A5 `        }* V* n/ W/ @3 K
}// end of class ProgramCompareMenu, i% p; [# f( Q) {

5 t7 F. E& d$ W! I, ^" K: t//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************+ b' S$ _5 q( o% G& D
//          AuthorisedUsers.java          Provided by: DRS4 |! t) i  ~3 d7 y
//                " @5 ]6 h) g; j! E
//         Program shell for Assignment 28 S6 }( ~* m" `" O0 ~( P
//4 d# _( L7 S' Y% M0 @( G
//         Represents facts about an AuthorisedUser
/ i# I6 w& Z3 s$ G# R1 w+ Z+ ?6 e//********************************************************************
/ i/ ^" f" W8 }. w: h" ^& F' ?. a
3 I* Q0 m1 {3 P, Jpublic class AuthorisedUsers# r* k, G9 w8 a+ U  B7 [7 H2 w
    {- f2 U6 Z% P5 P) U

0 s8 A. W+ z5 d$ H+ m* W        //-----------------------------------------------------------------! T2 q3 ]7 t4 j# q% V! `% }
        // Constructor
4 B. h1 P; F6 Q        //-----------------------------------------------------------------
7 S8 B' v' t5 v* G
6 n5 z* u3 ]  a/ }) G        public AuthorisedUsers()
- R0 J; s9 l* ~9 @, Q                {' m9 A& V  S  z% K
                }7 x: u# K$ v7 s) |7 ^4 }& j* F
, U# T" }* n& u  h4 h0 v
        //-----------------------------------------------------------------
( ]1 ]4 M, Z" w+ l9 z* h9 S  x        // Method for testing that class has been reached( ]/ O9 [" d' ]& c# V7 c
        //-----------------------------------------------------------------        4 ]1 G" Y# C5 l' J, B/ @
        public boolean AuthorisedUsersReached()* a' w/ Y; w) F* @2 @
                {% U" R# \! E4 e" W5 V
                        return true;                       
# y) ?, B# E' d  f# \6 `  Q                }: a  m8 q& N& Q/ h
               
$ y* `. W6 i' ~( z$ }) Y    } // end of class AuthorisedUsers( W6 I; Z' D" J0 O& J
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming6 ^$ }% H# V% U! Q+ z' e! d
Shanghai - 2007* |3 ~% Y( Q" h7 o5 N8 F
Assignment 2
% i$ |7 ?- T5 x0 u) 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)) Y3 g. `7 Q  P
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./ b/ |3 M0 U! l& u: }( \
The staff must be able to:
( g6 ?) t- n- e" M; Z  z Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **./ S4 P; }. e* n7 ?+ U! d
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.
  Y4 W4 w* F$ }0 i+ Q$ G8 n The interface should provide a menu so that the staff can:9 p7 u( _- d- `$ ?
a) Enter the names of the two Java program files to be compared
0 ]% M) e+ S' P; B! |2 C. E For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
' q* t" A% B( {. 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).
9 R0 S2 O+ a  V* {BSA104 Business Programming – 2007: Assignment 2# }3 s7 R7 J" w  j$ ]
Page 2 of 58 q0 h6 O6 x" m7 f: S) A6 z; f7 a. p
b) Print out to the screen all the lines of code that are the same! u$ B4 H) K" d2 X- ~
 Include the name of the file and the line number of the code being printed for each of the two files
( j  b! M4 ]! O/ A& x8 sc) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
9 j. L- z2 b7 h" ]$ g3 s* R& u; a the name, username and department of the user
9 ]+ B- U, m2 r: B* G# H the statistics of the comparison/ l4 J( A! A& M- v( \! a  a( ~0 W
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different/ x& P8 T" r$ D' v# v( f
 the recommendation for further checking
- r# v2 b6 ?) y1 v' n- 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$ x9 v, C* z) Y3 l  @8 }5 I: [! t
 the names of the two files compared
% L( c0 n7 b- H$ Id) Leave the program (exit)3 P! |2 X& V* D5 m) h! a
The ProgramCompare class: (Total maximum 20 marks available)' U' M7 N7 ^. {7 _5 f* ?
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)
6 G. m6 C4 w; x( y( i4 h" r3 La) provide an error message if the files are not found or there is a problem opening them0 u1 X4 m; u6 S4 [
b) compare each line of code
7 d, J1 V( ?3 ?; P# ^! N) jc) print out the lines that are the same7 m% D- B% ]/ ~$ b
d) count the number of lines compared / lines the same
4 z! Y( S% y- u# ?' AThe AuthorisedUsers class: (Total maximum 20 marks available)5 m+ L3 V; T( D! t3 D
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)
3 p$ o, _* [# I' E  C7 L+ Q6 I8 f& z4. Provide methods to:
9 w$ Y/ z; P  V5 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 match
, b, {! E9 y$ F- \, ub) return the name of the authorised user
) R2 r+ @% X  l, Pc) return the name of the department of the authorised user* q/ n/ s% L" `6 n( `: y
Individual Data (Maximum 20 marks available)9 ]" h# y( s& t) ^% @
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.
% b! C& U, B& u: l1 l( hDocumentation (Maximum 10 marks available)9 I3 T% t: i4 o4 a1 X7 Z7 v
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.! U+ v* A: b" _/ n2 @
BSA104 Business Programming – 2007: Assignment 2
' x9 X8 u- K% ~Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了/ F& z5 ~! E5 R
不过你要翻JAVA的类库说明。你有下载没有?
; E. F3 e% h/ g8 @& N# w$ x  |查询关于对比的函数。貌似关键字是contrast,还有compare
$ \  w- B% A/ s4 w) R
- S8 {  ~# b3 G* ?[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
) }! w: P$ U  \' V痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
( {5 `4 t2 a/ F9 A可以下载到的 是 jdk-1_X_0-doc
$ w* X& n  l6 f2 \+ l5 N# s% t+ R; t/ d3 ~( f* m5 p9 d0 m
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-3 08:22

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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