Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an abstract superclass encapsulating or for a Vacation: A vacation has two

ID: 3729030 • Letter: W

Question

Write an abstract superclass encapsulating or for a Vacation: A vacation has two attributes, budget and destination. It has an abstract method returning how much the vacation is over budget. Create two non-abstract classes that extend vacation: one for an all-inclusive vacation, and another for a piecemeal vacation. All inclusive will have three attributes: brand, rating (represented by number of stars), and a price. Piecemeal needs to have a list of items (hotel, meals, airfaire, etc.) and their corresponding costs. This can be handled using parallel arrays, thus there will only be two attributes. Be sure to write appropriate getters, setters, and constructors for all 3 classes. Don't forget the abstract method. HINT: It is ok to have a constructor for an abstract class. It can be called to set up attribute values from the child class.  
Write a test application for these classes. You can create this as an application for a user to determine which vacation option is right for them. Create a piecemeal and all inclusive vacation object. Be sure to appropriately ask for and load the field values. Display all information for each object and display whether the vacation is over budget (showing by how much), under budget (showing how much), or right at budget.

Explanation / Answer

public class Lab4

{
private int budget;
private String destination;
}

class PiecemealVacation extends Vacation
{
}

abstract class Vacation
{
private int budget;
private String destination;

abstract double amountOverBudget();
}


class PiecemealVacation extends Vacation
{
private ArrayList<string> items;
private ArrayList<double> costs;

public double amountOverBudget() {
double sumCost = 0.0;
for( Iterator i = arrayList.iterator(); i.hasNext(); )
{
sumCost += i.next();
}
return sumCost - budget
}
}

class InclusiveVacation extends Vacation
{
private string brand;
private uint rating;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote