Congratulations—you've been hired by a pet setting and grooming company called Pet Elevator. They're building their own software to use in-house.
Your job is to create classes for the Customer Relationship Management (CRM) system. A CRM system helps to manage customer information and other related data.
Since Pet Elevator is a pet sitting and grooming company, you'll need to create a class to represent the human customers and a class to represent their pets.
Open the Week 3 review project in IntelliJ.
The software team has started building a system for the Human Resources (HR) department to manage employee, manager, and department information.
Take a moment to explore the starting code in the com.techelevator package and com.techelevator.hr package:
com.techelevatorPerson.java: base class representing a personBillable.java: interface defining methods for objects that are "billable"—meaning someone that can be billed for services
com.techelevator.hrDepartment.java: class to represent a department in the businessEmployee.java: class to represent an employee of the company, inheritsPersonclassManager.java: class to represent a manager of the company, inheritsEmployeeclass
Review and run the existing tests in the /src/test/java/com/techelevator package. All of the tests pass when you first open the project. You'll write additional tests to validate the code you'll add in this exercise.
- If there's nothing in the set column, that means the property is a derived property.
- All classes you create must be in the
com.techelevator.crmpackage.- By convention, these classes go in the
src\main\java\com\techelevator\crmfolder.
- By convention, these classes go in the
- The project must not have any build errors.
- All unit tests pass as expected.
- Appropriate variable names and data types are used.
- Code is presented in a clean, organized format.
- Code is appropriately encapsulated.
- The code meets the specifications defined below.
There are no provided unit tests. You'll also write tests for the methods you write.
| Property | Data Type | Get | Set | Description |
|---|---|---|---|---|
name |
String |
X | X | Name of pet. |
species |
String |
X | X | Species of pet, like dog or cat. |
vaccinations |
List<String> |
X | X | Vaccinations the pet has received. |
Note: Remember to set
vaccinationsto a new initializedArrayList. You can do this in the property declaration or constructor.
Create one constructor for Pet that accepts two Strings to set name and species.
| Method Name | Return Type | Parameters |
|---|---|---|
listVaccinations |
String |
none |
The listVaccinations method returns the elements of vaccinations as a comma-delimited string. For example, if the List contains ["Rabies", "Distemper", "Parvo"], the output must be "Rabies, Distemper, Parvo".
Keep in mind the spaces between and not to have a trailing comma.
Create a PetTests class in the com.techelevator.crm package. Create a test for listVaccinations.
Declare a Customer class that inherits the Person class.
| Property | Data Type | Get | Set | Description |
|---|---|---|---|---|
phoneNumber |
String |
X | X | Customer's phone number. |
pets |
List<Pet> |
X | X | Collection of customer's pets. |
Note: Remember to set
Petsto a new initializedArrayList. You can do this in the property declaration or constructors.
Customer needs two constructors:
- One that accepts three
Stringparameters for first name, last name, and phone number.- This constructor must set the phone number property, and call the base class constructor for first and last name.
- One that accepts two
Stringparameters for first name and last name.- This constructor must call the first constructor with an empty string for phone number.
You received an additional requirement to implement the Billable interface on the Customer class and the Employee class because employees can also be customers.
The Billable interface defines a method with the signature double getBalanceDue(Map<String, Double>). You need to implement this method in the Customer and Employee classes.
| Method Name | Return Type | Parameters |
|---|---|---|
getBalanceDue |
double |
Map<String, Double> |
The getBalanceDue method returns the total amount the customer owes.
It accepts one parameter, a Map of services rendered:
- The key is a
Stringrepresenting the type of service—for example, "Grooming", "Walking", or "Sitting." - The value is a
Doublerepresenting the price for each service.
Employees receive a 50% discount on walking services, but the discount isn't applied in the Map provided. In the Employee implementation of the method, you'll have to calculate the discount.
Create a CustomerTests class in the com.techelevator.crm package. Create a test for getBalanceDue.
You'll also need to add a test for getBalanceDue in the EmployeeTests class. Keep in mind the discount.