-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCard.java
More file actions
106 lines (94 loc) · 2.2 KB
/
Card.java
File metadata and controls
106 lines (94 loc) · 2.2 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/**
* This class creates card objects.
* @Michael Chadwick
* @4/8/2020
*/
import java.util.*;
public class Card implements Comparable<Card>
{
private String type;
private char color;
private int cNum;
/**
* Default constructor for objects of class Card.
*/
public Card()
{
}
/**
* Constructs a new card object with the passed values
* @param type, color, cNum - the card's type, color, and collectors number.
*/
public Card(String type, char color, int cNum)
{
this.type = type;
this.color = color;
this.cNum = cNum;
}
/**
* Gets the cards type.
* @return type - returns the card's type.
*/
public String getType()
{
return this.type;
}
/**
* Sets the cards type.
* @param type - sets the cards type.
*/
public void setType(String type)
{
this.type = type;
}
/**
* Gets the cards color.
* @return color - returns the card's color.
*/
public char getColor()
{
return this.color;
}
/**
* Sets the cards color.
* @param color - sets the cards color.
*/
public void setColor(char color)
{
this.color = color;
}
/**
* Gets the card's collectors number.
* @return cNum - returns the card's collectors number.
*/
public int getCNum()
{
return this.cNum;
}
/**
* Sets the card's collectors number.
* @param cNum - sets the cards collectors number.
*/
public void setCNum(int cNum)
{
this.cNum = cNum;
}
/**
* Compares a two cards in the linked list for validity.
* @param otherCard - copmares it's collectors number with the other cards.
* @return cNum - returns the card's collectors number minus the compared card.
*/
@Override
public int compareTo(Card otherCard)
{
return cNum - otherCard.cNum;
}
/**
* Formats a card'd values in columnar form.
* @return String - formats and returns the card's values.
*/
public String toString()
{
return String.format("%8d %-15s %-8c",cNum, type, color);
}
}