Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
6th Edition
ISBN: 9780134477367
Author: David J. Barnes, Michael Kolling
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 4, Problem 42E
Program Plan Intro
Question reference:Â Refer to chapter 4, exercise 4.42 to complete the join method, add membership objects to the club object, and call the numberOfMembers method on the club object.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Design a GUI for Book view class for the following Library Information System, which you have worked on 1 with the following details:
Library Item Class Design and TestingDesign a class that holds the Library Item Information, with item name, author, publisher. Write appropriate accessor and mutator methods. Also, write a tester program that creates three instances/objects of the Library Items class.
Extending Library Item Class (Library and Book Classes):
Extend the Library Item class in (1) with a Book class with data attributes for a book’s title, author, publisher and an additional attributes as number of pages, and a Boolean data attribute indicating whether there is both hard copy as well as eBook version of the book. Demonstrate Book Class in a Tester Program with an object of Book class.
Modified Circle class and test file:
Add a new attribute for color (or any other new attribute)
Add get/set methods for this new instance variable, including data validation in set method (assuming background is black, i.e. circle color can't be black, reset to any non-black color if black is entered ).
Add a new constructor to pass the color attribute as an argument.
Add an instance method to display all properties of a Circle object.
Create 2 objects using different constructors in test file, with invalid data. Use this test java file
test java file:
class CircleTest{ public static void main(String[] args){ int num = 10; Circle c1 = new Circle(0.001); Circle c2 = new Circle("black", -9); c1.display(); c2.display(); c1.setRadius( -1); c1.setColor("black"); c1.display(); }}
Overview:
A new bank wants to make a simple application to keep track of all accounts and transactions.
it is required to help the bank manager implement the required application.
Requirements:
After a quick meeting with the bank manager, you got the following information:
• tis required to store all bank accounts in one collection and all the transactions happened
in another collection.
Each account has a unique account number, a holder and balance. There is a specific prefix
(common for all accounts) that should be added to the holder's civil id to create the unique
account number. In addition, it is not allowed for a holder to have more than one account.
Furthermore, only three transactions are allowed on any account: deposit, withdrawal and
transfer money to another account.
• Each holder has a unique civil ID (national id), a name and other attributes (add at least 2
attributes from your choice).
• For each transaction, it is required to store the account(s) affected, amount of…
Chapter 4 Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Ch. 4 - Prob. 1ECh. 4 - What happens if you create a new MusicOrganizer...Ch. 4 - Prob. 3ECh. 4 - Prob. 4ECh. 4 - Write a declaration of a local variable called...Ch. 4 - Prob. 6ECh. 4 - Write assignments to the library, cs101. and track...Ch. 4 - If a collection stores 10 objects, what value...Ch. 4 - Write a method call using get to return the fifth...Ch. 4 - Prob. 10E
Ch. 4 - Write a method call to add the object held in the...Ch. 4 - Write a method call to remove the third object...Ch. 4 - Suppose that an object is stored at index 6 in a...Ch. 4 - Add a method called checklndex to the...Ch. 4 - Write an alternative version of checkIndex called...Ch. 4 - Rewrite both the 1istFi1e and removeFi1e methods...Ch. 4 - Prob. 17ECh. 4 - Prob. 18ECh. 4 - We know that the first file name is stored at...Ch. 4 - Prob. 20ECh. 4 - Create a MusicOrganizer and store a few file names...Ch. 4 - Create an ArrayList<String> in the Code Pad by...Ch. 4 - If you wish, you could use the debugger to help...Ch. 4 - Challenge exercise The for-each loop does not use...Ch. 4 - Prob. 25ECh. 4 - Prob. 26ECh. 4 - Prob. 27ECh. 4 - Write out the header of a for-each loop to process...Ch. 4 - Suppose we express the first version of the key...Ch. 4 - Write a while loop (for example, in a method...Ch. 4 - Write a while loop to add up the values 1 to 10...Ch. 4 - Write a method called sum with a while loop that...Ch. 4 - Challenge exercise Write a method isPrime (int n)...Ch. 4 - In the findFirst method, the loop's condition...Ch. 4 - Prob. 35ECh. 4 - Have the MusicOrganizer increment the play count...Ch. 4 - Prob. 37ECh. 4 - Prob. 38ECh. 4 - Prob. 39ECh. 4 - Prob. 40ECh. 4 - Complete the numberOfMembers method to return the...Ch. 4 - Prob. 42ECh. 4 - Prob. 43ECh. 4 - Prob. 44ECh. 4 - Challenge exercise Write a method to play every...Ch. 4 - Prob. 46ECh. 4 - Prob. 47ECh. 4 - Add a close method to the Auction class. This...Ch. 4 - Add a getUnsold method to the Auction class with...Ch. 4 - Suppose the Auction class includes a method that...Ch. 4 - Rewrite getLot so that it does not rely on a lot...Ch. 4 - Prob. 52ECh. 4 - Prob. 53ECh. 4 - Prob. 54ECh. 4 - Prob. 55ECh. 4 - Open the products project and complete the...Ch. 4 - Implement the findProduct method. This should look...Ch. 4 - Implement the numberInStock method. This should...Ch. 4 - Prob. 59ECh. 4 - Challenge exercise Implement a method in...Ch. 4 - Java provides another type of loop: the do-while...Ch. 4 - Prob. 85ECh. 4 - Prob. 86ECh. 4 - Find out about Java's switch-case statement. What...
Knowledge Booster
Similar questions
- PyCharm Programming! A Game object knows its name and the number of avators is currently has. It is initialized without Avatars objects. It has a method startGame, which initializes an internal empty list of Avator objects. It has a method to add one Avator object at a time to the Game. It also has a method to remove an Avatar object by the Avatar’s name. A Game object also has a method to animate all its current Avatar objects. Furthermore, it has a method to stopGame, which destroys all current Avator objects in its internal list. The Avatar class creates simple human-type Avatars, which have attributes such as name, hair color, height, superpower. An Avatar object can change its hair color and superpower. It also has a method that “animates” the avatar. The animate() method should simply be a print message such as “Hello! I am …! I have…. hair and my super power is….!”, using the Avatar’s object variables. In main program, create 3 different Avatar objects that resemble 3…arrow_forwardA field has access that is somewhere between public and private. static final Opackage Oprotectedarrow_forwardRectangle Object Monitoring Create a Rectangle class that can compute the total area of all the created rectangle objects using static fields (variables). Remember that a Rectangle has two attributes: Length and Width. Implement the class by creating a computer program that will ask the user about three rectangle dimensions. The program should be able to display the total area of the three rectangle objects. For this exercise, you are required to apply all OOP concepts that you learned in class. Sample output: Enter Length R1: 1 Enter Width R1: 1 Enter Length R2: 2 Enter Width R2: 2 Enter Length R3: 3 Enter Width R3: 3 The total area of the rectangles is 14.00 Note: All characters in boldface are user inputs.arrow_forward
- Customer This class should now implement the Comparable interface. Customer instances should be ordered by their last name, then first name, and finally the name of their associated building. toString() - Add this method that returns a String with the following format: <lastName>, <firstName> Reading This class should now implement the Comparable interface. Reading instances should be ordered by their timestamp. XmlHandler The following methods should be updated: startElement() - The handler logic should be modified such that it can now create and associate Customer, Building, Room, Device, and Reading objects. endElement() - Modify this method such that the current customer instance is added to the ArrayList of customers when a closing customer element is encountered. No hand written and fast answer pleasearrow_forwardChallenge exercise The following object creation will result in the constructor of the Date class being called. Can you write the constructor’s header? new Date("March", 23, 1861) Try to give meaningful names to the parametersarrow_forwardDesign a class named CustomerRecord that holds a customer number, name, and address. Include separate methods to 'set' the value for each data field using the parameter being passed. Include separate methods to 'get' the value for each data field, i.e. "return" the field's value. Pseudocode:arrow_forward
- The monkey class should look similar to the dog class.arrow_forwardClass Circle A Circle will have a radius. The class will be able to keep track of the number of Circle objects created. It will also hold the total of the circumferences of all the Circle objects created. It will allow a client to create a Circle, passing in a double value for the radius into the Circle constructor. If the value for the radius that is passed in is 0 or negative, then the radius will be set to a value of 999. The constructor should add 1 to the count of the number of Circles created. The constructor should call a method to calculate the circumference and then add the circumference for that object to an accumulator. In addition to the constructor, the Circle class must have the following methods that return a boolean value: isCongruent(Circle c) – Compares two Circle objects to determine if they are congruent (radii are equal). isValid() – the radius may not be 0 or negative. equals (Triangle t) – compares two Triangle objects…arrow_forwardClass Triangle ï A Triangle will have 3 sides. The class will be able to keep track of the number of Triangle objects created. It will also hold the total of the perimeters of all the Triangle objects created. ï It will allow a client to create a Triangle, passing in integer values for the three sides into the Triangle constructor. If the values for the sides that are passed in do not represent a valid Triangle (read below for the requirements for a Triangle to be valid) , then all sides will be set to a value of 1. The constructor should add 1 to the count of the number of Triangles created. The constructor should call a method to calculate the perimeter and then add the perimeter for that object to an accumulator. In addition to the constructor, the Triangle class must have the following methods that return a boolean value: isRight () - see note 1 below regarding Acute triangles. isAcute() - see note 1 below regarding Acute triangles. isObtuse() - see note…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT