Coverage Summary for Class: TowerComponent (it.polimi.ingsw.Client.GUI.Components)
| Class | Method, % | Branch, % | Line, % |
|---|---|---|---|
| TowerComponent | 0% (0/1) | 0% (0/5) | 0% (0/10) |
| TowerComponent$1 | 0% (0/1) | 0% (0/1) | |
| Total | 0% (0/2) | 0% (0/5) | 0% (0/11) |
1 package it.polimi.ingsw.Client.GUI.Components; 2 3 import it.polimi.ingsw.Model.Enums.TowerColour; 4 5 import javax.swing.*; 6 import java.awt.*; 7 8 import static it.polimi.ingsw.Client.GUI.IconLoader.*; 9 10 public class TowerComponent extends JButton { 11 /** 12 * Create a new JButton tower as icon 13 * 14 * @param tower tower's colour 15 * @param amount towers' multiplicity 16 */ 17 public TowerComponent(TowerColour tower, int amount) { 18 //set icon basing on tower's colour 19 switch (tower) { 20 case BLACK -> this.setIcon(BlackTower); 21 case GRAY -> this.setIcon(GrayTower); 22 case WHITE -> this.setIcon(WhiteTower); 23 } 24 //write eventual multiplicity beside the JButton 25 if (amount > 1) { 26 this.setText("x" + amount); 27 this.setHorizontalTextPosition(SwingConstants.RIGHT); 28 Font font = new Font("SansSerif", Font.BOLD, 13); 29 this.setFont(font); 30 } 31 } 32 }