Write an abstract super class encapsulating a vacation: A vacation has one attribute: adestination. It has anoverloaded constructoratoString()and anabstract calculate costmethod that returns the total cost of each vacation. This class has two non-abstract subclasses: one encapsulating anall-inclusive vacation, and the other encapsulating avacation bought piece-meal.
Anall-inclusive vacationhas three additional attributes: abrand(for instance ClubMed); arating, expressed as a number of stars; and aprice. In addition anall-inclusive vacationhas an overloaded constructor, a toString() and aconcrete calculate costmethod that returns the total cost of theall-inclusive vacationvacation ( price).
Apiecemeal vacationhas three additional attributes:hotel, meal, airfareas corresponding costs. In addition anall-inclusive vacationhas an overloaded constructor, a toString() and aconcrete calculate costmethod that returns the total cost of theall-inclusivevacation ( sum of hotel, meal and airfare).
You also need to include aclient classto test these two classes using either anArrayListor anarray of objectsto populate the array. Print the state of each element and the total costs for each vacation element.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here