Initial Commit
This commit is contained in:
8
Source Code/Assignment8/.idea/.gitignore
generated
vendored
Normal file
8
Source Code/Assignment8/.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Datasource local storage ignored files
|
||||
/../../../../../../:\ProgrammingProjects\JavaProjects\JavaYear1\Assignment8\.idea/dataSources/
|
||||
/dataSources.local.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
25
Source Code/Assignment8/.idea/codeStyles/Project.xml
generated
Normal file
25
Source Code/Assignment8/.idea/codeStyles/Project.xml
generated
Normal file
@ -0,0 +1,25 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<JetCodeStyleSettings>
|
||||
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
||||
<value>
|
||||
<package name="java.util" alias="false" withSubpackages="false" />
|
||||
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
|
||||
<package name="io.ktor" alias="false" withSubpackages="true" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="PACKAGES_IMPORT_LAYOUT">
|
||||
<value>
|
||||
<package name="" alias="false" withSubpackages="true" />
|
||||
<package name="java" alias="false" withSubpackages="true" />
|
||||
<package name="javax" alias="false" withSubpackages="true" />
|
||||
<package name="kotlin" alias="false" withSubpackages="true" />
|
||||
<package name="" alias="true" withSubpackages="true" />
|
||||
</value>
|
||||
</option>
|
||||
</JetCodeStyleSettings>
|
||||
<ScalaCodeStyleSettings>
|
||||
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
|
||||
</ScalaCodeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
5
Source Code/Assignment8/.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
5
Source Code/Assignment8/.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
1
Source Code/Assignment8/.idea/description.html
generated
Normal file
1
Source Code/Assignment8/.idea/description.html
generated
Normal file
@ -0,0 +1 @@
|
||||
<html>Simple <b>Java</b> application that includes a class with <code>main()</code> method</html>
|
6
Source Code/Assignment8/.idea/discord.xml
generated
Normal file
6
Source Code/Assignment8/.idea/discord.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="PROJECT" />
|
||||
</component>
|
||||
</project>
|
6
Source Code/Assignment8/.idea/encodings.xml
generated
Normal file
6
Source Code/Assignment8/.idea/encodings.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="PROJECT" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
12
Source Code/Assignment8/.idea/misc.xml
generated
Normal file
12
Source Code/Assignment8/.idea/misc.xml
generated
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<entry_points version="2.0" />
|
||||
</component>
|
||||
<component name="ProjectKey">
|
||||
<option name="state" value="project://e2804f05-5315-4fc6-a121-c522a6c26470" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
8
Source Code/Assignment8/.idea/modules.xml
generated
Normal file
8
Source Code/Assignment8/.idea/modules.xml
generated
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/Assignment8.iml" filepath="$PROJECT_DIR$/Assignment8.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
3
Source Code/Assignment8/.idea/project-template.xml
generated
Normal file
3
Source Code/Assignment8/.idea/project-template.xml
generated
Normal file
@ -0,0 +1,3 @@
|
||||
<template>
|
||||
<input-field default="com.company">IJ_BASE_PACKAGE</input-field>
|
||||
</template>
|
124
Source Code/Assignment8/.idea/uiDesigner.xml
generated
Normal file
124
Source Code/Assignment8/.idea/uiDesigner.xml
generated
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
12
Source Code/Assignment8/Assignment8.iml
Normal file
12
Source Code/Assignment8/Assignment8.iml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,42 @@
|
||||
|
||||
*********************************
|
||||
* HARRISON FORD CUSTOMER SYSTEM *
|
||||
*********************************
|
||||
November 1, 2019
|
||||
----------------
|
||||
INVOICE for: John Smith
|
||||
model: Escape
|
||||
last visit: 1
|
||||
next visit cost: $32.00
|
||||
|
||||
INVOICE for: Harold Lee
|
||||
model: Fiesta
|
||||
last visit: 3
|
||||
next visit cost: $56.00
|
||||
months since discount: 3 (has warranty)
|
||||
|
||||
INVOICE for: Beth Blart
|
||||
model: Focus
|
||||
last visit: 4
|
||||
next visit cost: $68.00
|
||||
months since discount: 4 (has warranty)
|
||||
|
||||
November 1, 2020
|
||||
----------------
|
||||
INVOICE for: John Smith
|
||||
model: Escape
|
||||
last visit: 12
|
||||
next visit cost: $164.00
|
||||
|
||||
INVOICE for: Harold Lee
|
||||
model: Fiesta
|
||||
last visit: 0
|
||||
next visit cost: $20.00
|
||||
months since discount: 3 (has warranty)
|
||||
|
||||
INVOICE for: Beth Blart
|
||||
model: Focus
|
||||
last visit: 12
|
||||
next visit cost: $131.20
|
||||
months since discount: 16 (has warranty)
|
||||
|
75
Source Code/Assignment8/src/Customer.java
Normal file
75
Source Code/Assignment8/src/Customer.java
Normal file
@ -0,0 +1,75 @@
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* The customer class holds the name and car and methods relating to costs and last time visited
|
||||
* @author Isaac Shoebottom (3429069)
|
||||
*/
|
||||
|
||||
public class Customer {
|
||||
/**
|
||||
* (String) customer name
|
||||
*/
|
||||
private final String customer;
|
||||
/**
|
||||
* (String) car name
|
||||
*/
|
||||
private final String car;
|
||||
/**
|
||||
* (long) The time in months since the last time the customer has visited
|
||||
*/
|
||||
private long monthsSinceVisit = 0;
|
||||
|
||||
/**
|
||||
* Currency formatter
|
||||
*/
|
||||
NumberFormat cf = NumberFormat.getCurrencyInstance(Locale.CANADA);
|
||||
|
||||
/**
|
||||
* The constructor for the customer class, stores the customers name and car model
|
||||
* @param customer The customers name
|
||||
* @param car The customers car model
|
||||
*/
|
||||
Customer(String customer, String car) {
|
||||
this.customer = customer;
|
||||
this.car = car;
|
||||
}
|
||||
|
||||
/**
|
||||
* Increases the months since the last time the customer has visited
|
||||
*/
|
||||
void incMonthsSinceVisit() {
|
||||
monthsSinceVisit++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the months since the last time the customers has visited
|
||||
* @return The months since the last time the customer has visited
|
||||
*/
|
||||
long getMonthsSinceVisit() {
|
||||
return monthsSinceVisit;
|
||||
}
|
||||
|
||||
/**
|
||||
* The cost of the next visit
|
||||
* @return The cost of the next visit in double format
|
||||
*/
|
||||
double getNextVisitCost() {
|
||||
return (20.00 + (monthsSinceVisit*12.00));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an invoice containing the customers name, car model, last time the visited and the cost of the visit
|
||||
* @return A string containing the customers name, car model, last time the visited and the cost of the visit
|
||||
*/
|
||||
String createVisitInvoice() {
|
||||
double cost = getNextVisitCost();
|
||||
long lastVisit = getMonthsSinceVisit();
|
||||
monthsSinceVisit = 0;
|
||||
return (
|
||||
"INVOICE\tfor: " + customer + "\n" +
|
||||
"\t\tmodel: " + car + "\n" +
|
||||
"\t\tlast visit: " + lastVisit + "\n" +
|
||||
"\t\tnext visit cost: " + cf.format(cost));
|
||||
}
|
||||
}
|
79
Source Code/Assignment8/src/HarrisonFord.java
Normal file
79
Source Code/Assignment8/src/HarrisonFord.java
Normal file
@ -0,0 +1,79 @@
|
||||
/**
|
||||
A driver class demonstrating the classes available in
|
||||
for HarrisonFord customer management.
|
||||
|
||||
@author Scott Bateman
|
||||
*/
|
||||
|
||||
public class HarrisonFord{
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
//creating test customers John, Harold and Beth
|
||||
|
||||
//create one customer
|
||||
Customer john = new Customer("John Smith","Escape");
|
||||
|
||||
//create two warranty customers
|
||||
WarrantyCustomer harold = new WarrantyCustomer("Harold Lee", "Fiesta");
|
||||
WarrantyCustomer beth = new WarrantyCustomer("Beth Blart", "Focus");
|
||||
|
||||
//Displaying pretty text banner
|
||||
System.out.println();
|
||||
System.out.println("*********************************");
|
||||
System.out.println("* HARRISON FORD CUSTOMER SYSTEM *");
|
||||
System.out.println("*********************************");
|
||||
|
||||
//increment months since visit for each customer
|
||||
|
||||
//it's been 1 month since john bought his car
|
||||
john.incMonthsSinceVisit();
|
||||
|
||||
//it's been 3 months since harold bought his car
|
||||
harold.incMonthsSinceVisit();
|
||||
harold.incMonthsSinceVisit();
|
||||
harold.incMonthsSinceVisit();
|
||||
|
||||
//it's been 4 months since beth bought her car
|
||||
beth.incMonthsSinceVisit();
|
||||
beth.incMonthsSinceVisit();
|
||||
beth.incMonthsSinceVisit();
|
||||
beth.incMonthsSinceVisit();
|
||||
|
||||
//display report for Nov 1, 2019
|
||||
System.out.println("November 1, 2019\n----------------");
|
||||
System.out.println(john.createVisitInvoice());
|
||||
System.out.println();
|
||||
System.out.println(harold.createVisitInvoice());
|
||||
System.out.println();
|
||||
System.out.println(beth.createVisitInvoice());
|
||||
System.out.println();
|
||||
|
||||
//using a loop to simulate the passage of a year
|
||||
int i = 0;
|
||||
while (i < 12)
|
||||
{
|
||||
//john and beth to not visit in the year
|
||||
john.incMonthsSinceVisit();
|
||||
beth.incMonthsSinceVisit();
|
||||
|
||||
//harold really wants to keep his car in
|
||||
//good shape - he visits every month
|
||||
harold.incMonthsSinceVisit();
|
||||
|
||||
//creating a visit for monthly visits
|
||||
//for Harold, but not displaying them
|
||||
harold.createVisitInvoice();
|
||||
i++;
|
||||
}
|
||||
|
||||
//creating invoices for all customers
|
||||
System.out.println("November 1, 2020\n----------------");
|
||||
System.out.println(john.createVisitInvoice());
|
||||
System.out.println();
|
||||
System.out.println(harold.createVisitInvoice());
|
||||
System.out.println();
|
||||
System.out.println(beth.createVisitInvoice());
|
||||
System.out.println();
|
||||
}
|
||||
}
|
55
Source Code/Assignment8/src/WarrantyCustomer.java
Normal file
55
Source Code/Assignment8/src/WarrantyCustomer.java
Normal file
@ -0,0 +1,55 @@
|
||||
/**
|
||||
* This class contains a customer that has a warranty. It contains the customers name, car model and overridden methods pertaining to that the customer is a warranty owner
|
||||
* @author Isaac Shoebottom (3429069)
|
||||
*/
|
||||
|
||||
public class WarrantyCustomer extends Customer {
|
||||
/**
|
||||
* (long) The time since the last discount for being a warrenty owned was applied
|
||||
*/
|
||||
private long monthsSinceLastDiscount = 0;
|
||||
|
||||
/**
|
||||
* Warranty customer constructor, it stores the customers name and car model
|
||||
* @param customer The customers name
|
||||
* @param car The customers car model
|
||||
*/
|
||||
WarrantyCustomer(String customer, String car) {
|
||||
super(customer, car);
|
||||
}
|
||||
|
||||
/**
|
||||
* The overridden method that applies a discount if the user has not used their discount in 12 months
|
||||
* @return The cost of the visit
|
||||
*/
|
||||
@Override
|
||||
double getNextVisitCost() {
|
||||
if (monthsSinceLastDiscount >= 12) {
|
||||
monthsSinceLastDiscount = 0;
|
||||
return (0.8 * super.getNextVisitCost());
|
||||
}
|
||||
return super.getNextVisitCost();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method specific to the warranty owners, increases the months since last discount as well as months since last visit
|
||||
*/
|
||||
@Override
|
||||
void incMonthsSinceVisit() {
|
||||
super.incMonthsSinceVisit();
|
||||
monthsSinceLastDiscount++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an invoice for warranty owners, includes the months since the last time the discount was applies
|
||||
* @return The customers invoice, includes the last time the warranty discount was applied
|
||||
*/
|
||||
@Override
|
||||
String createVisitInvoice() {
|
||||
long tempMonthsSinceLastDiscount = monthsSinceLastDiscount;
|
||||
return(
|
||||
super.createVisitInvoice() +
|
||||
"\n\t\tmonths since discount: " + tempMonthsSinceLastDiscount + "\t(has warranty)"
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user