The class TimeBook in Listing 7.14 is not really finished. Complete the definition of this class in the way described in the text. In particular, be sure to add a default constructor, as well as set and get methods that change or retrieve each of the instance variables and each indexed variable of each array instance variable. Be sure you replace the stub setHours with a method that obtains values from the keyboard. You should also define a private method having two int parameters that displays the first parameter in the number of spaces given by a second parameter. The extra spaces not filled by the first parameter are to be filled with blanks. This will let you write each array element in exactly four spaces, for example, and so win allow you to display a neat rectangular arrangement of array elements. Be sure that the main method in Listing 7.14 works correctly with these new methods. Also, write a separate test program to test all the new methods (Hint: To display an int value n in a fixed number of spaces, use Integer.toString(n) to convert the number to a string value, and then work with the string value. This method is discussed in Chapter 6 in the section “Wrapper Classes.”)
Want to see the full answer?
Check out a sample textbook solutionChapter 7 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Additional Engineering Textbook Solutions
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis
Database Concepts (7th Edition)
Concepts of Programming Languages (11th Edition)
Artificial Intelligence: A Modern Approach
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
- I need the source code for this question 4 in Java. Please provide an explanation for the methods provided. Client Class:The client program should read the input data from the user (or the method with hardcoded inputs)and use the Change class to store the data entered. This data should be stored in a Change classobject. You will need a data structure to store the Change class objects according to the number ofpersons entered. Thus, you are to utilize an array of Change objects. Do not use ArrayList for thisassignment It should be noted that it is possible to have the same name entered numerous times, but the coinvalues for such repetitions could be different. When the name is the same, it would mean the sameindividual, and your program should add up the coin amounts to obtain a total amount for thatindividual; this should be performed before computing the change to be given. Note that in thisscenario, the total amount for an individual may end up being over 100, 200, 300, or more cents…arrow_forwardYou will need to use at least 1 additional class other than the class with the main method. Perhaps the class would be how you instantiate each character for the array? The class needs to contain at least 3 different private members (variable/attribute) and public getter and setter properties for those members. These could be name, points, whether the character is good or evil, etcarrow_forward1. Create a class Employee with parameters name, id, designation, and basicSalary. Use appropriate datatypes and access specifiers. Use default constructor to create objects of employee. Write methods toset and get the values of parameters of employee. Write methods to find total salary of employee andto display the complete details of employee along with total salary. Create another class TestEmployeewhich creates array of n number of employees, uses appropriate set methods to set the values ofparameters of every employee. Display the details of each employee. (Total salary = basic salary + 80%of basic salary)arrow_forward
- THE BELOW IS IMPORTANT Rewrite the above code so that It has all of the correct access modifiers for good encapsulation. Your code obeys the principle of encapsulation that obliges you to put each method in the proper class. Your code uses NO getters and NO additional classes or methods. You are welcome to modify any existing methods (including signatures and bodies) and/or move them between the existing classes. Your code DOES NOT modify any of the constructors. Important notes: You DO NOT have to write a main method. You DO NOT have to write tests. You DO NOT have to write Javadocs. You DO NOT have to write interfaces to encapsulate data structures. There should be no incorrect syntax or other compile-time errors.arrow_forward) Modify the BookStore and BookSearchEngine classes explained in the class to include the following additional methods and test them:a) A method returning the book with the lowest price in the library.b) A method searching the library for Books of a given author and returning an ArrayList of such Books. c) A method returning an ArrayList of Books whose price is less than a given number.arrow_forwardThe owner of a venue for events needs software to keep track of reservations. The venue can handle two events in a day, one scheduled for the afternoon and another scheduled for the evening. Each event consists of the type (wedding, bar mitzvah, etc.), the date of the event, and whether or not the event will be held in the evening. A programmer writes the code given on the handout. import java.util.LinkedList; class Event { // wedding, etc. String type; Date date; boolean isEvening; // true if the event is to be held in the evening public Event(string type, Date date, boolean isEvening) { this.type - type; this.date = date; this.isEvening = isEvening; } class Date { string month; int day; int year; public Date(string month, int day, int year) { this.month = month; this.day = day; this.year = year; class Reservations { LinkedList events; public Reservations() { this.events = new LinkedList(); // adds the given event to the events list, as long as there is no // date/time conflict with…arrow_forward
- 1. Implement the above system using inheritance in the best possible way. Keep every object size as small as possible. Implement all methods (setter/getter/constructors and destructors) Note that the region area is 0 while the city is len*width and the country is the sum of their cities. 2. Create array of countries called Arab of 22 countries, Write a function fill that fills the arrav Arab 3. Write a method that finds the city that has the max area in a country 4. Write a method that sorts the cities in a country from the largest to the smallest area 5. Write a function that retums array of countries of the same area of Arab 6. Write a function that compares between two countries. It returns true if countryl area greater than country2 area. 7. Write a function to move a city from one country to another.arrow_forwardYou are required to design an item class which has following attributes String name; Int stock; Int price; String expiry_Date; Provide default & Parameterized constructors. Provide getters & setters for data members. Provide a toString() method to print values. Now create an array of items store values in it (take values form user). After that you have to print the following All the items in the array. items whose name starts with ‘a’; All sold out items (whose stock is zero). All the items having expire date before 2-11-2020. Solve this using Simple java, arrays in java and string methods if required.arrow_forwardI found this practice java problem. Unfortunately, this is out of my knowledge, but I'm just very curios as to how I could solve it. Any help is appreciatedarrow_forward
- Must be written in Python. Please include docstring and show how output should look like. Remember that all data members should be private. An object can access it's own private data members directly. It can also access the private data members of other objects of the same class directly. But when accessing a private data member of an object of another class, it needs to call the appropriate get method. If that sounds complicated, just remember this: if a method is in the same class as a private data member, then it can access that data member directly, otherwise, it needs to use a get method. Write a class named Point that has two data members, x_coord and y_coord, representing the two coordinates of the point. It should have: an init method that takes two arguments, an x-coordinate and y-coordinate (in that order), and uses them to initialize the two data members. get methods for the two data members: get_x_coord and get_y_coord. a method named distance_to that takes a Point object…arrow_forwardCreate a class Car with parameters companyName, color, maxSpeed (Not more than 150) andcategory. Use appropriate data types and access specifiers. Use default constructor to create objectsof cars. Write methods to set and get the values of parameters of car. Write methods to find categoryof car and to display the complete details of car along with category. Create another class TestCarwhich creates array of n number of cars, uses appropriate set methods to set the values of parametersof every car. Display the details of each car. (If max speed is between 120 and 150 then category is“High speed” otherwise “Normal”) (JAVA)arrow_forwardDesign and implement a data class. The class will store data that has been read asuser input from the keyboard (see Getting Input below), and provide necessary operations. As the data stored relates to monetary change, 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. You may also wish to use 4 instance variables to represent amounts for each of the 4 coin denominations (see Client Class below). There should be no need for more than these instance variables. However, if you wish to use more instance variables, you must provide legitimate justification for their usage in the internal and external documentation. 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 may be provided as…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