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.
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
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.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images