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 1, Problem 26E
Program Plan Intro
Question reference:Â Refer to the Chapter 1 Exercise 1.26 to call printList method on the object of LabClass.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Create an object of class LabClass. As the signature indicates, you need to specify the maximum number of students in that class (an integer).
Write down four more color constants that are available in the Color class. Refer to the class’s documentation to find out what they are.
In this exercise, you are going to build on your Circleclass from the previous exercise.
You are going to add 2 method, areaDifference and perimeterDifference. Both methods take a doubleradius of a second circle and return the difference from the current circle.
For example, if you create a Circle object with a radius of 4 and call areaDifference(3), you will return the diffence between the area of a circle with radius 4 and the area of a circle with a radius of 3. perimeterDifferencewould be the same.
Make sure you create at least one Circle and test and print the results of your methods.
given: public class Circle{private double radius;public Circle(double theRadius){radius = theRadius;}// Add a method called area that returns the area of a circle// using Math.PIpublic double area(){return Math.PI*radius*radius;}// Add a method called perimeter that returns the perimeter of a// circle using Math.PIpublic double perimeter(){return Math.PI*2*radius;}}
Chapter 1 Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Ch. 1 - Prob. 1ECh. 1 - Prob. 2ECh. 1 - Prob. 3ECh. 1 - Prob. 4ECh. 1 - This is a very simple example, and not many colors...Ch. 1 - Prob. 6ECh. 1 - Prob. 7ECh. 1 - Prob. 8ECh. 1 - Prob. 9ECh. 1 - Select Show Terminal from the View menu. This...
Ch. 1 - Select Show Code Pad from the View menu. This...Ch. 1 - Prob. 12ECh. 1 - Prob. 13ECh. 1 - Prob. 14ECh. 1 - Look at the pop-up menu of class Picture again....Ch. 1 - In the source code of class Picture, find the part...Ch. 1 - Add a second sun to the picture. To do this, pay...Ch. 1 - Prob. 18ECh. 1 - Prob. 19ECh. 1 - Prob. 20ECh. 1 - Create an object of class Student. You will notice...Ch. 1 - Prob. 22ECh. 1 - Prob. 23ECh. 1 - Call the numberOfStudents method of that class....Ch. 1 - Look at the signature of the enrollStudent method....Ch. 1 - Prob. 26ECh. 1 - Prob. 27ECh. 1 - Prob. 28ECh. 1 - Prob. 29ECh. 1 - In this chapter we have mentioned the data types...Ch. 1 - What are the types of the following values?...Ch. 1 - Prob. 32ECh. 1 - Write the header for a method named send that has...Ch. 1 - Prob. 34ECh. 1 - Prob. 35ECh. 1 - Prob. 36E
Knowledge Booster
Similar questions
- In this exercise, you are going to build on your Circleclass from the previous exercise. You are going to add 2 method, areaDifference and perimeterDifference. Both methods take a doubleradius of a second circle and return the difference from the current circle. For example, if you create a Circle object with a radius of 4 and call areaDifference(3), you will return the diffence between the area of a circle with radius 4 and the area of a circle with a radius of 3. perimeterDifferencewould be the same. Make sure you create at least one Circle and test and print the results of your methods. in javaarrow_forwardCreate some Student objects. Call the getName method on each object. Explain what is happening.arrow_forwardWrite a program that asks the user for two points (x, y) and use them to create two Point2D objects. Then, use the methods in the Point2D class to determine and display the distance between the two points and the midpoint between the two points.arrow_forward
- Complete MyProgram such that you can test all conditions In the Theater constructor you need to instantiate each seat object based upon the information passed to the constructor, making sure they are available. In the reassign method, make sure the from and to seat assignments are within range and return false if not. There is test cases included with this exercise, so when you submit your screenshot, it needs to show the test cases passed.arrow_forwardOpen the clock-display project and create a ClockDisplay object by selecting the following constructor: new ClockDisplay() Call its getTime method to find out the initial time the clock has been set to. Can you work out why it starts at that particular time?arrow_forwardUpdate it to create a class Student that includes four properties: an id (type Integer), a name (type String), a Major (type String) and a Grade (type Double). Use class Student to create objects (using buttonAdd) that will be read from the TextFields then save it into an ArrayList. Perform the following queries on the ArrayList of Student objects and show the results on the listViewStudents (Hint: add buttons as needed): d) Use lambdas and streams to calculate the total average of all Students grades, then show the result. 1. Ch3HW; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; public class MainApp extends Application{ @Override publicvoidstart(StageprimaryStage) throwsException { FXMLLoader loader =newFXMLLoader(getClass().getResource("StudentScreen.fxml")); Parent parent = loader.load(); Scene scene =newScene(parent);…arrow_forward
- Update it to create a class Student that includes four properties: an id (type Integer), a name (type String), a Major (type String) and a Grade (type Double). Use class Student to create objects (using buttonAdd) that will be read from the TextFields then save it into an ArrayList. Perform the following queries on the ArrayList of Student objects and show the results on the listViewStudents (Hint: add buttons as needed): d) Use lambdas and streams to calculate the total average of all Students grades, then show the result. e) Use lambdas and streams to group Students by major, then show the results. 1. Ch3HW; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; public class MainApp extends Application{ @Override publicvoidstart(StageprimaryStage) throwsException { FXMLLoader loader…arrow_forwardAdd the purple code to your Main Code Section (type it by hand if you get weird errors). It will call the object’s monitorLevels() method, which we will create in this sprint: userInput = 99while userInput != 0:checkerObj.displayList()userInput = checkerObj.displayMenu()if(userInput == 1):checkerObj.addLevel()checkerObj.writeLevelsToFile() # Write levelsList to LevelsFileelif(userInput == 2):checkerObj.removeLevel()checkerObj.writeLevelsToFile() # Write levelsList to LevelsFileelif(userInput == 3):checkerObj.removeAllLevels()checkerObj.writeLevelsToFile() # Write levelsList to LevelsFileelif(userInput == 4):checkerObj.updateMenuPrice() elif(userInput == 5):userInput = 0 # prevent the app from continuing if the user pressed Ctrl+C to stop itcheckerObj.monitorLevels()arrow_forwardQ2. In the ClockDisplay example, create a NumberDisplay object with limit 80 in the Code Pad by typing NumberDisplay nd = new NumberDisplay(80); Then call its getValue(), setValue(int value), and increment() methods in the Code Pad.arrow_forward
- Currently, there are two draw rectangle methods in the DoodleController class. Since two different turtles need to draw a rectangle, create a draw rectangle method in the DoodleTurtle class that will take the width and height of the rectangle as parameters and draw a rectangle of the specified size. The size will be the number of steps by the turtle. With the new method introduced, the calls to drawRectangleWithLittleTurtle and drawRectangleWithBigTurtle can be replaced with a call to the turtle’s drawRectangle method passing in the desired size of the rectangle. Refactor the DoodleController accordingly. Note: When you are done with the refactoring the drawRectangleWithLittleTurtle and drawRectangleWithBigTurtle method in the DoodleController need to be deleted. After this refactoring, do not move on until you verify the program works as it did before.arrow_forwardCreate new method in the Rectangle class called getArea to calculate the area of the rectangle. Call getArea method from the LengthWidthDemo class to print the area. In JAVA Programming pleasearrow_forwardAn archery target consists of a central circle of yellow surrounded by con-centric rings of red, blue, black and white. Each ring has the same width, which is the same as the radius of the yellow circle. Write a programthat draws such a target. Hint: Objects drawn later will appear on top ofobjects drawn earlier.arrow_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