This repository has been archived by the owner on Nov 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShopItem.java
85 lines (72 loc) · 1.67 KB
/
ShopItem.java
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
73
74
75
76
77
78
79
80
81
82
83
84
import java.util.*;
/**
* Superclass for the Tool and Accessory classes
*
* @author George Broadley
* @version 1.0.0
*/
public abstract class ShopItem
{
// instance variables
private String itemName;
private String itemCode;
private int cost;
/**
* Constructor for the ShopItem class
*
* @param itemName
* @param itemCode
* @param cost
*/
public ShopItem(String itemName, String itemCode, int cost)
{
this.itemName = itemName;
this.itemCode = itemCode;
this.cost = cost;
}
public ShopItem() {}
/**
* Prints the default data that is shared between each shop item.
*/
public void printDetails()
{
System.out.println("");
System.out.printf("%-25s: %s\n", "Item Name", itemName);
System.out.println("");
System.out.printf("%-25s: %s\n", "Item Code", itemCode);
System.out.printf("%-25s: £%.2f\n", "Cost", (float) cost / 100);
}
public void extractData(Scanner fieldScanner)
{
itemName = fieldScanner.next();
itemCode = fieldScanner.next();
cost = fieldScanner.nextInt();
}
/**
* Getters and Setters below
*/
public String getItemName()
{
return itemName;
}
public String getItemCode()
{
return itemCode;
}
public int getCost()
{
return cost;
}
public void setItemName(String itemName)
{
this.itemName = itemName;
}
public void setItemCode(String itemCode)
{
this.itemCode = itemCode;
}
public void setCost(int cost)
{
this.cost = cost;
}
}