Here is an incomplete definition for a class called Basket: public class Basket { private int radius; private String material; private double price; } Write an accessor and mutator method for each of the class member variables.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

For this questions, your answer only needs to include exactly what the question asks for - you do not have to complete program if the question doesn't specify it. 

assembly language x86

Here is an incomplete definition for a class called Basket:

```java
public class Basket {
    private int radius;
    private String material;
    private double price;
}
```

**Task:**

Write an accessor and mutator method for each of the class member variables.

**Explanation:**

The class `Basket` has three private member variables:

1. `radius`: An integer that represents the radius of the basket.
2. `material`: A string that represents the material of the basket.
3. `price`: A double that represents the price of the basket.

**Objective:**

- Create accessor (getter) methods to retrieve each of the private variables.
- Create mutator (setter) methods to modify each of the private variables.
Transcribed Image Text:Here is an incomplete definition for a class called Basket: ```java public class Basket { private int radius; private String material; private double price; } ``` **Task:** Write an accessor and mutator method for each of the class member variables. **Explanation:** The class `Basket` has three private member variables: 1. `radius`: An integer that represents the radius of the basket. 2. `material`: A string that represents the material of the basket. 3. `price`: A double that represents the price of the basket. **Objective:** - Create accessor (getter) methods to retrieve each of the private variables. - Create mutator (setter) methods to modify each of the private variables.
Expert Solution
Step 1: Introduction

Accessor/ get method/getter: it returns a property of the object. It is declared as public. The naming scheme is to add get to the start of the method name. The return data type is same as of the private variable, for which it is designed.

Mutators/ set method/ setter: sets a property of the object. It is declared as public. The naming scheme is to add a word to set at the start of the method name. It does not have any return type but accepts a parameter of the same data type depending on the private field.  

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Class
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.
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education