Question: Customer class package timeShare;public class Customer {private int custId;private String name;private boolean premier;private static int nextNum = 100;public Customer(){custId = nextNum;nextNum++;}public Customer(String n){name = n;custId
Customer class
package timeShare;public class Customer {private int custId;private String name;private boolean premier;private static int nextNum = 100;public Customer(){custId = nextNum;nextNum++;}public Customer(String n){name = n;custId = nextNum;nextNum++;}public Customer( String n, boolean {custId = nextN;nextNum++;name = n;premier = p;}public String toString(){String ans = "is a";if(!premier)ans = " is not a";return name + " (custID: " + custId + ") " + ans + " premier member of the club";}public int getCustId() {return custId;}public void setCustId(int custId) {this.custId = custId;}public String getName() {return name;}public void setName(String name) {this.name = name;}public boolean isPremier() {return premier;}public void setPremier(boolean premier) {this.premier = premier;}}
TSReservation
package timeShare;import java.text.NumberFormat;public class TSReservation {private Customer cust;private TimeShare timeShare;private int numDays;private char discount; // N = none P = premier D = days B = bothprivate double rentAmt;public TSReservation () {}public TSReservation(Customer c, TimeShare t, int n) {cust = c;timeShare = t;numDays = n;setRentalCost();}public String toString(){NumberFormat nf = NumberFormat.getCurrencyInstance(); String string;string = cust.toString() + " rented " ; string = string + timeShare.toString() + " for " + numDays + " days.";string = string + " The cost was " + nf.format(rentAmt) + " ";switch (discount) {case 'B':string = string + "This person was a premier member and rented over six days and received a a 30% discount";break;case 'G':string = string + "This person was a premier member and received a a 10% discount";break;case 'D':string = string + "This person rented over six days and received a 20% discount";break;case 'N':string = string + "This person did not qualify for a discount";}return string;}public void setRentalCost() {if (numDays > 6) {if (cust.isPremier()) {rentAmt = (numDays * timeShare.getCostPerNight()) * .7;discount = 'B';}else {rentAmt = (numDays * timeShare.getCostPerNight()) * .8;discount = 'D';}}else {if (cust.isPremier()) {rentAmt = (numDays timeShare.getCostPerNight()) * .9;discount = 'G';}else {rentAmt = (numDays * timeShare.getCostPerNight());discount = 'N';}}} public Customer getCust() {return cust;}public void setCust(Customer cust) {this.cust = cust;}public TimeShare getTimeShare() {return timeShare;}public void setTimeShare(TimeShare timeShare) {this.timeShare = timeShare;}public int getNumDays() {return numDays;}public void setNumDays(int numDays) {this.numDays = numDays;}public char getDiscount() {return discount;}public void setDiscount(char discount) {this.discount = discount;package timeShare;
TimeShare class import java.text.NumberFormat; public class TimeShare { private String location;private int numBedrooms;private double costPerNight;public TimeShare() { } public TimeShare(String l, int n, double c) { location = l; numBedrooms = n; costPerNight = c; }public String toString() {NumberFormat nf = NumberFormat.getCurrencyInstance(); return "A " + numBedrooms + " bedroom glorious room located in " + location + " and rents for " + nf.format(costPerNight) + " per night"; } public String getLocation() { return location;}public void setLocation(String location) { this.location = location; } public int getNumBedrooms() { return numBedrooms; }public void setNumBedrooms(int numBedrooms) {this.numBedrooms = numBedrooms;}public double getCostPerNight() {return costPerNight }public void setCostPerNight(double costPerNight) { this.costPerNight = costPerNight;}}
Now its his Driver timeShareDriver
package timeShare;import java.util.*;import java.text.*;public class TimeShareDriver {public static void main(String[] args) Scanner scan = new Scanner(System.in); ArrayList ts = new ArrayList<>() ArrayList clients = new ArrayList<>() ArrayList rentals = new ArrayList<>();loadNewData(ts, clients);boolean moreRentals = true;int counter = 0;while (moreRentals){ showCustomers(clients);int custSelect = pickCust(clients);System.out.println();int tsSelect = pickTimeShares(ts);System.out.println("How many days do you wish to have this beautiful vacation spot?"); int numDays = scan.nextInt(); rentals.add(new TSReservation(clients.get(custSelect-1), ts.get(tsSelect-1), numDays)); System.out.println(rentals.get(counter).toString());counter++;ts.remove(tsSelect-1);System.out.println();System.out.println("more rentals? (true/false)");moreRentals = scan.nextBoolean();}printRentals(rentals); }publicstaticvoidloadNewData(ArrayLista,ArrayListc{a.add(newTimeShare("Phoenix1",2,120.00));a.add(newTimeShare("SanDie11, 135.00));a.add(new TimeShare("Phoenix-2", 1, 110.00));a.add(new TimeShare("Virginia Beach-1", 3, 145.00));c.add(new Customer( "Jose Altuve",false));c.add(new Customer( "Bruce Springsteen",true));c.add(new Customer( "Diana Taurasi", true));c.add(new Customer( "Queen Elizabeth", true)); c.add(new Customer( "Mike Moustakas", true));}public static void printRentals(ArrayList rents{ System.out.println("RentalSummary");for (int i=0; i System.out.println(rents.get(i));} public static int pickTimeShares(ArrayList ts) {Scanner scan = new Scanner(System.in); System.out.println("The following time share locations are available to rent:");for (int i = 0; i < ts.size(); i++) {System.out.println((i+1) + " " + ts.get(i).toString());}System.out.println("Which time share would you like to rent:");int tsSelect = scan.nextInt();return tsSelect;}public static void showCustomers(ArrayList custs) { System.out.println("Customers:");for (int i = 0; i < custs.size(); i++) { System.out.println((i+1) + " " + custs.get(i).toString());}System.out.println();}public static int pickCust(ArrayList custs) {Scanner scan = new Scanner(System.in);System.out.println("Please select a customer:");int which = scan.nextInt(); if (custs.get(which-1).isPremier()) { System.out.println("This customer is a premium member, so treat them well"); } return which; }}
the JUnit testing framework to create unit test cases, find bugs and fix the TimeShare code. The example code comes with some seeded faults. For this exercise you are required to create a test plan, implement the test plan as unit test cases for the three methods pickTimeShare, showCustomers, and pickCust with JUnit, execute those against the code, detect faults, and fix as many issues as possible
Your submission should include: 1) Test Descriptions Document. This is a document that you need to write before you start fixing the application. Based on your exploration of the system and its functionality, you will formulate a plan for how you will write unit tests for the three methods to ensure that they deliver system functionality, free of faults. What data will you provide in the assertions for success? For failure? This document needs to describe the unit tests that you have created, including a description of what each test is intended to do and how it serves a purpose in verifying system functionality. Your tests must cover the major system functionality, including both normal usage and erroneous input. You must explain why your tests will cover all major functionality, and not leave gaps in test coverage. 2) Unit tests implemented in the JUnit framework to match your document above. 3) List of faults found, along with a recommended fix for each and a list of test cases that expose the fault.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
