Question
There are two main parts to this assignment. Write the VisitProcedure and Appointment classes. Write two classes to handle the user interface. Part 1 -
There are two main parts to this assignment.
Write the VisitProcedure and Appointment classes.
Write two classes to handle the user interface.
Part 1 - Class Specifications
Class VisitProcedure
Member Variables (all private)
Variables | Data Type | Description |
Procedure | Procedure | Contains the procedure being done. |
Quantity | double | Contains the quantity of the procedure being done. |
IsCoveredByInsurence | Boolean | Indicates whether or not this procedure is covered by insurance. |
PctCovered | Double | The percentage of the procedure that is covered by insurance. The percentage should be given in the range 0.0 -1.0. For example, 50% would be .5 . |
Member Method Signatures and Descirptions (all public)
Default Constructor | Default constructor. Sets the values of each member variable to default values. Hint: Make sure that new is called for reference types. |
Get/set methods for all member variables | The get/set values for reference types should just get and set instance references. |
double CalculateProcedureAmount() | Returns the procedure amount (this does NOT take insurance into account). This is the price of the procedure times the quantity. Note: This method should NOT print anything on the screen. It just returns the data from the method. |
double CalculateProcedureAmountCovered() | Returns the procedure amount that is covered by insurance. If the procedure is not covered (check IsCovered member variable) then return 0. If the procedure is covered then calculate the amount covered from the procedure amount using percent covered. Note: This method should NOT print anything on the screen. It just returns the data from the method. |
double CalculateProcedureAmountDue() | Returns the procedure amount that the customer actually has to pay (not covered by insurance). This is the price of the procedure times the quantity with the amount covered by insurance subtracted from it. You should only take insurance into account if the IsCovered member is true. For example, assume the following: price = 100, quantity=2, IsCoveredByInsurance=true, PctCovered=.75. The procedure amount is 200. The amount covered by insurance is 150. This means the procedure amount due is 50. So the value 50 would be returned from the function for this example. Note: This method should NOT print anything on the screen. It just returns the data from the method. |
void Write(PrintStream ps) | Write the contents of all member variables to the given instance of PrintStream. Assume the PrintStream is already open and ready to use. Data should be written on to separate lines. DO NOT ADD ANY DESCRIPTIVE TEXT IN THE OUTPUT. JUST PRINT THE VALUES. IMPORTANT - Whatever data is written out should be readable by the Read method of this class. If descriptive text is added then Read will not work. |
void Read(Scanner s) | Read the contents of all member variables from the given instance of Scanner. Assume the following inside the method: 1. Scanner is already open. 2. Member variable values are on separate lines. |
String GetJSON() | This method should return a string using JSON formatting (www.json.org). Here is the format: { variable name : value, } Each variable name should be surrounded by quotes. If the variable data type is String then the value should be surrounded by double quotes. There should be a comma between each pair (no comma after the last pair). Check at the end of document for an example of a properly formatted JSON string for this class. |
@Override String toString() | This method should return a String instance (not print on the screen) that contains the values of member variables with descriptive text. Here is an example of a string that gets returned from the method. For example: Name: Physical Therapy Price: $100.00 Quantity: 2.0 Is Covered By Insurance: true Pct Covered: 0.5 |
Class Appointment
Member Variables (all private)
Variable | Data Type | Description |
Month | int | Contains the month of the appointment. |
Day | int | Contains the day of the appointment. |
Year | int | Contains the year of the appointment. |
Pet | Pet | Contains the pet being seen at the appointment. |
Member Method Signatures and Descirptions (all public)
Default Constructor | Default constructor. Sets the values of each member variable to default values. Hint: Make sure that new is called for reference types. |
Get/set methods for all member variables | The get/set values for reference types should just get and set instance references. |
void Write(PrintStream ps) | Write the contents of all member variables to the given instance of PrintStream. Assume the PrintStream is already open and ready to use. Data should be written on to separate lines. DO NOT ADD ANY DESCRIPTIVE TEXT IN THE OUTPUT. JUST PRINT THE VALUES. IMPORTANT - Whatever data is written out should be readable by the Read method of this class. If descriptive text is added then Read will not work. |
void Read(Scanner s) | Read the contents of all member variables from the given instance of Scanner. Assume the following inside the method: 1. Scanner is already open. 2. Member variable values are on separate lines. |
String GetJSON() | This method should return a string using JSON formatting (www.json.org). Here is the format: { variable name : value, } Each variable name should be surrounded by quotes. If the variable data type is String then the value should be surrounded by double quotes. There should be a comma between each pair (no comma after the last pair). Check at the end of document for an example of a properly formatted JSON string for this class. |
@Override String toString() | This method should return a String instance (not print on the screen) that contains the values of member variables with descriptive text. Here is an example of a string that gets returned from the method. For example: Date: 9/3/2018 Name: Snickers Species: Dog Gender: Male |
Procedure class
import java.io.*;
import java.util.*;
public class Procedure {
// Instance variables
String name;
double price;
// Default constructor
public Procedure() {
name = "";
price = 0.0;
}
// Parameterized constructor
Procedure(String name, double price) {
this.name = name;
this.price = price;
}
// getters and setters
public void setName(String na) {
name = na;
}
public void setPrice(double pr) {
price = pr;
}
String getName() {
return name;
}
double getPrice() {
return price;
}
public String toString() {
return " Name: " + getName() + "\t Price: " + getPrice();
}
// Method to write procedure data to file
void Write(PrintStream ps) {
ps.println();
ps.println(getName());
ps.print(getPrice());
ps.close();
}
// Method to read file
void Read(Scanner s) {
setName(s.nextLine());
setPrice(s.nextDouble());
}
} // End of class procedure
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started