谁会JAVA编程
救急没人懂吗? 偶懂一点点点 我在做作业啊...遇到不会的问下你.. 还给老师了 我晕到,做JAVA的作业啊,你学啥子的 问下,如果有两个.java的文件,这两个文件有相似性...我们的要求是写一个另外的java程序,然后可以载如 这两个java文件,进行code的逐行对比,然后列出相似的行和相似内容,应该用什么类 //*********************************************************************
//ProgramCompare.java Provided by: DRS
//
//Program shell for Assignment 2
//
//Compares two text files line by line
//*********************************************************************
import java.io.*;
public class ProgramCompare
{
//-----------------------------------------------------------------
// Constructor
//-----------------------------------------------------------------
public ProgramCompare()
{
}
//-----------------------------------------------------------------
// Method for testing that class has been reached
//-----------------------------------------------------------------
public boolean ProgramCompareReached()
{
try
{
//********************************************************************
// Try-Catch Statement is used to handle exceptions - such as file not found
// Reading the files will need to be placed inside a Try-Catch - just like this one!
// For more information see page 534 of the textbook
//********************************************************************
}
catch (Exception ex) // Exception caught here and message displayed to the screen
{
ex.printStackTrace (System.err);
System.out.println ("Error message goes here"); // Replace this error message with your own
}
return true;
}
} // end of class ProgramCompare
//----------------------------------------------------------------- //********************************************************************
//ProgramCompareMenu.java Provided by: DRS
//
//Calls AuthorisedUsers.java and ProgramCompare.java
//
//Driver shell for Assignment 2.
//********************************************************************
class ProgramCompareMenu
{
public static void main (String[] args)
{
//Check that the two classes ProgramCompare and AuthorisedUsers are reachable
ProgramCompare reached1 = new ProgramCompare();
AuthorisedUsers reached2 = new AuthorisedUsers();
System.out.println("ProgramCompare reached? " + reached1.ProgramCompareReached());
System.out.println("AuthorisedUsers reached? " + reached2.AuthorisedUsersReached());
}
}// end of class ProgramCompareMenu
//----------------------------------------------------------------- //********************************************************************
// AuthorisedUsers.java Provided by: DRS
//
// Program shell for Assignment 2
//
// Represents facts about an AuthorisedUser
//********************************************************************
public class AuthorisedUsers
{
//-----------------------------------------------------------------
// Constructor
//-----------------------------------------------------------------
public AuthorisedUsers()
{
}
//-----------------------------------------------------------------
// Method for testing that class has been reached
//-----------------------------------------------------------------
public boolean AuthorisedUsersReached()
{
return true;
}
} // end of class AuthorisedUsers
//----------------------------------------------------------------- BSA104 Business Programming
Shanghai - 2007
Assignment 2
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. 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.
The staff must be able to:
Log on to the „system‟ using their user name, and a Personal Identification Number (PIN) which is a four digit number **.
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.
The interface should provide a menu so that the staff can:
a) Enter the names of the two Java program files to be compared
For this assignment, it will be assumed that the two Java program files are in the same folder as your program.
** 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).
BSA104 Business Programming – 2007: Assignment 2
Page 2 of 5
b) Print out to the screen all the lines of code that are the same
Include the name of the file and the line number of the code being printed for each of the two files
c) Print out to the screen all the available information regarding the evaluation of the two Java program files being compared
the name, username and department of the user
the statistics of the comparison
- For example: the number of lines of code checked, the number of lines the same, the number of lines that are different
the recommendation for further checking
- 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
the names of the two files compared
d) Leave the program (exit)
The ProgramCompare class: (Total maximum 20 marks available)
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)
a) provide an error message if the files are not found or there is a problem opening them
b) compare each line of code
c) print out the lines that are the same
d) count the number of lines compared / lines the same
The AuthorisedUsers class: (Total maximum 20 marks available)
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)
4. Provide methods to:
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
b) return the name of the authorised user
c) return the name of the department of the authorised user
Individual Data (Maximum 20 marks available)
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.
Documentation (Maximum 10 marks available)
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.
BSA104 Business Programming – 2007: Assignment 2
Page 3 of 5 上面是作业要求,然后前三个是给的java程序,要求自己修改- - 我的妈咪哦,这个已经超出了,我的一点点了
不过你要翻JAVA的类库说明。你有下载没有?
查询关于对比的函数。貌似关键字是contrast,还有compare
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:05 编辑 ] ,.....看来还要翻书哇....我学信息系统的- -
痛苦啊15搞要交..没觉睡了 不是翻书,是要翻在SUN下载的JAVA的手册,书有个毛用。
可以下载到的 是 jdk-1_X_0-doc
[ 本帖最后由 =|HERO|=GreatWall 于 2007-5-9 14:09 编辑 ]
页:
[1]
2