| Project #6 | CMSC 131 |
| Due Tuesday 11/15/05 | Object-Oriented Programming I |
| Type of Project: Closed | Fall 2005 |
Warning: This project requires a significant amount of work and is probably the longest project assignment of the course. We encourage you to start working on it immediately. Office hours get extremely busy a few days before the project is due and you may not receive the assistance you need if you delay working on this project. Keep in mind that the submit server cannot test your submission instantaneously and in some cases it can take several minutes (or hours) to process the test suite. If you wait until the last minute to submit your project, you may not be able to verify the results generated by your project.
Objective
This project will give you practice designing object-based solutions to problems. In addition, it will allow you to practice using arrays of references.
Overview
For this project you will implement a very simple database system for a software company. Your program will allow the company to keep track of customers and different types of software the company develops. You will design and implement all the classes needed to complete the database application. You may want to take a look at the Sample Run section before you read the detailed description.
This project will be graded as follows: 70% (Implementation), 20% (Design), 10% (Style)
Program Overview
You will write a program that enables a software company to keep track of the its customers and the software products it develops. The program will handle the following tasks:
The Name class
We wrote this class for you. Please familiarize yourself with the implementation, provided. You will certainly make use of the following methods:
What you must implement, in a nutshell
You must design and implement a working solution to this problem! The design will include documentation for each of the classes that are part of the application and the methods for each class. You are expected to design your own classes for representing the basic entities that the program manipulates. You will document your design in the design.txt file, which is part of the code distribution. (More specific instructions are in that file.) Don't forget to complete the design.txt file -- this is 20% of your grade on the project! After completing your design, you will implement it. The number of classes you decide to use is up to you; however, you must follow the set of restrictions specified below.
Before you read these specifications, you should access the files associated with this project by checking out the project named p6. The code distribution provides you with the following:
Database Representation
The database application will be represented using two lists:
How you represent these lists is part of your design. You may follow any approach you deem necessary as long as it adheres to the specifications of the project. Note that you will not use any sorting algorithm in this project. For example, you will keep your customer list sorted by inserting elements in the appropriate position in the list.
Required Classes
You must implement and use the following classes:
Customer
This class represents a customer. A customer is identified by a name, email address, and an array of software products licensed to the customer. As is the case for the software products lists (for the overall database application), the customer's software list does not need to be sorted and elements are added to the end. The Customer class should include appropriate instance variables for the name, email address, and software products. We leave it up to you as to which methods you must define for the Customer class. (You must use the Name class to store the names of the customers.)
CompanyDatabase
This class represents the database. The methods' prototypes and behaviors are defined next. You must not change the following methods' prototypes or add any other public methods.
public boolean addSoftware(String name, String version, String code);
The name parameter represents the software's name. The version parameter provides a version tag and the code parameter represents the code for this software (yes, it is an open software company ☺). The code is simply a collection of characters (any characters representing a computer program), e.g., "int main() { }" This method will return true if the add operation was completed successfully and false if the software product was already in the database. Keep in mind that a software product is uniquely identified by the combination of name and a version number.
public String findSoftware(String name, String version);
The format of the String to return is:
SoftwareString ® "Software Name: " name "|Version: "version"|Code: " code
where name, version, and code correspond to the software's name, version and code respectively. For example:
Software Name: VPNS|Version: 1.0|Code: int main() {// VPNS implementation }
public String getSoftwareList();
The format of the String to be returned is a sequence of SoftwareString each on a line by itself. We refer to this list as the SoftwareStringList.
public boolean addCustomer(String name, String email);
The collection of customers is kept sorted by customer name (according to the order determined by the Name class). For example, Rose Johnson will appear before Albert Smith. The method will return true if the add operation was successful and false otherwise (e.g., if the customer is already part of the database).
public String findCustomer(String name);
The format of the String to return is one of the following:CustomerString®
OR
CustomerString®
public boolean removeCustomer(String name);
Returns true if the remove operation was successful and false otherwise (e.g., the name is not found).
public String getCustomerList();
The format of the String to be returned is a sequence of CustomerString each on a new line. We refer to this list as the CustomerStringList.
public boolean licenseSoftwareToCustomer(String customerName, String softwareName, String softwareVersion);
The method returns true if the software is licensed successfully and false otherwise (e.g., the customer doesn't exist or the software is not in the Software Products list).
public String[] newSoftwareVersion(String name, String version, String code);
Besides adding the software, the method returns an array of e-mail addresses. These e-mail addresses represent the customers that have other versions of the software. (The idea is that the company could use this mailing list to notify users of the availability of the update.) The method will return null if there are no customers to notify. Note: The customers' software is not updated by this method.
public String toString();
The format of the String to return is the following:
DatabaseString®
If any of the lists is empty then only the corresponding header will appear.
Additional Classes
As part of your design you will need to define classes in addition to the ones described above. Think carefully about the classes you will need. A good design can simplify dramatically the amount of time you will spend implementing your design. For example, we recommend you implement a class called Software which represents a software product.
Requirements/Assumptions
Complete the design.txt file you will find in the code description. (Specific instructions can be found in that file.)
At the end of this page you will find a class ExampleDriver.java and the output that it produces. Access to the database application is through the CompanyDatabase class you will implement. The class ExampleDriver.java can be found in the code distribution.
Challenge Problem
Remember that you are not required to implement the following problem (unless you are enrolled in the honors section). Please visit the course web page for information regarding challenge problems. IMPORTANT: If you decide to complete the challenge problem you must provide its implementation in the file called Challenge.java. Remember to define a main method in the Challenge class that allow us to run your program.
The challenge problem consists of defining a GUI for the database software application. The GUI should allow a user to complete all the tasks associated with the CompanyDatabase class. Feel free to define your interface as you understand is best.
For students in the Honors section: If your GUI doesn't implement ALL of the functionality of the CompanyDatabase class you can still receive partial credit, based on how much functionality your GUI provides.
IMPORTANT: Make sure that your Challenge class has a default constructor, which will create an empty database and draw the GUI for us to test by running it manually.
Submission
Submit your project using the submit project option associated with Eclipse. Make sure that the submit server generates the expected results.
ExampleDriver.java
(This is provided in the code distribution.)
public class ExampleDriver {
public static void addSoftware(CompanyDatabase companyDatabase,
String name, String version, String code) {
System.out.println("Adding software: \"" + name + "\"");
companyDatabase.addSoftware(name, version, code);
System.out.println(companyDatabase + "\n");
}
public static void addCustomer(CompanyDatabase companyDatabase,
String name, String email) {
System.out.println("Adding customer: " + name);
companyDatabase.addCustomer(name, email);
System.out.println(companyDatabase + "\n");
}
public static void main(String[] args) {
String results = "", info;
CompanyDatabase companyDatabase = new CompanyDatabase();
/* An empty database */
System.out.println("Initial database with no data");
System.out.println(companyDatabase + "\n");
/* Adding some software and printing the database status after each add */
addSoftware(companyDatabase, "VPNS", "1.0", "int main() {// VPNS implementation }");
addSoftware(companyDatabase, "Ninux", "2.0", "public static void main(String a){//Ninux implementation}");
addSoftware(companyDatabase, "FireDog", "1.5", "int main() {// FireDog implementation }");
/* Adding some customers and printing the database status after each add */
addCustomer(companyDatabase, "Isaac Newton", "gravity@it.falls.com");
addCustomer(companyDatabase, "Albert Einstein","relativity@physics.smart.out" );
addCustomer(companyDatabase, "Marie Curie","lovePhysics@great.science.com" );
/* Printing software and customer's lists */
System.out.println("***Software Collection***\n" + companyDatabase.getSoftwareList() + "\n");
System.out.println("***Customers ***\n" + companyDatabase.getCustomerList() + "\n");
/* Look up operations */
System.out.println("***Looking for a \"Ninux\" software");
if ((info = companyDatabase.findSoftware("Ninux", "2.0")) != null)
System.out.println(info + "\n");
System.out.println("***Looking for a customer \"Marie Curie\"");
if ((info = companyDatabase.findCustomer("Marie Curie")) != null)
System.out.println(info + "\n");
/* Assigning software to customer */
System.out.println("***Licensing \"Ninux\" software to Isaac Newton");
companyDatabase.licenseSoftwareToCustomer("Isaac Newton", "Ninux", "2.0");
System.out.println(companyDatabase + "\n");
System.out.println("***Licensing \"FireDog\" software to Isaac Newton");
companyDatabase.licenseSoftwareToCustomer("Isaac Newton", "FireDog", "1.5");
System.out.println(companyDatabase + "\n");
System.out.println("***Licensing \"FireDog\" software to Albert Einstein");
companyDatabase.licenseSoftwareToCustomer("Albert Einstein", "FireDog", "1.5");
System.out.println(companyDatabase + "\n");
/* Adding wew software version */
System.out.println("***Adding new software version for FireDog");
String[] mailingList = companyDatabase.newSoftwareVersion("FireDog", "2.0", "int main() {// FireDog update implementation }");
System.out.println(companyDatabase + "\n");
System.out.println("***Update notices for FireDog");
if (mailingList != null) {
System.out.println("Update notices should be sent to:");
for (int i=0; i<mailingList.length; i++)
System.out.println(mailingList[i]);
}
}
}
Output of ExampleDriver.java
Initial database with no data
**** Company's Software ****
**** Company's Customers ****
Adding software: "VPNS"
**** Company's Software ****
Software Name: VPNS|Version: 1.0|Code: int main() {// VPNS implementation }
**** Company's Customers ****
Adding software: "Ninux"
**** Company's Software ****
Software Name: VPNS|Version: 1.0|Code: int main() {// VPNS implementation }
Software Name: Ninux|Version: 2.0|Code: public static void main(String a){//Ninux
implementation}
**** Company's Customers ****
Adding software: "FireDog"
**** Company's Software ****
Software Name: VPNS|Version: 1.0|Code: int main() {// VPNS implementation }
Software Name: Ninux|Version: 2.0|Code: public static void main(String a){//Ninux
implementation}
Software Name: FireDog|Version: 1.5|Code: int main() {// FireDog implementation
}
**** Company's Customers ****
Adding customer: Isaac Newton
**** Company's Software ****
Software Name: VPNS|Version: 1.0|Code: int main() {// VPNS implementation }
Software Name: Ninux|Version: 2.0|Code: public static void main(String a){//Ninux
implementation}
Software Name: FireDog|Version: 1.5|Code: int main() {// FireDog implementation
}
**** Company's Customers ****
Name: Isaac Newton, Email: gravity@it.falls.com
Software List: None
Adding customer: Albert Einstein
**** Company's Software ****
Software Name: VPNS|Version: 1.0|Code: int main() {// VPNS implementation }
Software Name: Ninux|Version: 2.0|Code: public static void main(String a){//Ninux
implementation}
Software Name: FireDog|Version: 1.5|Code: int main() {// FireDog implementation
}
**** Company's Customers ****
Name: Albert Einstein, Email: relativity@physics.smart.out
Software List: None
Name: Isaac Newton, Email: gravity@it.falls.com
Software List: None
Adding customer: Marie Curie
**** Company's Software ****
Software Name: VPNS|Version: 1.0|Code: int main() {// VPNS implementation }
Software Name: Ninux|Version: 2.0|Code: public static void main(String a){//Ninux
implementation}
Software Name: FireDog|Version: 1.5|Code: int main() {// FireDog implementation
}
**** Company's Customers ****
Name: Marie Curie, Email: lovePhysics@great.science.com
Software List: None
Name: Albert Einstein, Email: relativity@physics.smart.out
Software List: None
Name: Isaac Newton, Email: gravity@it.falls.com
Software List: None
***Software Collection***
Software Name: VPNS|Version: 1.0|Code: int main() {// VPNS implementation }
Software Name: Ninux|Version: 2.0|Code: public static void main(String a){//Ninux
implementation}
Software Name: FireDog|Version: 1.5|Code: int main() {// FireDog implementation
}
***Customers ***
Name: Marie Curie, Email: lovePhysics@great.science.com
Software List: None
Name: Albert Einstein, Email: relativity@physics.smart.out
Software List: None
Name: Isaac Newton, Email: gravity@it.falls.com
Software List: None
***Looking for a "Ninux" software
Software Name: Ninux|Version: 2.0|Code: public static void main(String a){//Ninux
implementation}
***Looking for a customer "Marie Curie"
Name: Marie Curie, Email: lovePhysics@great.science.com
Software List: None
***Licensing "Ninux" software to Isaac Newton
**** Company's Software ****
Software Name: VPNS|Version: 1.0|Code: int main() {// VPNS implementation }
Software Name: Ninux|Version: 2.0|Code: public static void main(String a){//Ninux
implementation}
Software Name: FireDog|Version: 1.5|Code: int main() {// FireDog implementation
}
**** Company's Customers ****
Name: Marie Curie, Email: lovePhysics@great.science.com
Software List: None
Name: Albert Einstein, Email: relativity@physics.smart.out
Software List: None
Name: Isaac Newton, Email: gravity@it.falls.com
Software List:
Software Name: Ninux|Version: 2.0|Code: public static void main(String a){//Ninux
implementation}
***Licensing "FireDog" software to Isaac Newton
**** Company's Software ****
Software Name: VPNS|Version: 1.0|Code: int main() {// VPNS implementation }
Software Name: Ninux|Version: 2.0|Code: public static void main(String a){//Ninux
implementation}
Software Name: FireDog|Version: 1.5|Code: int main() {// FireDog implementation
}
**** Company's Customers ****
Name: Marie Curie, Email: lovePhysics@great.science.com
Software List: None
Name: Albert Einstein, Email: relativity@physics.smart.out
Software List: None
Name: Isaac Newton, Email: gravity@it.falls.com
Software List:
Software Name: Ninux|Version: 2.0|Code: public static void main(String a){//Ninux
implementation}
Software Name: FireDog|Version: 1.5|Code: int main() {// FireDog implementation
}
***Licensing "FireDog" software to Albert Einstein
**** Company's Software ****
Software Name: VPNS|Version: 1.0|Code: int main() {// VPNS implementation }
Software Name: Ninux|Version: 2.0|Code: public static void main(String a){//Ninux
implementation}
Software Name: FireDog|Version: 1.5|Code: int main() {// FireDog implementation
}
**** Company's Customers ****
Name: Marie Curie, Email: lovePhysics@great.science.com
Software List: None
Name: Albert Einstein, Email: relativity@physics.smart.out
Software List:
Software Name: FireDog|Version: 1.5|Code: int main() {// FireDog implementation
}
Name: Isaac Newton, Email: gravity@it.falls.com
Software List:
Software Name: Ninux|Version: 2.0|Code: public static void main(String a){//Ninux
implementation}
Software Name: FireDog|Version: 1.5|Code: int main() {// FireDog implementation
}
***Adding new software version for FireDog
**** Company's Software ****
Software Name: VPNS|Version: 1.0|Code: int main() {// VPNS implementation }
Software Name: Ninux|Version: 2.0|Code: public static void main(String a){//Ninux
implementation}
Software Name: FireDog|Version: 1.5|Code: int main() {// FireDog implementation
}
Software Name: FireDog|Version: 2.0|Code: int main() {// FireDog update
implementation }
**** Company's Customers ****
Name: Marie Curie, Email: lovePhysics@great.science.com
Software List: None
Name: Albert Einstein, Email: relativity@physics.smart.out
Software List:
Software Name: FireDog|Version: 1.5|Code: int main() {// FireDog implementation
}
Name: Isaac Newton, Email: gravity@it.falls.com
Software List:
Software Name: Ninux|Version: 2.0|Code: public static void main(String a){//Ninux
implementation}
Software Name: FireDog|Version: 1.5|Code: int main() {// FireDog implementation
}
***Update notices for FireDog
Update notices should be sent to:
relativity@physics.smart.out
gravity@it.falls.com