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 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
|
public class User
{
private int Code;
private String Nom;
private String Prenom;
private int Age;
private String Type;
private ArrayList<DvdFilm> Home=new ArrayList<DvdFilm>();
private ArrayList<DvdFilm> Charriot=new ArrayList<DvdFilm>();
private int NbrDVD=0;
private int NbrDVDMax=0;
private int Duree=1;
private int penalite=10;
private String TypeAbonnement;
private java.util.Date DateDebutAbonnement;
private GregorianCalendar date;
public User(int code, String prenom, String nom, int age)
{
Code=code;
Prenom=prenom;
Nom=nom;
Age=age;
Home=new ArrayList<DvdFilm>();
remplirHome();
}
public void Reinitialiser()
{
Nom="";
Prenom="";
Age=0;
Home.clear();
Charriot.clear();
Code=0;
NbrDVDMax=1;
Duree=1;
penalite=10;
TypeAbonnement="";
}
public String tonNom()
{
String nom=Prenom+" "+Nom;
return nom;
}
public void AjCharriot(DvdFilm media)
{
Charriot.add(media);
}
public void remplirCharriot()
{
}
@SuppressWarnings("unchecked")
public void remplirHome()
{
Statement stmt=null;
try
{
stmt = Main.getConnection().createStatement();
System.out.println("SELECT CodeTransaction, CodeDVD,dvd.codeFilm,film.titre" +
" FROM emprunt,dvd,film " +
" WHERE emprunt.CodeClient="+Code+
" AND codeDVD=dvd.CodeDVD " +
" AND dvd.CodeFilm=film.CodeFilm");
ResultSet resultat=stmt.executeQuery("SELECT CodeTransaction, emprunt.CodeDVD, dvd.codeFilm, film.titre" +
" FROM emprunt,dvd,film " +
" WHERE (emprunt.CodeClient="+Code+
") AND (emprunt.codeDVD=dvd.CodeDVD) " +
" AND (dvd.CodeFilm=film.CodeFilm)");
while (resultat.next())
{
System.out.println("Resultat: codeTransaction"+resultat.getInt(1) +" codeDVD"+ resultat.getInt(2)+" codefilm "+resultat.getInt(3)+" Titre"+resultat.getString(4));
Home.add(new DvdFilm(resultat.getInt(1),resultat.getInt(2),resultat.getInt(3),resultat.getString(4)));
}
}
catch (SQLException e)
{
e.printStackTrace();
}
}
public void LoadSettings()
{
Statement stmt;
try
{
stmt = Main.getConnection().createStatement();
ResultSet resultat=stmt.executeQuery("SELECT TypeAbonnement ,DateDebutAbonnement from client where codeclient="+Code);
resultat.next();
SetTypeAbonnement(resultat.getString(1));
SetDateDebutAbonnement(resultat.getDate(2));
}
catch (SQLException e)
{
e.printStackTrace();
}
}
public void SetTypeAbonnement(String typeAbonnement)
{
TypeAbonnement=typeAbonnement;
if (typeAbonnement=="Standard")
{
NbrDVDMax=3;
Duree=5;
}
else if (typeAbonnement=="Silver")
{
NbrDVDMax=3;
Duree=5;
}
else if (TypeAbonnement=="Gold")
{
NbrDVDMax=3;
Duree=5;
}
}
public void SetDateDebutAbonnement(java.util.Date dateDebutAbonnement)
{
DateDebutAbonnement=dateDebutAbonnement;
}
public ArrayList getCharriot()
{
return Charriot;
}
public ArrayList getHome()
{
return Home;
}
} |
Partager