(Time Class Modification) It would be perfectly reasonable for the Time class of Figs17.4–17.5 to represent the time internally as the number of seconds since midnight rather than the three integer values hour, minute and second. Clients could use the same public methods and get the same results. Modify the Time class of Fig17.4. to implement the time as the number of seconds since midnight and show that there is no visible change in functionality to the clients of the class. [Note: This exercise nicely demonstrates the virtues of implementation hiding.]
Want to see the full answer?
Check out a sample textbook solutionChapter 17 Solutions
C How To Program, Global Edition
Additional Engineering Textbook Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Starting Out with C++: Early Objects (9th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Modern Database Management (12th Edition)
Starting Out With Visual Basic (8th Edition)
Starting Out with Python (3rd Edition)
- What is the output for the following java code?arrow_forwardJustify the following question in your own opinion. Write your answer very precisely. Friend functions increase Programming Bugs?arrow_forwardPlease answer the following question in Python code: (Composition) Write a Pizza class so that this client code works. Please note that it is ok if the toppings are listed in a different order. >>> pie = Pizza() >>> pie Pizza('M',set()) >>> pie.setSize('L') >>> pie.getSize() 'L' >>> pie.addTopping('pepperoni') >>> pie.addTopping('anchovies') >>> pie.addTopping('mushrooms') >>> pie Pizza('L',{'anchovies', 'mushrooms', 'pepperoni'}) >>> pie.addTopping('pepperoni') >>> pie Pizza('L',{'anchovies', 'mushrooms', 'pepperoni'}) >>> pie.removeTopping('anchovies') >>> pie Pizza('L',{'mushrooms', 'pepperoni'}) >>> pie.price() 16.65 >>> pie2 = Pizza('L',{'mushrooms','pepperoni'}) >>> pie2 Pizza('L',{'mushrooms', 'pepperoni'}) >>> pie==pie2 True The Pizza class should have two attributes(data items): size – a single character str, one of ‘S’,’M’,L”…arrow_forward
- Write a code in Java, test and document (at least) three classes – a CourseWorkStudent class, aResearchStudent class (which both derive from the Student class) and a Client program. Make sure the rules below are followed for the code. For coursework students:(a) There are two assignments, each marked out of a maximum of 100 marks and equally weighted.The marks for each assignment are recorded separately.(b) There is weekly practical work. The marks for this component are recorded as a total markobtained (marked out of a maximum of 20 marks) for all practical work demonstrated during thesemester.(c) There is one final examination that is marked out of a maximum of 100 marks and recordedseparately.(d) An overall mark (to be calculated within the class)(e) A final grade, which is a string (think of a way to avoid code duplication for calculating this)The final grade, for coursework students, is to be awarded on the basis of an overall mark, which is anumber in the range 0 to 100 and is…arrow_forward(Composition as an Alternative to Inheritance) Many programs written with inheritancecould be written with composition instead, and vice versa. Rewrite class BasePlusCommissionEmployee of the CommissionEmployee–BasePlusCommissionEmployee hierarchy to use compositionrather than inheritance. After you do this, assess the relative merits of the two approaches for designing classes CommissionEmployee and BasePlusCommissionEmployee, as well as for object-oriented programs in general. Which approach is more natural? Why?arrow_forward5. Answer the following questions based on your understanding on methods. a) How do the overloading methods can be ambiguous? Which one is the best solution for avoiding ambiguity for the overloading methods - i) pass the appropriate type of variable(s) to the overloading method, ii) avoid declaring overloading methods that may cause ambiguity. b) What are the outputs of the following java code? Which overloading method will swap the values correctly? Why does one of the following overloading methods swap correctly but other does not? public class Mainclass { public static void swap(int a, int b) { int temp; temp = a; a = b; b = temp; } public static void swap(int a[]) { int temp; temp = a[0]; a[e] = a[1]; a[1] = temp; } public static void main(String[] args) { int a=2, b=5; swap(a, b); System.out.println(a+", "+b); int[] arr = {5,8}; swap (arr); System.out.println(arr[@]+", "+arr[1]); }arrow_forward
- ANSWER IN JAVA: 3.14 (Date Class) Create a class called Date that includes three instance variables-a month (type int), a day (type int) and a year (type int). Provide a constructor that initializes the three instance variables and assumes that the values provided are correct. Provide a set and a get method for each instance variable. Provide a method displayDate that displays the month, day and year separated by forward slashes (/). Add a main method to the class that demonstrates class Date's capabilities. STANDARD OUTPUT: Enter·the·month,·day·and·year·in·the·form·XX·XX·XXXX·and·hit·enter:The·Date·object's·state·is:·11/5/1929↵ Enter·a·new·year:The·Date·object's·state·is:·11/5/1978↵ Enter·a·new·day:The·Date·object's·state·is:·11/12/1978↵ Enter·a·new·month:The·Date·object's·state·is:·6/12/1978↵arrow_forwardSolve the problem in C++ (Extend MyPoint) In Programming Exercise 9.4, the MyPoint class was created to model a point in a two-dimensional plane. The MyPoint class has the properties x and y that represent x- and y-coordinates, two getter functions for x and y, and the function for returning the distance between two points. Create a class named ThreeDPoint to model a point in a three-dimensional space. Let ThreeDPoint be derived from MyPoint with the following additional features: - A data field named z that represents the z-coordinate.- A no-arg constructor that constructs a point with coordinates (0, 0, 0).- A constructor that constructs a point with three specified coordinates.- A constant getter function that returns the z value.- A constant distance(const MyPoint&) function to return the distance between this point and the other point in the three-dimensional space. Draw the UML diagram for the classes involved. Implement the classes. Write a test program that creates two…arrow_forwardplease may you : create a Python class named Animal with properties for name, age, and a method called speak. also include an initializer method for the class and demonstrate how to create an instance of this class. and extend the Animal class by adding a decorator for one of its properties (e.g., age). please include both a getter and a setter for the property, and demonstrate error handling.arrow_forward
- java. write grading program for a class with the following grading policies. thers a total of 2 quizzes, each graded on the basis of 10 points. theeres is 1 midterm exam and one final exam, each graded on the basis of 100 points. final exam counts for 50% of the grade, the midterm counts for 25%, and the 2 quizzes together count for a total of 25%. (Do not forget to normalize the quiz scores.) letter grade will be given based on the following criterion: 90 – 100 A 80 – 89 B 70 – 79 C 60 – 69 D 0 – 59 E program will read student’s scores from a txf file, save them in an arrayor arrays), process the arrays), print the student’s record, which consists of the name, 2 quiz and 2 exam scores as well along with students avg numscore for the course and final letter grade. please noteAll the scores are integers and a student name consists of no more than 10 characters. justify output filearrow_forward- a computer store management application with different jframes for customers and orders etc., using Swing library of Java programming language. Choose one of the applications above. Project logic is completely up to you. However, your application is supposed to include at least 3 different windows, in other words, 3 JFrames and you should create connections between those frames according to the logic of your application. Those JFrames can be accompanied by normal (model) java classes as well. In your application, file writing and file reading methods should be utilized. When submitting your project, you are required to have following parts in your paper; • A general description of the application. • Brief explanation of the logic of using different components in the application. • Screenshots of all possible windows. • Source codes (Showing each class separately).arrow_forwardDo the interface l.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