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
How do I make this: public class Country {     private String name;     private double area;     private...
How do I make this: public class Country {     private String name;     private double area;     private int population;     public Country(String name, double area, int population) {         this.name = name;         this.area = area;         this.population = population;     }     public double getPopulationDensity() {         return population / area;     }     public String getName() {         return name;     }     public void setName(String name) {         this.name = name;     }     public double getArea() {         return area;     }     public void setArea(double area) {         this.area = area;     }     public int getPopulation()...
Modify the Employee9C superclass so that is an abstract superclass with a constructor to set its...
Modify the Employee9C superclass so that is an abstract superclass with a constructor to set its variables (firstName and lastName). It should contain an abstract method called payPrint. Below is the source code for the Employee9C superclass: public class Employee9C {    //declaring instance variables private String firstName; private String lastName; //declaring & initializing static int variable to keep running total of the number of paychecks calculated static int counter = 0;    //constructor to set instance variables public Employee9C(String...
I am a beginner when it comes to java codeing. Is there anyway this code can...
I am a beginner when it comes to java codeing. Is there anyway this code can be simplified for someone who isn't as advanced in coding? public class Stock { //fields private String name; private String symbol; private double price; //3 args constructor public Stock(String name, String symbol, double price) { this.name = name; this.symbol = symbol; setPrice(price); } //all getters and setters /** * * @return stock name */ public String getName() { return name; } /** * set...
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...
public class Bicycle { // Instance variables (fields) private String ownerName; private int licenseNumber; // Constructor...
public class Bicycle { // Instance variables (fields) private String ownerName; private int licenseNumber; // Constructor public Bicycle( String name, int license ) { ownerName = name;    licenseNumber = license; } // Returns the name of the bicycle's owner public String getOwnerName( ) { return ownerName; } // Assigns the name of the bicycle's owner public void setOwnerName( String name ) { ownerName = name; } // Returns the license number of the bicycle public int getLicenseNumber( ) {...
Sort by the following (name, address, dependent and gender) of these and ask the user which...
Sort by the following (name, address, dependent and gender) of these and ask the user which field to sort by !. this mean the following java must sort by address if we need, by name , by dependent , and by gender it depend on the following java it must have an option which we need to sort. please i need your help now, you just add the sorting on the following java. // Use a custom comparator. import java.io.BufferedReader;...
Assignment 1 - ITSC 2214 I have to complete the array list for a shopping list...
Assignment 1 - ITSC 2214 I have to complete the array list for a shopping list code and can't figure out how to complete it: Below is the code Complete the three empty methods (remove(), find(), and contains()) in the ShoppingListArrayList.java file. These methods are already implemented in the ShoppingListArray class. /////////////////////////////////////////////////////////////////////////////////////////////////////////// Grocery Class (If this helps) package Shopping; public class Grocery implements Comparable<Grocery> { private String name; private String category; private int aisle; private float price; private int quantity;...
Using Java language.... Polymorphism of Interfaces : Take the Account class from the last chapter and...
Using Java language.... Polymorphism of Interfaces : Take the Account class from the last chapter and make a java program for your bank. However, there is another type of customer that may not have money in the bank and may not in fact have a back account with this bank at all, but may have a loan here. Make another class in the application you are making called CarLoan. Carloan's should have a name, amount owed, a rate, and a...
Problem Description: Problem Description: (The Account class) Design a class named Account that contains: A private...
Problem Description: Problem Description: (The Account class) Design a class named Account that contains: A private int data field named id for the account (default 0). A private double data field named balance for the account (default 0). A private double data field named annualInterestRate that stores the current interest rate (default 0). Assume all accounts have the same interest rate. A private Date data field named dateCreated that stores the date when the account was created. A no-arg constructor...
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...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT