-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndustryButton.java
More file actions
executable file
·59 lines (55 loc) · 1.42 KB
/
IndustryButton.java
File metadata and controls
executable file
·59 lines (55 loc) · 1.42 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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* IndustryButton Class
*
* @author Jimmy, Adrian, Daniel
* @version April 24, 2024
*/
public class IndustryButton extends Button {
private GreenfootImage image;
private GreenfootImage imageSelected;
private int type;
protected boolean toggleState = false;
private String[] icons = {
"Manufacturing",
"Agriculture",
"Education",
"Energy",
"Forestry",
"Material",
"Technology",
"Recreation",
"UrbanDev"
};
/**
* Constructor for IndustryButton
*
* @param type The index of the corresponding Industry
*/
public IndustryButton(int type) {
super(true);
this.type = type;
image = new GreenfootImage("images/industry/" + icons[type] + "1.png");
imageSelected = new GreenfootImage("images/industry/" + icons[type] + "Selected.png");
image.scale(128, 128);
imageSelected.scale(128, 128);
setImage(image);
}
/**
* Act - do whatever the IndustryButton wants to do. This method is called whenever the 'Act' or
* 'Run' button gets pressed in the environment.
*/
public void act() {
// Add your action code here.
}
/** Sets image and value for variable if it is toggled on/off */
public void toggle() {
if (toggleState) {
toggleState = false;
setImage(image);
} else {
toggleState = true;
setImage(imageSelected);
}
}
}