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
/
Tool.java
85 lines (73 loc) · 1.83 KB
/
Tool.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
85
import java.util.*;
/**
* Superclass for the ElectricTool and HandTool classes
*
* @author George Broadley
* @version 1.0.0
*/
public abstract class Tool extends ShopItem
{
// instance variables
private int timesBorrowed;
private boolean onLoan;
private int weight;
/**
* Constructor for the Tool class
*
* @param timesBorrowed
* @param onLoan
* @param weight
*/
public Tool(String itemName, String itemCode, int timesBorrowed, boolean onLoan, int cost, int weight)
{
super(itemName, itemCode, cost);
this.timesBorrowed = timesBorrowed;
this.onLoan = onLoan;
this.weight = weight;
}
public Tool() {}
/**
* Prints the default data that is shared between each tool type.
*/
public void printDetails()
{
super.printDetails();
System.out.printf("%-25s: %s\n", "Times Borrowed", timesBorrowed);
System.out.printf("%-25s: %s\n", "On Loan", onLoan);
System.out.printf("%-25s: %sg\n", "Weight", weight);
}
public void extractData(Scanner fieldScanner)
{
timesBorrowed = fieldScanner.nextInt();
onLoan = fieldScanner.nextBoolean();
super.extractData(fieldScanner);
weight = fieldScanner.nextInt();
}
/**
* Getters and Setters below
*/
public int getTimesBorrowed()
{
return timesBorrowed;
}
public boolean isOnLoan()
{
return onLoan;
}
public int getWeight()
{
return weight;
}
public void setTimesBorrowed(int timesBorrowed)
{
this.timesBorrowed = timesBorrowed;
}
public void setOnLoan(boolean onLoan)
{
this.onLoan = onLoan;
}
public void setWeight(int weight)
{
this.weight = weight;
}
}