Concept explainers
Define a class called Administrator, which is a derived class of the class SalariedEmployee in Display 7.5. You are to supply the following additional instance variables and methods:
An instance variable of type String that contains the administrator's title (such
as "Director" or "Vice President").
An instance variable of type String that contains the administrator's area of responsibility (such as "Production", "Accounting", or "Personnel").
An instance variable of type String that contains the name of this administrator's immediate supervisor.
Suitable constructors, and suitable accessor and mutator methods.
A method for reading in an administrator's data from the keyboard.
Override the definitions for the methods equals and tostring so they are appropriate to the class Administrator.
Also, write a suitable test
Want to see the full answer?
Check out a sample textbook solutionChapter 7 Solutions
Absolute Java (6th Edition)
Additional Engineering Textbook Solutions
Database Concepts (8th Edition)
SURVEY OF OPERATING SYSTEMS
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Web Development and Design Foundations with HTML5 (8th Edition)
- 4. Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four data members-a part number (type string), a part description (type string), a quantity of the item being purchased (type int) and a price per item (type int). Your dlass should have a constructor that initializes the four data members. A constructor that receives multiple arguments is defined with the form: ClassName( TypeName1 parameterName1, TypeName2 parameterName2, .) Provide a set and a get function for each data member. In addition, provide a member function named getinvoiceAmount that calculates the invoice amount (i.e., multiplies the quantity by the price per item), then returns the amount as an int value. If the quantity is not positive, it should be set to 0. If the price per item is not positive, it should be set to 0. Write a class program according to the main.cpp program given below. #include #include invoice #include…arrow_forward1- Create a hierarchy of Java classes as follows: MyRectangle is_a MyShape; MyOval is a MyShape. Class MyPoint: Class MyPoint is used by class MyShape to define the reference point, p(x, y), of the Java display coordinate system, as well as by all subclasses in the class hierarchy to define the points stipulated in the subclass definition. The class utilizes a color of enum reference type MyColor, and includes appropriate class constructors and methods. The class also includes draw and toString methods, as well as methods that perform point related operations, including but not limited to, shift of point position, distance to the origin and to another point, angle [in degrees] with the x-axis of the line extending from this point to another point. Enum MyColor: Enum MyColor is used by class MyShape and all subclasses in the class hierarchy to define the colors of the shapes. The enum reference type defines a set of constant colors by their red, green, blue, and opacity, components,…arrow_forwardImagine a publishing company that markets its works. Create a class publication that stores the title (a string), author (string), pages (int), pulicationDate (string) and price (type float) of a publication. There should be two constructor i.e. default and parameterized. The default Constructor should initialize the data members to 0 or 0.0 or “” if integers, floating point or string respectively. The parameterized constructor should assign user defined values to the data members. The default constructor should be inline while the parameterized constructor should not be inline. There should be an input/get function to input the values to the data members and a Print() to display the contents of the class variables/datamembers. Create two objects of the class named book, and tape. The book should be created with default constructor, while tape with parameterized constructor. Call input/get for book object only. Then call Print() for both the objects to display the contents. Mention…arrow_forward
- 1. Create a properly encapsulated class named Person that has the following: A String instance variable called name. A constructor that takes a String parameter and sets the instance variable. A properly named getter for the instance variable. A correctly overrided equals method which returns true if the name instance variable of the parameter and the reference variable calling the method are equal. (Do not forget the null and class type checks!) Compile your Person class. 2. Create a properly encapsulated class named Employee that inherits from Person and has the following: ● ● ● A String instance variable called office (e.g. "LWH 2222"). A String instance variable called hourlywage (e.g. "$45.15"). A constructor that takes three Strings as parameters for name, office, and hourlyWage and sets the instance variables of both the parent class and the Employee class. An overridden toString method that returns the concatenation of name and hourlyWage instance variables (separated by a…arrow_forwardLanguage is Java Write a Clothing class with the following attributes: color (e.g., "blue", "green", "orange") displayName (e.g., "Doctor Who hoodie", "slacks") price (e.g., 19.99, 7) Include only one constructor. It should have parameters for each of the attributes and set their values. Additionally, include getters and setters for each of the attributes. Add a driver, name it Purchases, and create 2 Clothing objects. Finally, print out some information about both objects (i.e., print the information from some or all of the getters). For example, if you created a Clothing object whose color was blue, whose display name was work trousers, for a price of 27.99, you could use the getters to print something like this:These work trousers are blue and cost $27.99.Don't hardcode the print statement for full credit, you must use the gettersarrow_forward2. You are to write a program that computes a patient's bill for a hospital stay. different components of the program are The The PatientAccount class The Surgery class The Pharmacy class The main program The PatientAccount class will keep a total of the patient's charges. It will also keep track of the number of days spent in the hospital. The group must decide on the hospital's daily rate. The Surgery class will have stored within it the charges for at least five types of surgery. It can update the charges variable of the PatientAccount class. The Pharmacy class will have stored within it the price of at least five types of medication. It can update the charges variable of the PatientAccount class. The student who designs the main program will design a menu that allows the user to enter a type of surgery and a type of medication, and check the patient out of the hospital. When the patient checks out, the total charges should be displayed.arrow_forward
- Your Code must be fully commented. The class name should be OOP your roll number (024).arrow_forwardDefine a new "Exam" class that manages the exam name (string) and its score (integer). For example, an exam can have - "Midterm Exam", 100 - "Final Exam", 50 The class must not provide the default constructor. It must require the exam name and score in order to initialize the Exam object. The class must provide only the following methods (no more and no less): - isPerfect method that returns true if the score is exactly 100 and false otherwise. - isPassing method that returns true if the score is equal or greater than 70 and false otherwise. - toString method must return all the exam information including the result of the exam as a string in the following format: EXAM(<name>) SCORE(<score>) RESULT(Pass/Fail) such asEXAM(Midterm Exam) SCORE(100) RESULT(Pass) EXAM(Final Exam) SCORE(50) RESULT(Fail) "Pass" means the score is greater or equal 70. "Fail" is whenever the score is below 70. - isGreater method that compares with another Exam object and return true if the score…arrow_forwardThe questions are related to each other, start from the top to bottomarrow_forward
- 1. Design a new Triangle class that extends the abstract GeometricObject class. Write a test program that prompts the user to enter three sides of the triangle, a color, and a Boolean value to indicate whether the triangle is filled. The program should create a Triangle object with these sides and set the color and filled properties using the input. The program should display the area, perimeter, color, and true or false to indicate whether it is filled or not.arrow_forwardFor the StudentWorker class, create the following: A private int instance variable m hours. A private int instance variable m A constructor that takes four parameters (in the order of name, department, hours, hourly wage). It should use the parameters for hours and hourly wage to set the m_hours and m hourlyWage instance variables and then explicitly call the parent class constructor using the super keyword and pass in the two other parameters. hourlyWage. A getPaycheck method that implements the same method in the Employee class. It calculates the paycheck amount (m hours × m worker's paycheck as a string in the following format (Note that the three fields are hourlyWage) and returns the student separated by a hyphen, represented by the minus character. Do NOT add spaces before or after each hyphen. There are no commas in the number.): Optimus Prime-Computer Science-$1200arrow_forwarddayType Class We will be working on a project that designs a class calendarType, so that a client program can use this class to print a calendar for any month starting Jan 1. 1900. An example of the calendar for September 2019 is: September 2019 Sun Mon Tue Wed Thu Fri Sat 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 We will develop several classes which will work together to create a calendar. The first of these classes is called dayType which will manipulate a day of the week. The class dayType will store a day, such as Sun for Sunday. The class should be able to perform the following operations on an object of type dayType: a. Set the day. b. Print the day. c. Return the day. d. Return the next day. e.…arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage