-
Notifications
You must be signed in to change notification settings - Fork 0
/
Country.pde
104 lines (83 loc) · 2.45 KB
/
Country.pde
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
/**
* This Class represents a country's attributes
*
* @author Olivier Niklaus
* @version 12.11.2017
**/
class Country{
// initialise variables
public String cname;
public int wine, beer, spirits;
public Float lifeyears, totalc;
/**
* Constructor for Objects Country
*/
public Country(String cname, int wine, int beer, int spirits, Float totalc, Float lifeyears){
this.cname = cname;
this.wine = wine;
this.beer = beer;
this.spirits = spirits;
this.totalc = totalc;
this.lifeyears = lifeyears;
}
/**
* empty Constructor
*/
public Country(){ }
/**
* Constructor with input other Country
*/
public Country(Country c){
this.cname = c.getName();
this.wine = c.getWine();
this.beer = c.getBeer();
this.spirits = c.getSpirits();
this.totalc = c.getTotalc();
this.lifeyears = c.getLifeyears();
}
/**
* Getter and setter methods
*/
public String getName(){
return this.cname; }
public int getWine(){
return this.wine; }
public int getBeer(){
return this.beer; }
public int getSpirits(){
return this.spirits; }
public Float getTotalc(){
return this.totalc; }
public Float getLifeyears(){
return this.lifeyears; }
/**
*Getter Methods to access Attribute by number
*Input is a float number
*Attention of Casts form integer rto float!!
*/
public Float getCountryAttribute(int i){
float attribute;
if (i == 0.0) {attribute = this.lifeyears;
return attribute;}
if (i == 1.0) {attribute = (float) this.beer;
return attribute;}
if (i == 2.0) {attribute = (float) this.wine;
return attribute;}
if (i == 3.0) {attribute = (float) this.spirits;
return attribute;}
else {attribute = this.totalc;}
return attribute;
}
public void setName(String cname){
this.cname = cname; }
public void setWine(int wine){
this.wine = wine; }
public void setBeer(int beer){
this.beer = beer; }
public void setSpirits( int spirits){
this.spirits = spirits; }
public void setTotalc(Float totalc){
this.totalc = totalc; }
public void setLifeyears(Float lifeyears){
this.lifeyears = lifeyears; }
}