Question

In: Computer Science

Rental Shop A. Create an abstract class named SummerSportRental that is to be used with for...

Rental Shop
A. Create an abstract class named SummerSportRental that is to be used with for a summer sports rental
shop. The SummerSportRental class must have the properties of newModel which takes on the type
boolean, and rentalCost which takes on the type double, and rentalNumber which is an identification
number as an long integer.These member variables must all be private!
It also must include the following member functions:
1. equals() which returns true if two SummerSportRental objects have the same rentalNumber.
2. all of the appropriate get/set methods for each of the above member variables. Make sure to have
data validation done on the set methods to prevent invalid/illegal values from being passed into the
member variables. (Example: rentalCost should not be allowed to be negative).
3. include an abstract method named lateCharge, that will only be implemented in child classes that
inherit the SummerSportRental class.
B. Create three children classes that inherit the SummerSportRental class, named WaterSkiRental,
PaddleboardRental, and BeachCruiserBikeRental.
The WaterSkiRental class should have one private member variable named size as an integer that will be
used to store the size of the water ski in centimeters. Implement the get/set method for this member
variable. The abstract method in the SummerSportRental class, named lateCharge must be implemented to
charge a late charge of 10% of the rental cost. Be sure to include a method named toString to output the
data stored in the member variables for this class. No main method in the class allowed!
The PaddleboardRental class should have two private member variable named size as an integer that will
be used to store the size of the paddle board in centimeters, and another member variable named style as
an enumerated type with the values (SINGLE, DOUBLE to denote if the paddle board is a single person
board or a two person board). Implement the get/set methods for these member variables. The abstract
method in the SummerSportRental class, named lateCharge must be implemented to charge a late charge
of 20% of the rental cost. Be sure to include a method named toString to output the data stored in the
member variables for this class. No main method in the class allowed!
The BeachCruiserBikeRental class should have two private member variable named wheel_szie as an
integer that will be used for storing the wheel size in centimeters of the beach cruiser bike, and another
member variable named capacity as an enumerated type with the values (SINGLE, DOUBLE, TRIPLE
[which has a very stylin' side cart to it]) that stores the seating capacity of the beach cruiser bike. Implement
the get/set methods for these member variables. The abstract method in the SnowSportRental class, named
lateCharge must be implemented to charge a late charge of (20+capacity*5)% (late charge for single=25%,
double=30%, triple=35%) of the rental cost. Be sure to include a method named toString to output the data
stored in the member variables for this class. No main method in the class allowed!
C. Create separate test class source files with their respective main methods to test each implemented
method in the WaterSkiRental, PaddleboardRental, and BeachCruiserBikeRental classes. The list below is
the minimums for the test cases for each of the child classes:
WaterSkiRental:
1. equals() method
2. newModel ( test get and set )
3. rentalCost ( test get and set )
4. rentalNumber ( test get and set )
5. size ( test get and set )
6. lateCharge - make sure it adheres to the specifications above.
7. toString ( test toString method )
A total of 11 tests for WaterSkiRental class ( tests 1-4 are actually for the SummerSportRental class, and will
not need to be repeated for PaddleboardRental and BeachCruiserBikeRental class test )
PaddleboardRental:
1. size ( test get and set )
2. style ( test get and set )
3. lateCharge - make sure it adheres to the specifications above.
4. toString ( test toString method )
A total of four tests for PaddleboardRental class
BeachCruiserBikeRental:
1. wheel_size ( test get and set )
2. capacity ( test get and set )
3. lateCharge - make sure it adheres to the specifications above.
4. toString ( test toString method )
A total of four tests for BeachCruiserBikeRental class
You are to submit:
Zipfile of your Final Project with the following name format: LastName_FirstName_Final.zip
Programmer Documentation File
Note: make sure to thoroughly read through all of the requirements for this project. Specifications will be
very strictly enforced.

How do I do this in JAVA?

Solutions

Expert Solution

SummerSportRental.java :

package Summer;

public abstract class SummerSportRental {
   protected enum Types {SINGLE,DOUBLE,TRIPLE};
   private boolean newModal;
   private double rentalCost;
   private long rentalNumber;
  
   public SummerSportRental(){
       newModal = false;
       rentalCost = 0.0;
       rentalNumber = 0;
   }
   public boolean equals(SummerSportRental obj){
       if(this.rentalNumber == obj.rentalNumber){
           return true;
       }
       else{
           return false;
       }
   }
   public boolean getNewModal(){
       return newModal;
   }
   public void setNewModal(boolean model){
       this.newModal = model;
   }
   public double getRentalCost(){
       return rentalCost;
   }
   public void setRentalCost(double cost){
       if(cost>0){
           rentalCost = cost;
       }
       else{
           System.out.println("Invalid cost");
       }
   }
   public long getRentalNumber(){
       return rentalNumber;
   }
   public void setRentalNumber(long number){
       if(number>0){
           rentalNumber = number;
       }
       else{
           System.out.println("Invalid cost");
       }
   }
   public abstract double lateCharge();
}

WaterSkiRental.java:

package Summer;

public class WaterSkiRental extends SummerSportRental {
   private int size;
   public WaterSkiRental(){
       super();
       size = 0;
   }
   public int getSize(){
       return size;
   }
   public void setSize(int s){
       if(s>0){
           size = s;
       }
       else{
           System.out.println("Invalid size");
       }
   }
   public double lateCharge() {
       double charge = this.getRentalCost()*0.1;
       return charge;
   }
   public String toString(){
       String str = "The size of the water ski is :" + size + " centimeters";
       return str;
   }
}

PaddleboardRental.java :

package Summer;

public class PaddleboardRental extends SummerSportRental {
   private int size;
   private Types style;
   public PaddleboardRental(){
       super();
       size = 0;
       style = Types.SINGLE;
   }
   public int getSize(){
       return size;
   }
   public void setSize(int s){
       if(s>0){
           size = s;
       }
       else{
           System.out.println("Invalid size");
       }
   }
   public Types getStyle(){
       return style;
   }
   public void setStyle(Types t){
       if(t==Types.TRIPLE){
           System.out.println("No three person paddlebord available");
       }
       else{
       style = t;
       }
   }
   public double lateCharge() {
       double charge = this.getRentalCost()*0.2;
       return charge;
   }
   public String toString(){
       String s = "";
       switch (style) {
       case SINGLE:
           s = "single";
           break;
       case DOUBLE:
           s = "two";
           break;
       default:
           break;
       }
       String str = "The size of the paddle board is : " + size + " centimeters. \n" +
                       "The paddle board is a " + s + " person board";
       return str;
   }
}

BeachCruiserBikeRental.java :

package Summer;

public class BeachCruiserBikeRental extends SummerSportRental {
   private int wheel_size;
   private Types capacity;
   public BeachCruiserBikeRental(){
       super();
       wheel_size = 0;
       capacity = Types.SINGLE;
   }
   public int getWheelSize(){
       return wheel_size;
   }
   public void setWheelSize(int size){
       if(size>0){
           wheel_size = size;
       }
       else{
           System.out.println("Invalid wheel size");
       }
   }
   public Types getCapacity(){
       return capacity;
   }
   public void setCapacity(Types t){
       capacity = t;
   }
   public double lateCharge() {
       double charge = 0.0;
       if(capacity==Types.SINGLE){
           charge = this.getRentalCost()*0.25;
       }
       else if(capacity==Types.DOUBLE){
           charge = this.getRentalCost()*0.3;
       }
       else {
           charge = this.getRentalCost()*0.35;
       }
       return charge;
   }
   public String toString(){
       int cap = 0;
       switch (capacity) {
       case SINGLE:
           cap = 1;
           break;
       case DOUBLE:
           cap = 2;
           break;
       case TRIPLE:
           cap = 3;
           break;
       default:
           break;
       }
       String str = "the wheel size is : " + wheel_size + " centimeters of the beach cruiser bike. \n" +
               "the seating capacity of the beach cruiser bike is : " + cap;
       return str;
   }
}

test.java:

package Summer;

import Summer.SummerSportRental.Types;

public class test {
   public static void main(String[] args){
       WaterSkiRental ws1 = new WaterSkiRental();
       ws1.setNewModal(true);
       ws1.setRentalCost(15);
       ws1.setRentalNumber(2456);
       ws1.setSize(50);
       WaterSkiRental ws2 = new WaterSkiRental();
       ws2.setNewModal(false);
       ws2.setRentalCost(8);
       ws2.setRentalNumber(2156);
       ws2.setSize(45);
       System.out.println(ws1.equals(ws2));
       System.out.println(ws1.getNewModal());
       System.out.println(ws1.getRentalCost());
       System.out.println(ws1.getRentalNumber());
       System.out.println(ws1.getSize());
       System.out.println(ws1.lateCharge());
       System.out.println(ws1.toString());
      
       PaddleboardRental pb1 = new PaddleboardRental();
       pb1.setSize(130);
       pb1.setStyle(Types.DOUBLE);
       pb1.setRentalCost(27);
       System.out.println(pb1.getSize());
       System.out.println(pb1.getStyle());
       System.out.println(pb1.lateCharge());
       System.out.println(pb1.toString());
      
       BeachCruiserBikeRental bcb1 = new BeachCruiserBikeRental();
       bcb1.setWheelSize(130);
       bcb1.setCapacity(Types.TRIPLE);
       bcb1.setRentalCost(41);
       System.out.println(bcb1.getWheelSize());
       System.out.println(bcb1.getCapacity());
       System.out.println(bcb1.lateCharge());
       System.out.println(bcb1.toString());
   }
}


Related Solutions

Create a file named StudentArrayList.java,within the file create a class named StudentArrayList. This class is meant...
Create a file named StudentArrayList.java,within the file create a class named StudentArrayList. This class is meant to mimic the ArrayList data structure. It will hold an ordered list of items. This list should have a variable size, meaning an arbitrary number of items may be added to the list. Most importantly this class should implement the interface SimpleArrayList provided. Feel free to add as many other functions and methods as needed to your class to accomplish this task. In other...
In Java, create an abstract vehicle class. Create a Truck Class that Inherits from Vehicle Class....
In Java, create an abstract vehicle class. Create a Truck Class that Inherits from Vehicle Class. The vehicle class should contain at least 2 variables that could pertain to ANY vehicle and two methods. The truck class should contain 2 variables that only apply to trucks and one method. Create a console program that will instantiate a truck with provided member information then call one method from the truck and one method contained from the inherited vehicle class. Have these...
Create a custom Exception named IllegalTriangleSideException. Create a class named Triangle. The Triangle class should contain...
Create a custom Exception named IllegalTriangleSideException. Create a class named Triangle. The Triangle class should contain 3 double variables containing the length of each of the triangles three sides. Create a constructor with three parameters to initialize the three sides of the triangle. Add an additional method named checkSides with method header - *boolean checkSides() throws IllegalTriangleSideException *. Write code so that checkSides makes sure that the three sides of the triangle meet the proper criteria for a triangle. It...
Create a custom Exception named IllegalTriangleSideException. Create a class named Triangle. The Triangle class should contain...
Create a custom Exception named IllegalTriangleSideException. Create a class named Triangle. The Triangle class should contain 3 double variables containing the length of each of the triangles three sides. Create a constructor with three parameters to initialize the three sides of the triangle. Add an additional method named checkSides with method header - *boolean checkSides() throws IllegalTriangleSideException *. Write code so that checkSides makes sure that the three sides of the triangle meet the proper criteria for a triangle. It...
In java: -Create a class named Animal
In java: -Create a class named Animal
Create an abstract class DiscountPolicy. It should have a single abstract method computeDiscount that will return...
Create an abstract class DiscountPolicy. It should have a single abstract method computeDiscount that will return the discount for the purchase of a given number of a single item. The method has two parameters, count and itemCost. Derive a class BulkDiscount from DiscountPolicy. It should have a constructor that has two parameters minimum and percent. It should define the method computeDiscount so that if the quantity purchased of an item is more then minimum, the discount is percent percent.
Create a class named Employee and its child class named Salesperson. Save each class in its...
Create a class named Employee and its child class named Salesperson. Save each class in its own file. Name your class and source code file containing the main method homework.java. Make sure each class follows these specifications: 1. An employee has a name (String), employee id number (integer), hourly pay rate (double), a timesheet which holds the hours worked for the current week (double array) and email address (String). A salesperson also has a commission rate, which is a percentage...
Create a class named UsedFurnitureItem to represent a used furniture item that the store sells. Private...
Create a class named UsedFurnitureItem to represent a used furniture item that the store sells. Private data members of a UsedFurnitureItem are: age (double) // age in years – default value for brandNewPrice (double) // the original price of the item when it was brand new description (string) // a string description of the item condition (char) // condition of the item could be A, B, or C. size (double) // the size of the item in cubic inches. weight...
I need to develop an abstract class/ class that will be called RandString will be used...
I need to develop an abstract class/ class that will be called RandString will be used as a base class for two derived classes: RandStr will generate a random string with 256 characters long and a RandMsgOfTheDay will return a random message the day. (use a table of message in memory - or in a file). C++, the coding langauge used.
In a package named "oop" create a Scala class named "Score" with the following: • A...
In a package named "oop" create a Scala class named "Score" with the following: • A constructor that takes an Int and stores it in a member variable named score • A method named scoreGoal that takes no parameters and has return type Unit that increments the score by 1 • A method named isWinner that takes a Score object as a parameter and returns a Boolean. The method returns true if this instances score is strictly greater than the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT