Absolute Java (6th Edition)
6th Edition
ISBN: 9780134041674
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 4, Problem 10STE
The method writeOutput in Display 4.2 uses the instance variables month, day, and year, but gives no object name for these instance variables. Every instance variable must belong to some object. To what object or objects do these instance variables in the definition of writeOutput belong?
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Given a class student that represents names and grades of a class:
1. How would we implement the Comparable interface in our class so we can compare the scores of individual students? Write
the complete Class Header implementing this interface.
2. Write the complete Method Header for the Student class's compareTo method. You do not need to write the body of the
method.
Using python: Suppose a call center has three levels of employees—respondent, manager, and director. An incoming telephone call must first be allocated to a respondent who is free. If the respondent cannot handle the call, the call must be escalated to a manager. If the manager is occupied, then the call should be escalated to a director. Design YOUR OWN classes and data structures for this problem. Implement a method dispatchCall() that assigns a call to the first available employee.
Please answer quick in python
Define a Rectangle class that inherits from Quadrilateral, with the following methods:
__init__(self, length, width): Override the __init__ method so that the Rectangle constructor only takes in two floating point numbers. Your constructor for Rectangle should only consist of a call to Quadrilateral’s constructor: don’t define any new instance variables.
Override the area method to return the correct area for a rectangle (width*length). Remember: you don’t have self.width or self.length instance variables, so you must use the instance variables from Quadrilateral to do this.
Do not override the perimeter method: if your __init__ is correct then the inherited method from Quadrilateral should work as-is.
Examples:
>>> isinstance(Rectangle(4, 6), Quadrilateral)
True
>>> Rectangle(6, 7).area()
42
Chapter 4 Solutions
Absolute Java (6th Edition)
Ch. 4 - Write a method called makeItNewYears that could be...Ch. 4 - Write a method called yellIfNewYear that could be...Ch. 4 - Prob. 3STECh. 4 - Write a method called happyGreeting that could be...Ch. 4 - Prob. 5STECh. 4 - Write a method called advanceYear that could be...Ch. 4 - Prob. 7STECh. 4 - Prob. 8STECh. 4 - Consider the definition of the method monthString...Ch. 4 - The method writeOutput in Display 4.2 uses the...
Ch. 4 - Rewrite the definitions of the methods getDay and...Ch. 4 - Rewrite the method getMonth in Display 4.2 using...Ch. 4 - In the definition of precedes in Display 4.7, we...Ch. 4 - Prob. 14STECh. 4 - Following the style guidelines given in this book,...Ch. 4 - Prob. 16STECh. 4 - List all the accessor methods in the class...Ch. 4 - List all the mutator methods in the class...Ch. 4 - Write a better version of the method dateOK with...Ch. 4 - What is the signature of each of the following...Ch. 4 - Prob. 21STECh. 4 - Prob. 22STECh. 4 - Prob. 23STECh. 4 - If a class is named CoolClass, what names are...Ch. 4 - Suppose you have defined a class such as the...Ch. 4 - What is a no-argument constructor? Does every...Ch. 4 - What would be the last line in the dialogue in...Ch. 4 - What would be the last line in the dialogue in...Ch. 4 - Write a program that outputs a certain coded...Ch. 4 - Prob. 2PPCh. 4 - Define a class called Journal that could be used...Ch. 4 - Define a class called WordCount whose objects...Ch. 4 - Write a grading program for a class with the...Ch. 4 - Prob. 7PPCh. 4 - Redefine the class Date in Display 4.13 so that...Ch. 4 - Define a class whose objects are records on animal...Ch. 4 - Prob. 10PPCh. 4 - Prob. 11PPCh. 4 - This programming project extends Programming...Ch. 4 - Your Community Supported Agriculture (CSA) farm...Ch. 4 - A comma-separated values (CSV) file is a simple...Ch. 4 - Prob. 15PP
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
How do type declaration statements for simple variables affect the readability of a language, considering that ...
Concepts Of Programming Languages
Consider the adage Never ask a question for which you do not want the answer. a. Is following that adage ethica...
Using MIS (10th Edition)
(Factorials) Factorials are used frequently in probability problems. The factorial of a positive integer n (wri...
Java How To Program (Early Objects)
Describe a method that can be used to gather a piece of data such as the users age.
Web Development and Design Foundations with HTML5 (8th Edition)
Are the two definitions of the constructors given in Listing 8.14 an example of overloading or overriding?
Java: An Introduction to Problem Solving and Programming (8th Edition)
In the following exercises, write a program to carry out the task. The program should use variables for each of...
Introduction to Programming Using Visual Basic (10th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- This way, any class that implements the Visible interface can define its own behavior for making an object visible or invisible based on its specific requirements.Create the Priority Java interface, which has the methods setPriority and getPriority. A method for determining numerical priority among a group of objects should be defined by the interface. Create and implement a class named Task that represents a task that implements the Priority interface, such as one that is on a to-do list. To test some Task objects, construct a driver class.arrow_forwardusing python language Suppose a call center has three levels of employees—respondent, manager, and director. An incoming telephone call must first be allocated to a respondent who is free. If the respondent cannot handle the call, the call must be escalated to a manager. If the manager is occupied, then the call should be escalated to a director. Design your own classes and data structures for this problem. Implement a method dispatchCall() that assigns a call to the first available employee.arrow_forwardUsing JAVA Language Consider a Billing class that implements an interface Payable having a method getTotalPaymentAmount(). Besides this, you have a Doctor class with private instance variables (docID, docName, and docFee) and a public getDoc() method, Patient class with private instance variables (pName, pID, pDisease), Medicine class with private instance variables (medID, medName, medQty, medPrice), and MedicalTest class with private instance variables (testID, testName, testPrice). Each of these classes has the toString() method to display the information of its object. The Billing class is having "Has A" relationship with the other four classes (Doctor, Patient, Medicine, and MedicalTest) mentioned above. The getPaymentAmount() method of Billing class returns the total billing amount that includes doc fee, medicine cost, and medical test fee that a patient has to pay. After implementing these classes, you are required to do the following in the driver class: Create an ArrayList of…arrow_forward
- Implement the following tasks by using concepts of object-oriented programming (Java). i. Create a generic class with a type parameter that simulates drawing an item at random out of a box. This class could be used for simulating a random drawing. For example, the box might contain Strings representing names written on a slip of paper, or the box might contain Integers representing a random drawing for a lottery based on numeric lottery picks. Create an add method that allows the user of the class to add an object of the specified type along with an isEmpty method that determines whether or not the box is empty. Finally, your class should have a drawItem method that randomly selects an object from the box and returns it. If the user attempts to drawn an item out of an empty box, return null. Write a main method that tests your class.ii. The following is a short snippet of code that simulates rolling a 6-sided dice 100 times. There is an equal chance of rolling any digit from 1 to…arrow_forwardNow we want to create an Object oriented System for a shopping mall. It has Items with name, manufacturer and price. Provide constructors. Getters, setters, toString methods. We add several items to Store. For that create a store class having name and array of items, Provide Constructors, getters/setters and toString(), in addition you have to provide a method add which add new item to the array.arrow_forwardNow we want to create an Object oriented System for a shopping mall. It has Items with name, manufacturer and price. Provide constructors. Getters, setters, toString methods. We add several items to Store. For that create a store class having name and arraylist of items, Provide Constructors, getters/setters and toString(), in addition you have to provide a method add which add new item to the array. The main function that does these things looks as follows: Public static void main(Strings[] args) { Item shampoo2(“pantene”, “Procter & Gamble”,100), noodles(“Noodles”, “knorr”, 50); // add further items. Store abcSuperStore; abcSuperStore.add(shampoo2); abcSuperStore.add(noodles); … abcSuperStore.sale(shampoo2); a bcSuperStore.sale(noodles);arrow_forward
- In the module point.py Create class Point, with a constructor (initializer) method that takes two integers, x and completed this step, test case TO CanconstructPoint should succeed. Add a method move that takes two integer arguments, dx and dy. This method should increase self.x by dx and increase self.y by dy . (If dx or dy are and stores them as instance variables self.x and self.y. When you have negative, the result will be decreasing self.x and/or self.y.) When you have completed this step, test case T1 CanMovePoint should succeed. • Now test case T2 EqualMeansIdentical will be --. You can fix this by creating a method with the special name _eq which takes, in addition to self, another Point object. This method should return a boolean. If the x and y fields of the self object and the other Point object are equal, should return True, and otherwise, it should eq return False. Now you have defined Point objects that can be created, moved, and compared for equality. But if you print a…arrow_forwardMust 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_forwardjava Design an interface named Encryptor that has a single (abstract) method named encrypt with one String argument named message. The method should return a String (which will be the encrypted message). Design a class named EncryptorOne that implements the Encryptor interface, and with one int instance variable named shift. The constructor should have one parameter to initialize the shift. Implement the method encrypt so that each letter of the message sent as the argument (with lowercase letters) is shifted by the value in shift. For example, if shift is 3, a will be replaced by d, b will be replaced by e, c will be replaced by f, and so on with a wraparound (i.e. with shift 3, x will be replaced by a, y will be replaced by b, and z will be replaced by c). The method should return the modified version of the message. (HINT: The value of a character literal is the integer value of the character in the Unicode character set. So, adding an integer (say, shift) to a character and…arrow_forward
- In this example, a Computer object keeps track of its amount of RAM and its OS version. It also has methods for upgrading the RAM and updating the OS. Two classes, a desktop computer, and a Phone, extend this class and implement its methods. A ComputerUpgrader object claims to be able to upgrade any Computer (that is, add more RAM and update the OS), but it really can't add more RAM to a phone, so it must check to make sure the Computer object it has been given isn't a Phone. This violates the ___ SOLID principle (chose the single best answer). Choose ADP OCP LSP ISP or DIP The Single Responsibility Principle (SRP)The Open-Closed Principle (OCP)The Liskov Substitution Principle (LSP)The Interface Segregation Principle (ISP)The Dependency Inversion Principle (DIP)arrow_forwardANSWER IN JAVA 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.arrow_forwardLanguage - Java Create a utility class called DuplicateCounter. Create an instance method called count that takes a single parameter called dataFile (representing the path to a text file) and uses a Map of Strings to count how many times each word occurs in dataFile. The counts should be stored in an instance variable called wordCounter. Create an instance method called write that takes a single parameter called outputFile (representing the path to a text file) and writes the contents of wordCounter to the file pointed to by outputFile. The output file should be overwritten if it already exists, and created if it does not exist. Create a separate class called Application that contains a main method which illustrates the use of DuplicateCounter by calling both the remove and write methods. Your input file must be called problem2.txt and your output file must be called unique_word_counts.txarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
6 Stages of UI Design; Author: DesignerUp;https://www.youtube.com/watch?v=_6Tl2_eM0DE;License: Standard Youtube License