找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1028|回复: 20

谁会JAVA编程

[复制链接]
发表于 2007-5-9 13:27:08 | 显示全部楼层 |阅读模式
救急' ^8 H2 }7 C) X5 l( ?' Z! ?' v3 R ! \0 A( _. I% N7 b' T1 d U, Z* w. ]
回复

使用道具 举报

 楼主| 发表于 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 | 显示全部楼层
//*********************************************************************
4 e8 s. B9 h) m% y  B6 s2 \//  ProgramCompare.java         Provided by: DRS
1 Z- y4 L  L+ }1 l5 x/// W, a+ x7 C3 Z3 N$ y1 P
//  Program shell for Assignment 2
- ]. f6 j  p: \//
5 {. u% X& |) ^& z" H8 b# j% J% h//  Compares two text files line by line
1 X9 ?/ E* O% x( K  |; _2 k5 S' k//*********************************************************************
/ O3 d% m. U! q6 b/ e/ K
8 o# j$ W+ \) D0 a6 Cimport java.io.*;! ~9 ]" W8 G$ O0 |) Y
) t% w- p% p1 b- ~$ R
public class ProgramCompare# l3 [0 c. {: a( k% m* R. _- j
{
. p) `8 ]9 Y% s        //-----------------------------------------------------------------) Q8 T6 g: f6 L0 R8 E- E& i+ _6 t  @
        // Constructor& Q  e7 @1 X1 k7 j% Z, Q
        //-----------------------------------------------------------------
4 @  f6 U5 x) k( `( J        public ProgramCompare()! _7 ]) @. |1 {8 ]
        {5 v2 O& n. Y) j: q) \! h
        }! ~, X) W) b( x4 B; m: F

" \, |& j: }+ k8 t3 E4 r        //-----------------------------------------------------------------
# C* H2 j$ Y$ U        // Method for testing that class has been reached
( I4 ?# R) K: R) ^- f        //-----------------------------------------------------------------       
  P! F  Z/ R4 g$ O* X7 `# [
$ R& ]; x8 ~/ R7 Y2 T4 [4 B        public boolean ProgramCompareReached()         # t7 v2 m) I1 `, V& ^* J
        {, H6 m8 D6 R8 G( E) F0 _( ^
      try ' Y  g5 ~. n! J; x$ o; K
   {        
3 H) Z& ]' N! f$ F7 B% u, C0 j/ V                       
4 W9 A7 `% @) H4 e9 ~                //********************************************************************  u3 q% R) Q' T. W6 {+ z7 J
                // Try-Catch Statement is used to handle exceptions - such as file not found * U" ~# z& z" g& U
                // Reading the files will need to be placed inside a Try-Catch - just like this one!
0 m8 m9 ?. l+ u$ x3 z$ T                // For more information see page 534 of the textbook
$ j8 G, h# Z3 v& q                //********************************************************************, K7 G  |9 b5 X+ }3 L
                     ) d5 a0 ~& F/ }" K3 l! ^+ J) j
        }5 J0 b$ j4 {1 m' T
             catch (Exception ex) // Exception caught here and message displayed to the screen , M# L$ D  M4 j; s  `1 y/ \
          {/ a  q, y% U9 @( E  v+ B
                    ex.printStackTrace (System.err);* h+ N& g8 t# F( j1 R4 R  w) k; p
           System.out.println ("Error message goes here"); // Replace this error message with your own          8 V+ f1 j5 d2 l9 c) D, Q
        }
# i" W# `3 J9 `0 A1 N) Y( F" F% K                return true;9 ]9 p3 j: n# d
        }
+ V$ c; ]# e: u7 e6 b
5 ~( [+ X9 O- P( ^/ o} // end of class ProgramCompare: r  E$ s* W2 X  [1 r; C
8 X: x3 |' J2 @% s
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:41 | 显示全部楼层
//********************************************************************  c2 B7 _6 C/ p  y4 c0 V& j1 y
//  ProgramCompareMenu.java    Provided by: DRS
: E- I& Y9 P! K/ N3 D+ `//
7 z" Z; C6 \+ ]$ w) Y' H//  Calls AuthorisedUsers.java and ProgramCompare.java. ?- S! v  G" w7 ?$ \% m' c; S& D
//
2 m0 f3 P1 @  e! j6 L0 `//  Driver shell for Assignment 2.* D; \1 m/ U/ z: z% d  n) M& X
//********************************************************************; `7 t/ w2 N' |4 A

% p" U3 E+ s) x- r: y# Sclass ProgramCompareMenu% k2 Y& Y; ?  l/ T0 o4 J9 G7 R
{. a6 d/ h7 h' C/ l: w) P
    public static void main (String[] args)
! i  C3 I" A& l: W            {/ Q' h. N% a8 q" G! O3 ^
                //Check that the two classes ProgramCompare and AuthorisedUsers are reachable
. h* g+ R( X: L& ?                ProgramCompare reached1 = new ProgramCompare();
( P9 a4 k9 m+ M/ t                AuthorisedUsers reached2 = new AuthorisedUsers();       
+ D  ~. J6 P: y$ b. i                System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());/ n5 U8 ~" t, L* @, o) |4 X
                System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());        : U$ j& G: o% `- f5 I
        }: A% j2 H% |: m
}// end of class ProgramCompareMenu
, O# |0 Y, H$ m/ p) m' k- n% j; b5 s; H; |& Y, {4 z
//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:01:55 | 显示全部楼层
//********************************************************************
1 k# E9 p0 i- j4 i$ l+ x//          AuthorisedUsers.java          Provided by: DRS" c( i3 W4 E1 K: K2 t
//               
: W! j* ]0 z2 v; r; s//         Program shell for Assignment 21 a1 b# d7 }* O# {% L" f& p
//
) l% @% @6 @2 @3 A5 m: a  V( c//         Represents facts about an AuthorisedUser0 x8 V# {! V% @( C
//********************************************************************
  Y8 Q8 _2 p2 \) i: d1 [+ ]
- _% W$ |1 p( f& {+ M$ p6 apublic class AuthorisedUsers
, l* G% _! e6 G- {9 p8 R% \    {) X9 q( |1 a' w5 l. C- P
# b  ?$ l) d! z% a, \
        //-----------------------------------------------------------------4 C/ s3 `8 t* O1 S+ @, z7 q9 ?
        // Constructor
  J" G+ P  V$ }& \; }6 I        //-----------------------------------------------------------------
3 u9 b- h* j2 ^: E1 V
% T6 z' G& k1 B: U3 o8 v        public AuthorisedUsers()9 d; ^9 G9 c8 x( x1 D1 y
                {
3 x+ U+ x* Y/ `+ g* r6 [                }
  d6 L. j- K  x  o1 G2 D  E6 o# t6 G6 O
        //-----------------------------------------------------------------
7 Y* q. t( M$ p        // Method for testing that class has been reached$ a9 v- s4 f5 E3 o# u8 p
        //-----------------------------------------------------------------        4 c( J$ _- u9 {. \( B
        public boolean AuthorisedUsersReached()! V, U9 w: z# c
                {
% X: s& Q; k) [/ d                        return true;                       
# ~" V. O! `$ x  T& r3 x% S: k                }: c$ W  m0 a$ s+ X5 x' R
                . Z. W+ C0 ^; J  r- c9 P
    } // end of class AuthorisedUsers
5 R5 p  z& k4 V* e//-----------------------------------------------------------------
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:03:32 | 显示全部楼层
BSA104 Business Programming  Q6 G- i7 G$ t: P5 ^8 D' ^
Shanghai - 2007
# @4 s5 {4 @: h$ {! e* e3 _Assignment 2
3 U- F% w- r: Q- c( [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)
1 W, I2 t* s8 v# U/ }# T8 b5 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.; g4 o  _* @$ c' h, Z
The staff must be able to:6 r( z% _8 e) R, p& I6 }- O
 Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
' V+ v* d  r8 c" K1. 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.
: i  t( a* p% a8 S The interface should provide a menu so that the staff can:
$ m4 P9 i- p/ E: ^# la) Enter the names of the two Java program files to be compared
- [  u. v8 |; t6 I$ U5 H For this assignment, it will be assumed that the two Java program files are in the same folder as your program.* @" r$ f8 i3 {" G; x) n
** 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).+ R$ i- @7 j  p# v* I0 B% H
BSA104 Business Programming – 2007: Assignment 2, _1 D$ v& g# H7 j0 F
Page 2 of 5) P. M9 ]5 t) z
b) Print out to the screen all the lines of code that are the same
* r; G9 s8 q1 y7 J& c( D3 G+ k Include the name of the file and the line number of the code being printed for each of the two files  ~8 T2 @- g% Q2 `  K# v: \
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared3 K' I, N2 c- q, s- a
 the name, username and department of the user- w" ?3 \8 }2 R4 ?5 H# O8 `, s
 the statistics of the comparison, Y/ i& q, z4 e3 ^: d
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different/ M9 B2 ~6 |3 Y; ?/ c+ N
 the recommendation for further checking
  @" s% V: w1 W2 ]% l5 G0 }- 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( @+ m5 K# r# v. V# o! n
 the names of the two files compared- Z# H' z/ B' C" r3 q! T: E
d) Leave the program (exit)
& U; `. k: a+ rThe ProgramCompare class: (Total maximum 20 marks available)+ y, u( x+ C5 ~3 ?) q' F% [3 ~
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)' T: F9 z: M  C; m+ t3 u
a) provide an error message if the files are not found or there is a problem opening them
6 ~* ]& T+ l# f: r& S) ?b) compare each line of code
& _) l# h8 [# `8 Lc) print out the lines that are the same% z' ?% y7 w( K" k/ T  J# b
d) count the number of lines compared / lines the same
' B' r6 I3 c6 M$ n: c- D; W! j. BThe AuthorisedUsers class: (Total maximum 20 marks available)
+ [/ |0 O' a4 ~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)
' _8 K5 }! m+ g, ?4. Provide methods to:
- c, W# \6 W0 E- pa) 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
9 N& ^3 v: d* C1 ?) ^" ~! ^b) return the name of the authorised user7 m7 ?% D5 ~+ _* C6 X
c) return the name of the department of the authorised user% ~7 [7 U8 b, n6 q6 N
Individual Data (Maximum 20 marks available)
+ }/ K8 u% D) E5. 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.+ m( v$ C* L2 y
Documentation (Maximum 10 marks available)
* o& V) U3 o2 v0 l3 p/ Y6. 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.
4 {% U: c0 K( O/ N6 U( G5 q3 wBSA104 Business Programming – 2007: Assignment 2& M' f, V& Q0 Q4 R: o6 M
Page 3 of 5
回复

使用道具 举报

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

使用道具 举报

发表于 2007-5-9 14:04:47 | 显示全部楼层
我的妈咪哦,这个已经超出了,我的一点点了
( K- K5 L5 G' t不过你要翻JAVA的类库说明。你有下载没有?6 I& A* O' S, ~) p- d% e
查询关于对比的函数。貌似关键字是contrast,还有compare6 P( V; G! V/ Q
# @/ {5 I9 z$ Q
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2007-5-9 14:06:19 | 显示全部楼层
,.....看来还要翻书哇....我学信息系统的- -
' h; g1 d4 N# N9 C. s! y# z  p, F痛苦啊15搞要交..没觉睡了
回复

使用道具 举报

发表于 2007-5-9 14:07:54 | 显示全部楼层
不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。) A1 }8 e1 \( l# \) N
可以下载到的 是 jdk-1_X_0-doc
; B" o# }& I" ?
+ t7 N: ^1 A& M5 O( [3 Z[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-9 15:33

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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