-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCarte.java
More file actions
57 lines (51 loc) · 1.58 KB
/
Carte.java
File metadata and controls
57 lines (51 loc) · 1.58 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
import javax.swing.*;
import javax.imageio.ImageIO;
import java.io.*;
import java.awt.*;
import java.awt.image.*;
public class Carte {
public String couleur;
public int valeur;
public String type;
public String pouvoir;
private Image image;
public Carte (int valeur, String couleur){
this.couleur=couleur;
this.valeur=valeur;
this.type= "chiffre";
this. pouvoir = "void";
String fileName=valeur +" "+couleur;
try{
BufferedImage img= ImageIO.read(new File("./images UNO/"+fileName+".png"));
image=img.getScaledInstance(125,185,java.awt.Image.SCALE_SMOOTH);
}catch (IOException ex){
System.out.println("IOException from cartes constructor"+ this.getCarte());
}
}
public Carte (){
}
public Carte (String type, String couleur){
this.couleur=couleur;
this.type=type;
this.pouvoir=type;
if (this.type=="+4"||this.type=="choixCouleur") valeur=50;
if (this.type=="+2"||this.type=="passer"||this.type=="inverser") valeur=20;
String fileName=type +" "+couleur;
try{
BufferedImage img= ImageIO.read(new File( fileName+".png"));
image=img.getScaledInstance(125,185,java.awt.Image.SCALE_SMOOTH);
}catch (IOException ex){
System.out.println("IOException from cartes constructor" + this.getCarte());
}
}
public String getCarte (){
String s =("Je suis une carte de couleur " + this.couleur+ ", de type "+ this.type+ " et de valeur " + this.valeur +" et de pouvoir " + this.pouvoir);
return s;
}
public void dessine(Graphics g, int x, int y){
g.drawImage(image,x,y,null);
}
public String getCouleur(){
return this.couleur;
}
}