Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Add methods to get and set all the instance variables. Finallywrite a test class

ID: 3618971 • Letter: A

Question

Add methods to get and set all the instance variables. Finallywrite a test class of this class.
class Box { private int height; private int width; private int length; Box() { height=width=length=10; } public int volume() { return length*width*height; } public void setHeight(int h) { height=h; } public int getLength() { return length; } }

class Box { private int height; private int width; private int length; Box() { height=width=length=10; } public int volume() { return length*width*height; } public void setHeight(int h) { height=h; } public int getLength() { return length; } }

Explanation / Answer

Here is the whole code AND the class tester ; Please rate /** * * @author http://www.javacoder.webs.com */ public class Main {     public static void main(String args[]) {         Box box = new Box();         box.setHeight(3);         box.setLength(5);         box.setWidth(5);        System.out.println(box.getHeight());        System.out.println(box.getLength());        System.out.println(box.getWidth());     } } class Box { private int height; private int width; private int length; Box() { height=width=length=10; } public int volume() { return length*width*height; } public int getHeight() {       return height; } public int getWidth() {       return width; } public int getLength() {       return length; } public void setHeight(int height) {       this.height = height; } public void setWidth(int width) {       this.width = width; } public void setLength(int length) {       this.length = length; } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote