For the Trip class:
For the CarTrip class:
For the PlaneTrip class:
For the Taxable class:
For the TripTest class:
You ready to make your car trip from Al Ain University – Abu Dhabi to Al Ain University – Al Ain City. The tax amount to be paid for the car trip is: 13.0$
You ready to make your plane trip from UAE to Jordan.
The tax amount to be paid for the plane trip is : $23.9
Taxable.java
public class Taxable {
double carTax = 3.25;
double checkedLaguageTax = 9.77;
double carryLaguageTax = 4.36;
public double getTaxAmount(Object x) {
if(x instanceof CarTrip) {
return
this.carTax;
}
else if (x instanceof PlaneTrip)
{
return
((PlaneTrip)
x).numCheckedLuggage*(this.checkedLaguageTax)+(this.carryLaguageTax)*(((PlaneTrip)
x).numCarryOn);
}
return 0.0;
}
}
Trip.java
public abstract class Trip extends Taxable{
abstract boolean checklist();
int startTime,endTime;
String departureLocation;
String destinationLocation;
//Trip
public String getDepartureLocation() {
return departureLocation;
}
public String getDestinationLocation() {
return destinationLocation;
}
}
CarTrip.java
public class CarTrip extends Trip{
boolean isFull;
boolean brakesChecked;
int numPassenger;
public CarTrip(int startTime ,int endTime,String
departureLocation ,String destinationLocation,boolean isFull
,boolean brakesChecked ,int numPassenger) {
super.startTime = startTime;
super.endTime = endTime;
super.departureLocation =
departureLocation;
super.destinationLocation =
destinationLocation;
this.isFull = isFull;
this.brakesChecked =
brakesChecked;
this.numPassenger =
numPassenger;
}
@Override
boolean checklist() {
if (brakesChecked &&
isFull&& numPassenger<=4) {
return
true;
}
return false;
}
@Override
public double getTaxAmount(Object x) {
return super.getTaxAmount(x);
}
}
PlaneTrip.java
public class PlaneTrip extends Trip{
boolean ticketIssued;
boolean passportValid;
int numCheckedLuggage;
int numCarryOn;
public PlaneTrip(int startTime ,int endTime,String
departureLocation ,String destinationLocation,boolean
passportValid,boolean ticketIssued,int numCheckedLuggage,int
numCarryOn) {
super.startTime = startTime;
super.endTime = endTime;
super.departureLocation =
departureLocation;
super.destinationLocation =
destinationLocation;
this.passportValid =
passportValid;
this.ticketIssued =
ticketIssued;
this.numCarryOn = numCarryOn;
this.numCheckedLuggage =
numCheckedLuggage;
}
@Override
boolean checklist() {
if (passportValid &&
ticketIssued && numCheckedLuggage<=2 &&
numCarryOn<=1) {
return
true;
}
return false;
}
@Override
public double getTaxAmount(Object x) {
return super.getTaxAmount(x);
}
}
Test.java
public class Test {
public static void main(String[] args) {
CarTrip c1 = new CarTrip(2, 5, "AI
Ain University - Abu Dhabi","AI Ain University - AI in city" ,
true, true, 4);
if (c1.checklist() == true) {
System.out.println("You are ready to Make you car trip
from"+c1.getDepartureLocation()+"\n"+"The tax amount to be paid for
the car trip is : $"+c1.getTaxAmount(c1));
}
System.out.println();
PlaneTrip p1 = new PlaneTrip(3, 4,
"UAE","JORDAN",true,true, 2, 1);
if (p1.checklist() == true) {
System.out.println("You are ready to Make you plane trip
from"+p1.getDepartureLocation()+"\n"+"The tax amount to be paid for
the car trip is : $"+p1.getTaxAmount(p1));
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
EXPLANATION
Taxable CLASS
public class Taxable {//creating Taxable class
double carTax = 3.25;//creating a double variable
called carTax
double checkedLaguageTax = 9.77;//creating a double
variable checkedLaguageTax
double carryLaguageTax = 4.36;//creating a double
variable carryLaguageTax
public double getTaxAmount(Object x) {//creating a
method called getTaxAmount which takes object
if(x instanceof CarTrip) {//if
object is an carTrip
return
this.carTax; //return carTax which is default
}
else if (x instanceof PlaneTrip)
{//if object is PlaneTrip
//return num of
laguage*checkedlaguageTaxa + carryLauguageTax *num carry on
return
((PlaneTrip)
x).numCheckedLuggage*(this.checkedLaguageTax)+(this.carryLaguageTax)*(((PlaneTrip)
x).numCarryOn);
}
return 0.0;//if the object is not
of carTrip or PLaneTrip return 0
}
}
Trip CLASS
public abstract class Trip extends Taxable{//creating Trip class
which extends Taxable class
abstract boolean checklist();//creating an abstract
boolean checkList which is abstract and needs to be overrided in
every class
int startTime,endTime;//creating start and endtime of
type int
String departureLocation;//creating a string value
which stores depature location
String destinationLocation;//creating a string value
which stores destination location
public String getDepartureLocation() {
return departureLocation;//returns
the location
}
public String getDestinationLocation() {
return
destinationLocation;//returns destination location
}
}
CarTrip CLASS
public class CarTrip extends Trip{//create carTrip and extend Trip
class
boolean isFull;//boolean value to store whether isFull
its true or not
boolean brakesChecked;//boolean value to store whether
breaksChecked its true or not
int numPassenger;//numPassenger to store the number of
passengers
public CarTrip(int startTime ,int endTime,String
departureLocation ,String destinationLocation,boolean isFull
,boolean brakesChecked ,int numPassenger) {
super.startTime =
startTime;//passing start time to Trip class to store its
value
super.endTime = endTime;//passing
end time to Trip class to store its value
super.departureLocation =
departureLocation;//passing departure location to Trip class to
store its value
super.destinationLocation =
destinationLocation;//passing destination Location to Trip class to
store its value
this.isFull = isFull;//assigning
the boolean value to isFull
this.brakesChecked =
brakesChecked;//assigning boolean value to brakesChecked
this.numPassenger =
numPassenger;//assigning the number of Passengers
}
@Override
boolean checklist() {
if (brakesChecked &&
isFull&& numPassenger<=4) {//if breakesChecked is true
and tank isFUll and number ofPassengers are 4 or less
return
true;//return boolean value true
}
return false;//else false
}
@Override
public double getTaxAmount(Object x) {
return
super.getTaxAmount(x);//passing to super class Trip which passes to
super class Taxable
}
}
PlaneTrip CLASS
public class PlaneTrip extends Trip{//creating PLaneTrip which
extends Trip
boolean ticketIssued;//creating a boolean value
TicketIssued
boolean passportValid;//creating a passportValid
boolean value to store true or false
int numCheckedLuggage;//numCheckLaguage to store the
number of checked lugage
int numCarryOn;//numCarryOn to store the number
public PlaneTrip(int startTime ,int endTime,String
departureLocation ,String destinationLocation,boolean
passportValid,boolean ticketIssued,int numCheckedLuggage,int
numCarryOn) {
super.startTime =
startTime;//passing start time to Trip class to store its
value
super.endTime = endTime;//passing
end time to Trip class to store its value
super.departureLocation =
departureLocation;//passing departure location to Trip class to
store its value
super.destinationLocation =
destinationLocation;//passing destination Location to Trip class to
store its value
this.passportValid =
passportValid;//assigning the values passed through the
constructor
this.ticketIssued =
ticketIssued;
this.numCarryOn = numCarryOn;
this.numCheckedLuggage =
numCheckedLuggage;
}
@Override
boolean checklist() {
//checking is passportValid is true
and ticked is Issued and numCHecked Luggage is 2 or less and
numCarryOn is 1 or less
if (passportValid &&
ticketIssued && numCheckedLuggage<=2 &&
numCarryOn<=1) {
return
true;//return true if all rules are satisfied
}
return false;//else false
}
@Override
public double getTaxAmount(Object x) {
return
super.getTaxAmount(x);//passing PlaneTrip Object to super class
Taxable class
}
}
Test CLASS
public class Test {
public static void main(String[] args) {
CarTrip c1 = new CarTrip(2, 5, "AI
Ain University - Abu Dhabi","AI Ain University - AI in city" ,
true, true, 4);//CREATING OBJECT 1 CAR1 AND PASSING VALUES TO
ASSIGN
if (c1.checklist() == true)
{//CHECKING CAR OBJECT TERMS
System.out.println("You are ready to Make you car trip
from"+c1.getDepartureLocation()+"\n"+"The tax amount to be paid for
the car trip is : $"+c1.getTaxAmount(c1));//PASSING C1 OBJECT
}
System.out.println();//SEPERATING
LINE
PlaneTrip p1 = new PlaneTrip(3, 4,
"UAE","JORDAN",true,true, 2, 1);//CREATING PLANETRIP OBJECT
if (p1.checklist() == true)
{//CHECKING THE RULES
System.out.println("You are ready to Make you plane trip
from"+p1.getDepartureLocation()+"\n"+"The tax amount to be paid for
the car trip is : $"+p1.getTaxAmount(p1));
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
You are allowed to add any parameter you need into any class. You are not allowed...
in java Write a class named Palindrome.java and Write a method isPalindrome that takes an IntQueue as a parameter and that returns whether or not the numbers in the queue represent a palindrome (true if they do, false otherwise). A sequence of numbers is considered a palindrome if it is the same in reverse order. For example, suppose a Queue called q stores this sequence of values: front [3, 8, 17, 9, 17, 8, 3] back Then the following call:...
Write code in Java programming language. The ShoppingCart class will be composed with an array of Item objects. You do not need to implement the Item class for this question, only use it. Item has a getPrice() method that returns a float and a one-argument constructor that takes a float that specifies the price. The ShoppingCart class should have: Constructors: A no-argument and a single argument that takes an array of Items. Fields: • Items: an array of Item objects...
pls help me with it. you just need to answer the question in Appointment.Java, There is only 1 question u need to answer! Appointment.Java package option1.stage3; import option1.stage1.Doctor; import option1.stage1.Patient; import option1.stage2.TimeSlot; public class Appointment { private Doctor doctor; private Patient patient; private TimeSlot timeSlot; public Doctor getDoctor() { return doctor; } public void setDoctor(Doctor doctor) { this.doctor = doctor; } public Patient getPatient() { return patient; } public void setPatient(Patient patient) { this.patient = patient; } public TimeSlot getTimeSlot()...
I NEED HELP with this. please create a UML diagram. I need a simple code to solve the problem. The ADT Bag is a group of items, much like what you might have with a bag of groceries. In a software development cycle, specification, design, implementation, test/debug, and documentation are typical activities. The details are provided in the rest of the document. ADT Bag Specification: (Note: You should not change the names of the operations in your program. This should...
code must be in java.
Assignment 5 Purpose In this assignment, you will implement a class hierarchy in Java. Instructions The class hierarchy you will implement is shown below account Package Account manager Package SavingAccount CheckingAccount AccountManager The descriptions of each class and the corresponding members are provided below. Please note that the Visibility Modifiers (public, private and protected) are not specified and you must use the most appropriate modifiers Class AccountManager is a test main program. Create it so...
will provide any other class if needed. Just need these 3 for now. Thank you You will make one change to the Sort class. You will modify the sortAnything method such that it now accepts a boolean isDescending. If isDescending is false, sortAnything will behave normally (sorting the student in ascending order). If isDescending is true, however, sortAnything will sort in descending order instead. Class University: Modify sortStudents such that it takes a boolean, isDescending, and uses that when calling...
Design and implement a class Q that uses Q.java as a code base. The queue ADT must use class LinkedList from Oracle's Java class library and its underlying data structure (i.e. every Q object has-a (contains) class LinkedList object. class Q is not allowed to extend class LinkedList. The methods that are to be implemented are documented in Q.java. Method comment blocks are used to document the functionality of the class Q instance methods. The output of your program must...
In JAVA In this assignment you will use a class Car to represent a car that travels to various destinations. Your car has a fuel economy rating of 32.3 miles per gallon. The gas tank holds 19.5 gallons. Your program will need to simulate two trips: 1) BC to Yosemite Valley, and 2) BC to Washington, D.C.. For each trip you will start with a full tank of gas. The output should look as follows. Trip one: Bakersfield College to...
In this practical task, you need to implement a class called MyTime, which models a time instance. The class must contain three private instance variables: hour, with the domain of values between 0 to 23. minute, with the domain of values between 0 to 59. second, with the domain of values between 0 to 59. For the three variables you are required to perform input validation. The class must provide the following public methods to a user: MyTime() Constructor. Initializes...
language is java
Restrictions: You are not allowed to use anything from the String, StringBuilder, or Wrapper classes. In general, you may not use anything from any other Java classes, unless otherwise specified. You are not allowed to use String literals in your code ("this is a string literal"). You are not allowed to use String objects in your code. The methods must be implemented by manipulating the data field array, The CSString Class: NOTE: Pay very careful attention to...