Question

Class VacationPackage java.lang.Object triptypes.VacationPackage Constructor Summary Constructors Constructor and Description VacationPackage(java.lang.String name, int numDays) Initializes a...

    • Class VacationPackage

    • java.lang.Object
      • triptypes.VacationPackage
    • Constructor Summary

      Constructors
      Constructor and Description
      VacationPackage(java.lang.String name, int numDays)

      Initializes a VacationPackage with provided values.

    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods
      Modifier and Type Method and Description
      boolean equals(java.lang.Object other)

      Provides a logical equality comparison for VacationPackages and any other object type.

      double getAmountDue()

      This method provides the remaining amount due to the travel agent for this trip less any deposit made upfront.

      abstract double getDepositAmount()

      This method provides the required upfront deposit amount for a given vacation.

      abstract double getLodgingCost()

      This method provides the subtotal for a trip related to lodging expenses (ie, not including flights, meals, and incidentals).

      java.lang.String getName()

      Retrieves the promotional name of this package.

      int getNumDays()

      Retrieves the number of days included in this package.

      abstract double getPrice()

      This method provides the full price of a vacation package, which is must be computed based on the specific kind of trip being booked.

      void setLength(int numDays)

      Updates the length of this VacationPackage.

      void setName(java.lang.String name)

      Updates the VacationPackage's externally facing promotional name.

      java.lang.String toString()

      This method produces a String summary of a VacationPackage.

      • Methods inherited from class java.lang.Object

        getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • VacationPackage

        public VacationPackage(java.lang.String name,
                               int numDays)

        Initializes a VacationPackage with provided values.

        Parameters:

        name - The promotional marketing name for this package.

        numDays - The number of days included in this VacationPackage trip.

    • Method Detail

      • setName

        public void setName(java.lang.String name)

        Updates the VacationPackage's externally facing promotional name. Due to travel agency policy, this name is never allowed to be empty as it would be confusing for agents and customers interacting with the system. Names that do not comply with this policy will be ignored and the package will be given the name "PACKAGE NAME TBD" as a placeholder.

        Parameters:

        name - The updated name to use for this package.

      • setLength

        public void setLength(int numDays)

        Updates the length of this VacationPackage. All packages must have a minimum of one day.

        Parameters:

        numDays - The new number of days for this package.

      • getName

        public java.lang.String getName()

        Retrieves the promotional name of this package.

        Returns:

        The name.

      • getNumDays

        public int getNumDays()

        Retrieves the number of days included in this package.

        Returns:

        The number of days for this trip.

      • getPrice

        public abstract double getPrice()

        This method provides the full price of a vacation package, which is must be computed based on the specific kind of trip being booked.

        Returns:

        The price of a vacation package in US Dollars.

      • getDepositAmount

        public abstract double getDepositAmount()

        This method provides the required upfront deposit amount for a given vacation. This must be computed based on rules determined by specific package types, per travel agency policies.

        Returns:

        The deposit amount required in US Dollars.

      • getAmountDue

        public double getAmountDue()

        This method provides the remaining amount due to the travel agent for this trip less any deposit made upfront.

        Returns:

        The remaining balance to pay the travel agency.

      • getLodgingCost

        public abstract double getLodgingCost()

        This method provides the subtotal for a trip related to lodging expenses (ie, not including flights, meals, and incidentals). Lodging rates are determined by specific package types.

        Returns:

        The lodging subtotal in US Dollars.

      • toString

        public java.lang.String toString()
        This method produces a String summary of a VacationPackage. Strings will be prefixed with the $ symbol, followed by trip total price rounded to two decimal places in a 8 character wide field. Price details should be followed by two spaces and the promotional name of this trip. For example:
        $ 1234.56  Spring Break at the Beach
        $  150.99  Rustic Backpacking at Mt. Rushmore

        Overrides:

        toString in class java.lang.Object

        Returns:

        The formatted string summary.

      • equals

        public boolean equals(java.lang.Object other)

        Provides a logical equality comparison for VacationPackages and any other object type.

        Overrides:

        equals in class java.lang.Object

        Parameters:

        other - A reference to another object to be compared with this one.

        Returns:

        true if and only if this VacationPackage shares the same promotional name as one referred to by other. false when other is not a valid VacationPackage object or the names do not match

Homework Answers

Answer #1

class VacationPackage

{

private String pName;

private int nDays;

public VacationPackage(String name, int numDays)

{

this.pName = name;

this.nDays = numDays;

}

public void setName(String name)

{

this.pName = name;

}

  public void setLength(int NumDays)

{

this.nDays = NumDays;

}

public String getName()

{

return this.pName;

}

public int getNumDays()

{

return this.nDays;

}

public abstract Double getPrice();

  public abstract double getDepositAmount();

  public double getAmountDue()

{

return this.getPrice()-this.getDepositAmount();

}

  public abstract double getLodgingCost();

public String toString()

{

String p = String.format("%7.2f",this.getPrice());

return "$"+p+" "+this.getName();

}

public boolean equals(Object other)

{

if(other instanceof VacationPackage)

if(this.getName()==other.getName())

return true;

return false;

}

}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
JAVA public class Purchase { private String name; private int groupCount; //Part of price, like the...
JAVA public class Purchase { private String name; private int groupCount; //Part of price, like the 2 in 2 for $1.99. private double groupPrice; //Part of price, like the $1.99 in 2 for $1.99. private int numberBought; //Total number being purchased. public Purchase () { name = "no name"; groupCount = 0; groupPrice = 0; numberBought = 0; } public Purchase (String name, int groupCount, double groupPrice, int numberBought) { this.name = name; this.groupCount = groupCount; this.groupPrice = groupPrice; this.numberBought...
Objectives:The focus of this assignment is to create and use a recursive method given a moderately...
Objectives:The focus of this assignment is to create and use a recursive method given a moderately difficult problem. Program Description: This project will alter the EmployeeManager to add a search feature, allowing the user to find an Employee by a substring of their name. This will be done by implementing the Rabin-Karp algorithm. A total of seven classes are required. Employee (From previous assignment) HourlyEmployee (From previous assignment) SalaryEmployee (From previous assignment) CommissionEmployee (From previous assignment) EmployeeManager (Altered from previous...
Java: ModifyStudentList.javato use anArrayListinstead of an array In StudentList.java, create two new public methods: The addStudent...
Java: ModifyStudentList.javato use anArrayListinstead of an array In StudentList.java, create two new public methods: The addStudent method should have one parameter of type Student and should add the given Student to the StudentList. The removeStudent method should have one parameter of type String. The String is the email of the student to be removed from the StudentList. In Assign5Test.java do the following: Create a new StudentList containing 3 students. Print the info of all the Students in the StudentList using...
1- Use inheritance to implement the following classes: A: A Car that is a Vehicle and...
1- Use inheritance to implement the following classes: A: A Car that is a Vehicle and has a name, a max_speed value and an instance variable called the number_of_cylinders in its engine. Add public methods to set and get the values of these variables. When a car is printed (using the toString method), its name, max_speed and number_of_cylinders are shown. B: An Airplane that is also a vehicle and has a name, a max_speed value and an instance variable called...
In Chapter 9, you created a Contestant class for the Greenville Idol competition. The class includes...
In Chapter 9, you created a Contestant class for the Greenville Idol competition. The class includes a contestant’s name, talent code, and talent description. The competition has become so popular that separate contests with differing entry fees have been established for children, teenagers, and adults. Modify the Contestant class to contain a field that holds the entry fee for each category, and add get and set accessors. Extend the Contestant class to create three subclasses: ChildContestant, TeenContestant, and AdultContestant. Child...
this is the book name. Data Structures and Abstractions with Java 1) Description: The sample programs...
this is the book name. Data Structures and Abstractions with Java 1) Description: The sample programs in Chapter 1 of your textbook are not complete. They are used for illustration purpose only. The implementation of Listing 1-1 on page 39 is explained in Chapter 2. And, in order to see the result of using it, we will need the following set of files: i. BagInteface.java – the specification only. ii. ArrayBag.java – the implementation of BagInerface.java. iii. ArrayBagDemo.java – a...
1. Consider the following interface: interface Duty { public String getDuty(); } a. Write a class...
1. Consider the following interface: interface Duty { public String getDuty(); } a. Write a class called Student which implements Duty. Class Student adds 1 data field, id, and 2 methods, getId and setId, along with a 1-argument constructor. The duty of a Student is to study 40 hours a week. b. Write a class called Professor which implements Duty. Class Professor adds 1 data field, name, and 2 methods, getName and setName, along with a 1-argument constructor. The duty...
Homework Draw class diagrams for your HW4 - the Tetris Game shown below: Part 1: UML...
Homework Draw class diagrams for your HW4 - the Tetris Game shown below: Part 1: UML As a review, Here are some links to some explanations of UML diagrams if you need them. • https://courses.cs.washington.edu/courses/cse403/11sp/lectures/lecture08-uml1.pdf (Links to an external site.) • http://creately.com/blog/diagrams/class-diagram-relationships/ (Links to an external site.) • http://www.cs.bsu.edu/homepages/pvg/misc/uml/ (Links to an external site.) However you ended up creating the UML from HW4, your class diagram probably had some or all of these features: • Class variables: names, types, and...
Complete a Java program named ARMgr that maintains customer accounts receivable in a database. The code...
Complete a Java program named ARMgr that maintains customer accounts receivable in a database. The code to initialize the CustomerAccountsDB database table and add a set of customer accounts is provided. Finish the code in these 3 methods in CustomerAccountDB.java to update or query the database: -purchase(double amountOfPurchase) -payment(double amountOfPayment) -getCustomerName() Hint: For getCustomerName(), look at the getAccountBalance() method to see an example of querying data from the database. For the purchase() and payment() methods, look at the addCustomerAccount() method...