Define a class named Doctor whose objects are records for a clinic’s doctors. Derive this class from the class Person given in Listing 8.1. A Doctor record has the doctor’s name—defined in the class Person—a specialty as a string (for example Pediatrician, Obstetrician, General Practitioner, and so on), and an office-visit fee (use the type double). Give your class a reasonable complement of constructors and accessor methods, and an equal method as well. Write a driver program to test all your methods.
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
Additional Engineering Textbook Solutions
Software Engineering (10th Edition)
C How to Program (8th Edition)
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Starting Out With Visual Basic (7th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Problem Solving with C++ (9th Edition)
- Create a class BeautyProduct with name, color, brand. Provide Constructors, getters, setters and also write toString method. Now create a class Lipstick which extends the class BeautyProduct as Lipstick is-a Beauty Product it has totalVolume, remainingVolume, price, texture (gloss, matt) as private data members. Provide Constructors, getters, setters and an apply() method whenever this method is called a beauty item is applied and its volume decreases by 10.This should also check that volume must not be zero if it then u have to throw exception. Also write toString method which prints all details like name, color, brand, price, texture and volume. Create another class foundation having totalVolume, remainingVolume, price, texture (liquid, cake) and lastingTime (number of hours foundation remain intact on face and does not crease) as private data members. This also extends the base class i.e. BeautyProduct. Provide Constructors, getters, setters and an apply() method whenever this…arrow_forwardJava- Suppose that Vehicle is a class and Car is a new class that extends Vehicle. Write a description of which kind of assignments are permitted between Car and Vehicle variables.arrow_forwardCreate an interface Wheel with methods setWheels (int c) and getWheels () and a class Vehicle with abstract methods getColor () and getBrand (). Now, create a concrete class Taxi with additional method setDriver (String name) that inherits both Wheel and Vehicle. (Note: Concrete classes don’t have any abstract method)arrow_forward
- Write a code for the tracking problem: Consider a tracking program that will track four types of things: Books, Mobiles, Laptop, and Bags. • Implement the Tracking program. • Allow the user to add, modify, and delete Books, Mobiles, Laptop, and Bags. • Allow the user to search for an asset by its serial number. Note: What classes are you going to design for the program? Want to define four non-related classes or one superclass and 4 subclasses? Would it be an abstract superclass if you design a superclass?arrow_forwardCreate a class Animal Create a class Cat, and a class Dog, and a class Bearded Dragon which extend Animal. Add to your Animal class: Member: name Methods: Public Animal (String name) //constructor public void makes Sound () with the implementation printing out a generic animal sound. Next, override (add) the makes Sound() method to your Cat and Dog class, with the implementation specific to each animal (i.e, cat says purr..). Do not override the makesSound() for your Dragon (bearded dragons don't make sounds!) Note, you'll also need a constructor in each of your subclasses which calls super(name) to initialize the common 'name' member of Animal. Next (in your test harness) create a List of different Animals ( a couple cats, a dog, a dragon... ) and add these Animals to your list. Iterate through your list & call makeSound on each. (you should observe the makeSound method called will be: cat -> from Cat class, dog-> from Dog class, bearded Dragon -> from Animal class ) EC:…arrow_forwardWrite all code for a class Guitar as described here. A Guitar can be described as having a number of strings (int), manufacturer (string), and price. Include the following methods in your class definition: • A default constructor. An overloaded constructor which takes the number of strings and manufacturer as input. • A getter (accessor) method to acquire the price. A tostring method that returns a reasonable description of the guitar. public class Guitar Write all the code necessary for a class TestGuitar as described here. TestGuitar implements a main method with the following functionality. a) Construct one guitar object using the default constructor b) Construct a second guitar object for a 6-string Gibson. c) Declare a variable p and initialize it with the price of the first guitar by calling the proper method. d) Print both guitar objects that were constructed. public class TestGuitar 8 of 9arrow_forward
- NOTE: READ CAREFULLY Design a class named Person and a subclasses named Employee. Make Teacher a subclass of Employee. A Person has a name, address, and e-mail address. An Employee has an office, salary. A Teacher has office hours and a subject they teach. They also have a tenure status. Define the tenure status as a constant. The tenure status is either Senior or Junior, and is represented as an integer, where Senior is equal to 1, and Junior is equal to 2. Each class should have a Default constructor, and a constructor that accepts all arguments. There should be appropriate calls to the superclass within the constructors. Each class should also have getters and setters for each member variable. Each class should have a toString method. Note: You do NOT need to run this in a test program. Just create the classes as indicated above.arrow_forwardAnswer the following and code in Java Thank youarrow_forwardImplement the Seller class as a derived class of Person class. Create the seller.h and seller.cppfiles for this class. The Seller class contains additional data members that hold a seller’s:o average star rating received from the buyers, ando total number of items sold.These data should be accessible by its derived classes. (should these data be private, public, orprotected?) The following methods are included in the seller class:• A default constructor and a copy constructor• A constructor that receives all of the data for a seller.(for the constructors, make sure to call the base class constructor as appropriate)• Appropriate get and set functions for the new data in this class• print() – overrides the base class print() to print the base class data and print all additionalseller data with appropriate messages. Make sure to call the base class print to print thebase class data.• read() – overrides the base class read() to read the base class data and reads all additionalseller data…arrow_forward
- Make a class Employee with a name and salary. Make a class Manager inherit from Employee. Add an instance variable, named department, of type string. Supply a method tostring that prints the manager's name, department, and salary. Make a class Executive inherit from Manager. Supply appropriate tostring methods for all classes. Supply a test program that tests these classes and methods.arrow_forwardWrite a class named Person with data attributes for a person’s name, address, and telephone number. Next, write a class named Customer that is a subclass of the Person class. The Customer class should have a data attribute for a customer number and a Boolean data attribute indicating whether the customer wishes to be on a mailing list. Demonstratean instance of the Customer class in a simple program.arrow_forwardSuppose that class Child extends class Parent, and that Parent does not explicitly extend another class. Suppose also that Child has THREE constructors and Parent has TWO constructors. When creating a Child object, Child c = new Child(...), what is the minimum and maximum number of constructors being called in total?arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education