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

IN JAVA. 3 Implement an Item class It should contain the following PRIVATE data:

ID: 3700668 • Letter: I

Question

IN JAVA.

3 Implement an Item class It should contain the following PRIVATE data: Page 2 of 9 String name (default: " (empty String)) double weight (default: 0) It should have the following PUBLIC methods: Constructor that takes no arguments Constructor that takes name and weight (in that order) Getter method: String getName) Getter method: double get Weight) String toString Override toString) to return a String with the following format: Example: if name- "Spoon" and weight - 2: Name: Spoon Weight: 2

Explanation / Answer

Item.java

public class Item {

private String name;

private double weight;

public Item() {

name="";

weight=0;

}

public Item(String name, double weight) {

this.name = name;

this.weight=weight;

}

public String getName() {

return name;

}

public double getWeight() {

return weight;

}

public String toString() {

return "Name: "+name+" Weight: "+weight;

}

}