A class RentedVehicle that has: 1.One private instance variable baseFee of type double 2.One constructor to initialize the instance variable 3. One instance method getCost () that returns the base fee - Accessor methods for the instance variables A subclass FuelVehicle that: 1.has one additional private instance variable nbKms indicating the total number of kilometers traveled. 2. one constructor to initialize the instance variables. 3. one instance method getMileageFees to return the fees due to mileage based on the following:
Q: This composition example contains classes Date, Employee and EmployeeTest .Class Date declares…
A: public class Date{ //instance variables used to store Date private int day; private int month;…
Q: The Room Carpet Class Part (1) Create a class called RoomCarpet that has three private instance…
A: Part 1: Please save the code as RoomCarpet.java public class RoomCarpet { private double length;…
Q: Write a Hamster class that is a subclass of Pet. Include: an additional attributes called…
A: A class is a group of objects which have common properties. A constructor is a method that is used…
Q: Given the code snippet below, the parameterized constructor for the class "SomeClass" is not working…
A: super is used to access something related to parent class whereas this refers to current instance…
Q: B - RobotFriend Create a RobotFriend class. RobotFriend is a new toy just on the market. Copy the…
A: EXPLANATION: - The RobotFriend class Details: - Instance Variables Declaration private String…
Q: Create two classes, Patient and Billing, whose objects are records for a clinic. Patient will be…
A: Programming Language Java:-
Q: Java Problem. compile and run the code below: /** A class to test the Door class. */ public…
A: Class definition: A class is a user-defined data type that contains the data members and methods.…
Q: A class called MyCircle, which models a circle with a center (x,y) and a radius, is designed as…
A: The required Java code is: // The MyPoint class definitionpublic class MyPoint { // Private member…
Q: Create an Employee Class that will have • Two instance variable: name and workingPeriod •A class…
A: Python class and static methods : def _init__ (self) : The method init is like a constructor that…
Q: Define a class named Apartment that has the following • An instance variable named address of type…
A: Create a class Apartment Then create instance variables in it Create a constructor that will have no…
Q: Design a ‘book’ class with title, author, publisher, price and author’s royalty as instance…
A: The following program created in Java. Created book class. Created constructor of book class for an…
Q: Create an Employee Class that will have ● Two instance variable: name and workingPeriod ● A class…
A: Answer : Employee Class Code Snippet: #Import datetime to get the curent yearfrom datetime import…
Q: Given the following class definition: public class Car { private String vehicleld; public Car…
A: Note: As per our guidelines we are supposed to answer only one question. Kindly repost other…
Q: Design a class called Flight that will store data about a commercial flight. Data includes:…
A: Begin Enter the details of the flight Display the details of the flight End
Q: Now write a Demo class which contains main method in order to demonstrate the behavior of all…
A: public class Main{ public static void main(String[] args) { //create Circle instace and…
Q: For the Circle class, create the following: • A private double instance variable m_radius. • A…
A: i.Class of circle The following class diagram depicts the design of a circle class. It includes the…
Q: Your task is to implement the following DigitalWallet class. The description of the class is as…
A: 1.DigitalWallet (double blnc, String ownr) 2.boolean pay(double amount) 3.boolean topUp (double…
Q: WRITE THIS JAVA CODE: A class RentedVehicle that has: - One private instance variable baseFee of…
A: Actually, the code for the above is given below:
Q: Create an abstract class called vehicle. The class should declare the following variables: an…
A: Given vehicle class : //Vehicle abstract class definition abstract class Vehicle { // data…
Q: • An instance variable of type double named price. • An instance variable of type String named type.…
A: According to the information given:- 1. I have created on clothing class based on according to your…
Q: Suppose there is a class Eye already created and has constructors and get and set methods. Write the…
A: Given data is shown below:
Q: In the following there are two classes, Employee and Manager. Manager is a subclass of Employee. The…
A: Constructor is the same name as that class name, and it is invoked when the object of that class is…
Q: A Car class which is a subclass of FuelVehicle that has: one additional private instance variable…
A: public class RentedVehicle { //declaring insatnce variable private double basefee; //constructor…
Q: Create a RobotFriend class. RobotFriend is a new toy just on the market. Copy the starter class and…
A: The required class will have an instance variable "name". 'this' refers to the current object of the…
Q: Write a class named Employee which implements Comparable Interface with name and salary as data…
A: Java program to create Employee and Manager class and build the given functionality.
Q: uppose you have opened an account with an initial amount of $50 and you have to add some more amount…
A: class AddAmount{ private int amount = 50; public AddAmount() //Default Constructor {…
Q: For the Faculty class, create the following: A private int instance variable m salary. A constructor…
A: A class is a group of objects which have common properties. A constructor is a method that is used…
Q: Given the following statement: Paper paper = new Paper("A4", 80); where "A4" is the paper size and…
A: Step 1st: Private Attributes of papersize and paperweight; Step 2nd: Constructor of Paper class Step…
Q: Create a Class Pet with the following data members Identification: String species : String (e.g.…
A: Solution- Programming language used - Java All solution necessary comments are included in program…
Q: In the following there are two classes, Employee and Manager. Manager is a subclass of Employee. The…
A: Problem: In the following, there are two classes, Employee and Manager. Manager is a subclass of…
Q: Complete the partial declaration of Class Car: public class Car { // declare three…
A: this keyword takes value from current object of instance variables. A setter method is always of…
Q: ou need to write the complete code as mentioned below: i) The main class with necessary codes.…
A: Summary:In this question, we need to create a superclass, subclass, and test class to test the…
Q: A class called Book is designed to model a book written by one author. It contains: • Four private…
A: In Python, constructors enable assigning the initial values to attributes of an instance of a class.…
Q: Class EmployeeTest creates two Date objects to represent an Employee’s birthday and hire date,…
A: public class EmployeeTest{ public static void main(String[] args) { Date d1=new…
Q: Write the following Book class:A Book has-a title, ISBN number, author and price.o Include the…
A: All the lines inside this (/* */) field are comments of this program. Read all comments above the…
Q: class Point with instance variables as: xCoordinate(int) and yCoordinate(int). Write public instance…
A: Program code: Filename: Point class(PointClass.java) class PointClass{ private int xCoordinate;…
Q: The xxx_Pet classA Pet has a:– Name• Include an instance variable• Getters and setters for an…
A: Programming language is missing in the question. The below program is written in Java programming…
Q: This composition example contains classes Date, Employee and EmployeeTest .Class Date declares…
A: public class EmployeeTest { public static void main(String[] args) throws Exception { //create…
Q: Create a subclass named Square from the superclass GeometricObject. Create an instance variable…
A: GeometricObject.java public abstract class GeometricObject {private String color = "white";private…
Q: Write a class called Dog that contains instance data that represents the dog's (string literal) name…
A: main.java (code) public class Main { public static void main(String[] args) { // Creating…
Q: MAKE A PROGRAM. Given the diagram in the attached photo, Employee is a super class with subclasses…
A: abstract class EMPLOYEE{ String empName="abc"; abstract double computeSalary(); }class…
Q: Create a subclass named Square from the superclass GeometricObject. Create an instance variable…
A: Sub Class is a class which inherits the other class. It is also called a derived class or child…
Q: A. Write the classes as shown in the following class diagram. Movable is an interface and…
A: Movable.java public interface Movable { void moveUP(); void moveDown(); void…
Q: 1) Write a class called Room, which has three private instance variables: a) a double width,…
A: Explanation : The code is self explanatory. Here are some key points: Instance variables are…
Q: Write a class called Dog that contains instance data that represents the dog’s name and age. •…
A: Algorithm: Start Create a class Dog with name and age as its attributes Implement constructor to…
Q: A class called Book is designed (as shown in the class diagram) to model a book written by one…
A: //this class might have been already implementedpublic class Author{ //declaring instance…
Q: Assume the existence of a Window class with a constructor that accepts two integer parameters…
A: The constructor for TitledWindow class is ://TitledWindow class constructor public…
Q: A class called Book is designed (as shown in the class diagram) to model a book written by one…
A: Actually, java is a object oriented programming language.
Q: Write an application class that generates 6 objects randomly from either a Car, or a Truck, or a…
A: public class RentedVehicle{ //declare instance variable private double baseFee; //constructor for…
USE C++ AND Concept of inheritance for the program.
Step by step
Solved in 2 steps
- WRITE THIS JAVA CODE: A class RentedVehicle that has:- One private instance variable baseFee of type double- One constructor to initialize the instance variable- One instance method getCost () that returns the base fee- Accessor methods for the instance variablesA subclass FuelVehicle that :- has one additional private instance variable nbKms indicating the total numberof kilometers traveled.- one constructor to initialize the instance variables.- one instance method getMileageFees to return the fees due to mileage based onthe following:If nbKms < 100 mileagefees=0.2*nbkmsIf 100<=nbKms<= 400 mileagefees=0.3*nbkmsIf nbKms>400 mileagefees=0.3 times 400 plus 0.5 times the extra kilometers above 400.- accessor methodsA Car class which is a subclass of FuelVehicle that :- has one additional private instance variable nbSeats - has one constructor to initialize the instance variables- overrides getCost method by adding nbseats*baseFee to mileageFees- accessorsA Truck class which…A class called MyCircle, which models a circle with a center (x,y) and a radius, is designed as shown in the class diagram. The MyCircle class uses an instance of MyPoint class (created in the previous exercise) as its center. The class contains: Two private instance variables: center (an instance of MyPoint) and radius (int).A constructor that constructs a circle with the given center's (x, y) and radius.An overloaded constructor that constructs a MyCircle given a MyPoint instance as center, and radius.A default constructor that construct a circle with center at (0,0) and radius of 1.Various getters and setters.A toString() method that returns a string description of this instance in the format "MyCircle[radius=r,center=(x,y)]". You shall reuse the toString() of MyPoint.getArea() and getCircumference() methods that return the area and circumference of this circle in double.A distance(MyCircle another) method that returns the distance of the centers from this instance and the given…Write a class Point with instance variables as: xCoordinate(int) and yCoordinate(int). Write public instance methods (getters & setters) for each instance variable. Now, write a class Circle with private instance variables as radius and Pi (value is 3.14). Write public setter, getter for radius, Area method for calculating Area, Draw method for radius. Formula for calculating area=pi*r^2 Formula for calculating radius= sqrt (xCordinate^2+yCordinate^2) Extend a Circle class from Point class such as Class Circle extends Point Write a Default constructor in Circle class that sets radius, xCoordinate & yCoordinate to some default value e.g. -1; Write a Parameterized constructor in Circle class which takes xCoordinate, yCoordinate and radius as a parameter. E.g. Circle (int xCoordinate, int yCoordinate, double radius) { this.xCoordinate= xCoordinate; this.yCoordinate= yCoordinate;…
- Write a class Point with instance variables as: xCoordinate(int) and yCoordinate(int). Write public instance methods (getters & setters) for each instance variable. Now, write a class Circle with private instance variables as radius and Pi (value is 3.14). Write public setter, getter for radius, Area method for calculating Area, Draw method for radius. Formula for calculating area=pi*r^2 Formula for calculating radius= Math.sqrt (xCordinate^2+yCordinate^2) a. Extend a Circle class from Point class such as Class Circle extends Pointb. Write a Default constructor in Circle class that sets radius, xCoordinate & yCoordinate to some default value e.g. -1;c. Write a Parameterized constructor in Circle class which takes xCoordinate, yCoordinate and radius as a parameter.Now write a ColoredCirlce class with private instance variable as color (String) and public setter & getters. Extend the ColoredCircle from Circle and do the following operations.d. Write a default constructor…Write a class called Circle that contains:a. Three private instance variables: radius (of the type double), color (of thetype String), and area (of type double).b. Two constructors - a default constructor with no argument (default value of radiusis 2.0, and color is Green) and a parameterized constructor, which initializes onlythe radius and the color variables.c. Getter and setter for the radius and color variables.d. Two public methods: calculateArea(), and getPerimeter, which return the areaand perimeter of a circle instance, respectively. Both methods have return.Then write a driver class that tests the Circle class. In the driver class, create two objectsof Circle class, one that tests the default constructor of the Circle class (here no user inputis required) and then get the color, radius, area, and perimeter of that object and displaythem. The second object should test the parameterized constructor (here you need to ask userto give you input to initialize the class variables).…Give a complete definition of a class called TitledPerson, which youderive from the class Person in Listing 8.1. The class TitledPerson hasone additional String instance variable for a title, such as Ms., Mr.,or The Honorable. The class TitledPerson has two constructors: adefault constructor and one that sets both the name and the title. It hasa writeOutput method, a reset method, an equals method, an accessormethod getTitle that returns the title, and a mutator method setTitlethat changes the person’s title. For two titled people to be equal, theymust have the same name and the same title. You may want to use theclass Student in Listing 8.2 as a model.
- the class should be named Change. The class requires at least 2 instance variables for the name of a person and the coin change amount to be given to that person. In Australia, the coin denominationsare 50 cents, 20 cents, 10 cents, and 5 cents. All these instancevariables should be declared as private. Think of a way such that the client program can use thesame class name and public methods for other countries with different coin denominations withoutchanging their client program. Explain how your class can satisfy this in your externaldocumentation.Your class will need to have at least a default constructor, and a constructor with two parameters:one parameter being a name and the other a coin amount. Your class should also provide appropriateget and set methods for client usage. Other methods (including helper) may be provided as needed.However, make sure they are necessary for good class design; you must provide legitimate justification for their usage in the internal and external…Create a class called RoomCarpet that has three private instance variables – room lengthand width in foot (double) and carpet cost per square foot (double). Additionally, the classshould have:a. A constructor that takes room length, room width and carpet cost per square foot. Theconstructor sets the class variables to these values and in case any of these values isnegative, set its instance variable to zero.b. A mutator method (set) and an accessor method (get) for the carpet cost variable only.c. A method getArea that returns the area of the room. The area of the room iscomputed by multiplying the room's length by the room's width.d. A method getTotalCost that returns the total cost of the carpet. The total cost iscomputed by multiplying the room area by the carpet cost per square foot. NOTE this is in java and there another question ill add as a follow up(Java) Create an HourlyEmployee class that inherits from Employee and has two new instance variables: hours, which represents the hours worked, and wage, which represents the employee's pay per hour. (Both are doubles.) Create a constructor that takes the arguments first name, last name, social security number, hourly wage, and the number of hours worked. Also create accessors, mutators, an earnings method that returns the money earned by the employee this week, and a toString method that returns information about the employee in the form of a String. The setWage method should ensure that the wage is nonnegative, and the setHours method should ensure that the value of hours is between 0 and 168 (the number of hours in a week).Create a Driver class with a main method that prompts the user to enter a first name, last name, social security number, hours, and wage for an employee. Then, the program should create an HourlyEmployee object and use its toString method to print information…
- 1) Write a class called Room, which has three private instance variables: a) a double width, representing the width of the room in feet, b) a double length, representing the length of the room in feet, and c) an int floor, representing the building floor that the room is on. 2) Write a default constructor for the class Room that sets the width to 10, the length to 12.5, and the floor to 1. 3) Write get and set methods (“getters” and “setters”) for the three instance variables. For the set methods for the width and length, only positive values should be set. If the input is 0 or a negative number, the variables should not be changed. 4) Write a constructor for the class Room that takes in two double parameters and an int, and sets length to the larger double, width to the smaller double, and floor to the int. Use the setters from part (b). 5) Override the default toString method for the class Room, so when called by an instance of Room created by the default constructor from part (a)…Complete the FoodItem class by adding a constructor to initialize a food item. The constructor should initialize the name (a string) to "None" and all other instance attributes to 0.0 by default. If the constructor is called with a food name, grams of fat, grams of carbohydrates, and grams of protein, the constructor should assign each instance attribute with the appropriate parameter value. The given program accepts as input a food item name, fat, carbs, and protein and the number of servings. The program creates a food item using the constructor parameters' default values and a food item using the input values. The program outputs the nutritional information and calories per serving for both food items. Ex: If the input is: M&M's 10.0 34.0 2.0 1.0 where M&M's is the food name, 10.0 is the grams of fat, 34.0 is the grams of carbohydrates, 2.0 is the grams of protein, and 1.0 is the number of servings, the output is: Nutritional information per serving of None: Fat: 0.00 g…Build a class called BankAccount that manages checking and savings accounts. The class has three private member fields: a customer name (String), the customer's savings account balance (double), and the customer's checking account balance (double). Implement the following Constructor and instance methods: public BankAccount(String newName, double amt1, double amt2) - set the customer name to parameter newName, set the checking account balance to parameter amt1 and set the savings account balance to parameter amt2. (amt stands for amount)public void setName(String newName) - set the customer namepublic String getName() - return the customer namepublic void setChecking(double amt) - set the checking account balance to parameter amtpublic double getChecking() - return the checking account balancepublic void setSavings(double amt) - set the savings account balance to parameter amtpublic double getSavings() - return the savings account balancepublic void depositChecking(double amt) - add…