-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathItem.java
More file actions
72 lines (64 loc) · 1.63 KB
/
Item.java
File metadata and controls
72 lines (64 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* Class Item - Represents an object that can be placed in a Room.
* Each Item has a name, a description, and a weight.
*
* @author Florian NELCHA
*/
public class Item
{
// ### Attributes ###
private String aName;
private String aDesc;
private double aWeight;
// ### Constructor ###
/**
* Constructs a new Item with the specified name, description, and weight.
*
* @param pName The name of the item.
* @param pDesc A detailed description of the item.
* @param pWeight The weight of the item.
*/
public Item(final String pName, final String pDesc, final double pWeight)
{
this.aName = pName;
this.aDesc = pDesc;
this.aWeight = pWeight;
} // Item()
// ### Getters ###
/**
* Gets the name of the item.
*
* @return The name of the item.
*/
public String getName()
{
return this.aName;
} // getName()
/**
* Gets the description of the item.
*
* @return The description of the item.
*/
public String getDescription()
{
return this.aDesc;
} // getDescription()
/**
* Gets the weight of the item.
*
* @return The weight of the item.
*/
public double getWeight()
{
return this.aWeight;
} // getWeight()
/**
* Returns a detailed string description of the item, including its weight.
*
* @return A formatted string describing the item.
*/
public String getItemString()
{
return "This is " + this.aDesc + " (Weight: " + this.aWeight + ")";
} // getItemString()
}