package com.example.domain;

public class Box {

	// instance variables
	// default access modifier - accessible within the package only
	private double width;
	private double height;
	private double depth;
	private String name;

	public Box() {
		System.out.println("Box constructor executed...");
		width = 10;
		height = 10;
		depth = 10;
		name = "box";
	}

	// parameterized constructor
	public Box(double width, double height, double depth, String name) {
		System.out.println("Box parameterized constructor executed...");
		this.width = width;
		this.height = height;
		this.depth = depth;
		this.name = name;
	}

	public double calculateVolume() {
		// calculate volume for box
		return width * height * depth;
	}

	public void display() {
		System.out.println("Width = " + width);
		System.out.println("Height = " + height);
		System.out.println("Depth = " + depth);
		System.out.println("Name = " + name);
		System.out.println();
	}

	// method that takes parameters
	public void setDimension(double width, double height, double depth, String name) {
		this.width = width;
		this.height = height;
		this.depth = depth;
		this.name = name;
	}

	@Override
	public String toString() {
		return "== Box Details ==\n" + "Name = " + name + "\n" + "Width = " + width + "\n" + "Height = " + height + "\n"
				+ "Depth = " + depth + "\n" + "Volume = " + calculateVolume() + "\n";
	}

	public double getWidth() {
		return width;
	}

	public void setWidth(double width) {
		this.width = width;
	}

	public double getHeight() {
		return height;
	}

	public void setHeight(double height) {
		this.height = height;
	}

	public double getDepth() {
		return depth;
	}

	public void setDepth(double depth) {
		this.depth = depth;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	// define a method that takes an object as parameter
	// java is strictly pass-by-value
	public void updateBox(Box box) {
		box.name = "Updated-" + box.name;
	}
}
