Write an abstract super class encapsulating a vacation: A vacation has one attribute: a destination. It has an overloaded constructor a toString() and an abstract calculate cost method that returns the total cost of each vacation. This class has two non-abstract subclasses: one encapsulating an all-inclusive vacation, and the other encapsulating a vacation bought piece-meal. An all-inclusive vacation has three additional attributes: a brand (for instance ClubMed); a rating, expressed as a number of stars; and a price. In addition an all-inclusive vacation has an overloaded constructor, a toString() and a concrete calculate cost method that returns the total cost of the all-inclusive vacation vacation ( price). A piecemeal vacation has three additional attributes: hotel, meal, airfare as corresponding costs. In addition an all-inclusive vacation has an overloaded constructor, a toString() and a concrete calculate cost method that returns the total cost of the all-inclusive vacation ( sum of hotel, meal and airfare). You also need to include a client class to test these two classes using either an ArrayList or an array of objects to populate the array. Print the state of each element and the total costs for each vacation element.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 3PE
icon
Related questions
Question

Write an abstract super class encapsulating a vacation: A vacation has one attribute: a destination. It has an overloaded constructor a toString() and an abstract calculate cost method that returns the total cost of each vacation. This class has two non-abstract subclasses: one encapsulating an all-inclusive vacation, and the other encapsulating a vacation bought piece-meal.

An all-inclusive vacation has three additional attributes: a brand (for instance ClubMed); a rating, expressed as a number of stars; and a price. In addition an all-inclusive vacation has an overloaded constructor, a toString() and a concrete calculate cost method that returns the total cost of the all-inclusive vacation vacation ( price).

A piecemeal vacation has three additional attributes: hotel, meal, airfare as corresponding costs. In addition an all-inclusive vacation has an overloaded constructor, a toString() and a concrete calculate cost method that returns the total cost of the all-inclusive vacation ( sum of hotel, meal and airfare).

You also need to include a client class to test these two classes using either an ArrayList or an array of objects to populate the array. Print the state of each element and the total costs for each vacation element.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT