├── .gitignore
├── .project
├── BoiteAuxLettres
├── .classpath
├── .project
├── README.md
├── mail_model.png
└── src
│ ├── Boite.java
│ ├── Colis.java
│ ├── Courrier.java
│ ├── Lettre.java
│ ├── Poste.java
│ └── Publicite.java
├── BrainCells
├── .classpath
├── .gitignore
├── .project
├── README.md
├── brain_model.png
└── src
│ ├── .classpath
│ ├── .project
│ └── Position.java
├── Cryptographie
├── .classpath
├── .project
├── README.md
├── crypto_model.png
└── src
│ ├── ACle.java
│ ├── ACleAleatoire.java
│ ├── Cesar.java
│ ├── Codages.java
│ ├── Code.java
│ ├── Secret.java
│ ├── TableauCodage.java
│ └── Utils.java
├── Employees
├── .classpath
├── .gitignore
├── .project
├── README.md
├── employees.png
└── src
│ └── Salaires.java
├── Journey
├── .classpath
├── .gitignore
├── .project
├── README.md
├── journeyDiagramm.png
└── src
│ └── Voyage.java
├── Puissance4
├── .classpath
├── .gitignore
├── .project
├── README.MD
├── puissance4_model.jpg
├── screenShots
│ ├── end.png
│ ├── otherend.png
│ └── start.png
└── src
│ ├── Jeu.java
│ ├── JoueurHumain.java
│ ├── JoueurOrdi.java
│ ├── Joueurs.java
│ ├── Partie.java
│ └── Puissance4.java
├── README.md
└── Race
├── .classpath
├── .gitignore
├── .project
├── README.md
├── diagrammeCourse.png
└── src
└── Course.java
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 | # Log file
4 | *.log
5 | # BlueJ files
6 | *.ctxt
7 | # Mobile Tools for Java (J2ME)
8 | .mtj.tmp/
9 | # Package Files #
10 | *.jar
11 | *.war
12 | *.nar
13 | *.ear
14 | *.zip
15 | *.tar.gz
16 | *.rar
17 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
18 | hs_err_pid*
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | javaCourseraOOP
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/BoiteAuxLettres/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/BoiteAuxLettres/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | BoiteAuxLettres
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/BoiteAuxLettres/README.md:
--------------------------------------------------------------------------------
1 | # Mail
2 |
3 | ## Topic
4 |
5 | The principle of this program is to create a letter box that can contain either letters, packages or ads which are defined by the classes "Lettre", "Colis" and "Publicite". All those kind of mail objects inherit from a mother class called "Courrier" which means "mail".
6 |
7 | ## Description
8 |
9 | Every letter, package or ad has a weight, an adress and is "Express" or not which is defined by a boolean value.
10 | In addition to this, each package has a volume and each letter has a format. We are then able to say if one of these is "Valid" or not by defining some conditions on those attributs.
11 |
12 | For instance both letters and packages have to define an adress and packages can't have a larger volume than 50 cube cm.
13 |
14 | There is also the class Boite which contains an ArrayList of mails and there is the Poste which basically is the class that will test our entire code.
15 |
16 |
17 | ## Class Diagram
18 |
19 | 
20 |
21 |
22 |
--------------------------------------------------------------------------------
/BoiteAuxLettres/mail_model.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Vincent3112/javaCourseraOOP/e69e62d2a5cd15c425a31a6440f984dc8d8cb360/BoiteAuxLettres/mail_model.png
--------------------------------------------------------------------------------
/BoiteAuxLettres/src/Boite.java:
--------------------------------------------------------------------------------
1 | import java.util.ArrayList;
2 |
3 | public class Boite {
4 |
5 | private ArrayList listeCourrier;
6 |
7 | public Boite(int nbPersonnes) {
8 | listeCourrier = new ArrayList();
9 | }
10 |
11 | public void ajouterCourrier(Courrier courrier) {
12 | if (courrier != null) {
13 | listeCourrier.add(courrier);
14 | }
15 | }
16 |
17 | public double affranchir() {
18 | double montantTotal = 0;
19 | for (Courrier courrier : listeCourrier) {
20 | montantTotal += courrier.affranchirCourrier();
21 | }
22 | return montantTotal;
23 | }
24 |
25 | public void afficher() {
26 | for (Courrier courrier : listeCourrier) {
27 | courrier.afficher();
28 | }
29 | }
30 |
31 | public int courriersInvalides() {
32 | int nbrCourrierInvalide = 0;
33 | for (Courrier courrier : listeCourrier) {
34 | if (courrier.isNotValid == true) {
35 | nbrCourrierInvalide +=1;
36 | }
37 | }
38 | return nbrCourrierInvalide;
39 | }
40 | }
--------------------------------------------------------------------------------
/BoiteAuxLettres/src/Colis.java:
--------------------------------------------------------------------------------
1 | public class Colis extends Courrier{
2 |
3 | double volume;
4 | double prix;
5 |
6 | Colis(int poids, boolean isExpress, String adresse, int volume) {
7 | super(poids, isExpress, adresse);
8 | this.volume = volume;
9 | if (adresse == "") {
10 | isNotValid = true;
11 | }
12 | if (volume > 50) {
13 | isNotValid = true;
14 | }
15 | }
16 | public double getPrix() {
17 | if (isNotValid) {
18 | return prix;
19 | }
20 | else {
21 | return affranchirCourrier();
22 | }
23 | }
24 |
25 | public void afficher() {
26 | System.out.println("Colis");
27 | if (isNotValid) {
28 | System.out.println("(Courrier invalide)");
29 | }
30 | System.out.println(" Poids : " + poids + " grammes ");
31 | System.out.println(" Express : " + isExpress());
32 | System.out.println(" Destination : " + adresse);
33 | System.out.println(" Prix : " + getPrix() + " euros ");
34 | System.out.println(" Volume : " + volume);
35 | }
36 |
37 | public double affranchirCourrier() {
38 | double montant=0;
39 | montant = 0.5*volume + poids;
40 | if (isExpress) {
41 | montant = montant*2;
42 | }
43 | return montant/1000;
44 | }
45 | }
--------------------------------------------------------------------------------
/BoiteAuxLettres/src/Courrier.java:
--------------------------------------------------------------------------------
1 |
2 | public abstract class Courrier {
3 |
4 | int poids;
5 | boolean isExpress;
6 | String adresse;
7 | boolean isNotValid;
8 |
9 | Courrier(int poids, boolean isExpress, String adresse) {
10 | this.poids = poids;
11 | this.isExpress = isExpress;
12 | this.adresse = adresse;
13 | boolean isNotValid = false;
14 | if (adresse == "") {
15 | isNotValid = true;
16 | }
17 | }
18 |
19 | public String isExpress() {
20 | if (isExpress) {
21 | return "oui";
22 | }
23 | else {
24 | return "non";
25 | }
26 | }
27 | public abstract double affranchirCourrier();
28 |
29 |
30 | public void afficher() {
31 | }
32 | }
--------------------------------------------------------------------------------
/BoiteAuxLettres/src/Lettre.java:
--------------------------------------------------------------------------------
1 | public class Lettre extends Courrier{
2 |
3 | String format;
4 | double prix = 0;
5 |
6 | Lettre(int poids, boolean isExpress, String adresse, String format) {
7 | super(poids, isExpress, adresse);
8 | this.format = format;
9 | if (adresse == "") {
10 | isNotValid = true;
11 | }
12 | }
13 |
14 | public double getPrix() {
15 | if (isNotValid) {
16 | return prix;
17 | }
18 | else {
19 | return affranchirCourrier();
20 | }
21 | }
22 |
23 | public void afficher() {
24 | System.out.println("Lettre");
25 | if (isNotValid) {
26 | System.out.println("(Courrier invalide)");
27 | }
28 | System.out.println(" Poids : " + poids + " grammes ");
29 | System.out.println(" Express : " + isExpress());
30 | System.out.println(" Destination : " + adresse);
31 | System.out.println(" Prix : " + getPrix() + " euros ");
32 | System.out.println(" Format : " + format);
33 | }
34 |
35 | public double affranchirCourrier() {
36 | double prix=0;
37 | if (format == "A4") {
38 | prix = 2.5 + poids;
39 | }
40 | else {
41 | prix = 3.5 + poids;
42 | }
43 | if (isExpress) {
44 | prix = prix*2;
45 | }
46 | return prix/1000;
47 | }
48 | }
--------------------------------------------------------------------------------
/BoiteAuxLettres/src/Poste.java:
--------------------------------------------------------------------------------
1 | // PROGRAMME PRINCIPAL (A NE PAS MODIFIER)
2 | class Poste {
3 |
4 | public static void main(String args[]) {
5 | //Cr'eation d'une boite-aux-lettres
6 | // 30 est la capacit'e maximale de la
7 | // boite aux lettres
8 | // (pas necessaire si vous dêcidez d'utiliser
9 | // un ArrayList).
10 | Boite boite = new Boite(30);
11 |
12 | //Creation de divers courriers/colis..
13 | Lettre lettre1 = new Lettre(200, true, "Chemin des Acacias 28, 1009 Pully", "A3");
14 | Lettre lettre2 = new Lettre(800, false, "", "A4"); // invalide
15 |
16 | Publicite pub1 = new Publicite(1500, true, "Les Moilles 13A, 1913 Saillon");
17 | Publicite pub2 = new Publicite(3000, false, ""); // invalide
18 |
19 | Colis colis1 = new Colis(5000, true, "Grand rue 18, 1950 Sion", 30);
20 | Colis colis2 = new Colis(3000, true, "Chemin des fleurs 48, 2800 Delemont", 70); //Colis invalide !
21 |
22 | boite.ajouterCourrier(lettre1);
23 | boite.ajouterCourrier(lettre2);
24 | boite.ajouterCourrier(pub1);
25 | boite.ajouterCourrier(pub2);
26 | boite.ajouterCourrier(colis1);
27 | boite.ajouterCourrier(colis2);
28 |
29 | System.out.println("Le montant total d'affranchissement est de " +
30 | boite.affranchir());
31 | boite.afficher();
32 |
33 | System.out.println("La boite contient " + boite.courriersInvalides()
34 | + " courriers invalides");
35 | }
36 | }
--------------------------------------------------------------------------------
/BoiteAuxLettres/src/Publicite.java:
--------------------------------------------------------------------------------
1 | public class Publicite extends Courrier {
2 |
3 | double prix;
4 |
5 | Publicite(int poids, boolean isExpress, String adresse) {
6 | super(poids, isExpress, adresse);
7 |
8 | if (adresse == "") {
9 | isNotValid = true;
10 | }
11 | }
12 | public double getPrix() {
13 | if (isNotValid) {
14 | return prix;
15 | }
16 | else {
17 | return affranchirCourrier();
18 | }
19 | }
20 |
21 | public void afficher() {
22 | System.out.println("Pub");
23 | if (isNotValid) {
24 | System.out.println("(Courrier invalide)");
25 | }
26 | System.out.println(" Poids : " + poids + " grammes");
27 | System.out.println(" Express : " + isExpress());
28 | System.out.println(" Destination : " + adresse);
29 | System.out.println(" Prix : " + getPrix() + " euros ");
30 | }
31 |
32 | public double affranchirCourrier() {
33 | double montant=0;
34 | montant = 5*poids;
35 | if (isExpress) {
36 | montant = montant*2;
37 | }
38 | return montant/1000;
39 | }
40 | }
--------------------------------------------------------------------------------
/BrainCells/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/BrainCells/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/BrainCells/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Neurones
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/BrainCells/README.md:
--------------------------------------------------------------------------------
1 | # Brain cells connectivity
2 |
3 | ## Topic
4 |
5 | This assignment was about using pretty much everything that had been learned since the beginning of this course.
6 | It was about a brain that contains different cells with many behavior such as getting a stimulation from another brain cell with the recoitStimulus() method.
7 | Also the brain could create connection between its cells with the creerConnexion() method and then stimulate every single cell thanks to a *ad hoc* algorithm.
8 |
9 | The only thing that was a bit fun in the end is to code this *ad hoc* algorithm.
10 |
11 | ## Class diagram
12 |
13 | As usual, you can find my class diagram designed on MagicDraw.
14 |
15 | 
--------------------------------------------------------------------------------
/BrainCells/brain_model.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Vincent3112/javaCourseraOOP/e69e62d2a5cd15c425a31a6440f984dc8d8cb360/BrainCells/brain_model.png
--------------------------------------------------------------------------------
/BrainCells/src/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/BrainCells/src/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | src
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/BrainCells/src/Position.java:
--------------------------------------------------------------------------------
1 | import java.util.ArrayList;
2 |
3 | public class Position {
4 |
5 | double x;
6 | double y;
7 |
8 |
9 | Position(double x,double y){
10 | this.x = x;
11 | this.y = y;
12 | }
13 |
14 | Position(){
15 | x = 0;
16 | y = 0;
17 | }
18 |
19 | public double getX() {
20 | return x;
21 | }
22 |
23 | public double getY() {
24 | return y;
25 | }
26 |
27 | public String toString() {
28 | return "(" + x + ", " + y + ")";
29 | }
30 |
31 |
32 | }
33 |
34 | class Neurone {
35 |
36 | Position position;
37 | double signalInterne;
38 | double facteurAttenuation;
39 | ArrayList connexions = new ArrayList();
40 |
41 | Neurone(){
42 |
43 | }
44 |
45 | Neurone(Position position, double facteurAttenuation){
46 | this.position = position;
47 | this.facteurAttenuation = facteurAttenuation;
48 | signalInterne = 0;
49 | }
50 |
51 | public Position getPosition() {
52 | return position;
53 | }
54 |
55 | public int getNbConnexions() {
56 | return connexions.size();
57 | }
58 |
59 | public Neurone getConnexion(int index) {
60 | return connexions.get(index);
61 | }
62 |
63 | public double getAttenuation() {
64 | return facteurAttenuation;
65 | }
66 |
67 | public double getSignal() {
68 | return signalInterne;
69 | }
70 |
71 | public void connexion(Neurone n) {
72 | connexions.add(n);
73 | }
74 |
75 | public void recoitStimulus(double stimulus) {
76 | signalInterne = stimulus*facteurAttenuation;
77 | for(Neurone neurone : connexions) {
78 | neurone.recoitStimulus(signalInterne);
79 | }
80 | }
81 |
82 | public String toString() {
83 | if(connexions.size() == 0) {
84 | System.out.println("Le neurone en position " + position + " avec attenuation " + facteurAttenuation + " sans connexions");
85 | }
86 | else {
87 |
88 |
89 | System.out.println("Le neurone en position " + position + " avec attenuation " + facteurAttenuation + " en connexion avec :");
90 | for(Neurone neurone : connexions) {
91 | System.out.println(" - Un neurone en position " + neurone.getPosition());
92 | }
93 | }
94 | return "";
95 |
96 | }
97 |
98 | }
99 |
100 | class NeuroneCumulatif extends Neurone{
101 |
102 | NeuroneCumulatif(Position position, double facteurAttenuation){
103 | super(position , facteurAttenuation);
104 | }
105 |
106 | public void recoitStimulus(double stimulus) {
107 | signalInterne = signalInterne + stimulus*facteurAttenuation;
108 | for(Neurone neurone : connexions) {
109 | neurone.recoitStimulus(signalInterne);
110 | }
111 | }
112 |
113 | public double getSignal() {
114 | return signalInterne;
115 | }
116 | }
117 |
118 | class Cerveau{
119 |
120 | ArrayList cerveau = new ArrayList();
121 |
122 | Cerveau(){
123 |
124 | }
125 |
126 |
127 | public int getNbNeurones() {
128 | return cerveau.size();
129 | }
130 |
131 | public Neurone getNeurone(int index) {
132 | return cerveau.get(index);
133 | }
134 |
135 | public void ajouterNeurone(Position pos, double facteurAttenuation) {
136 | cerveau.add(new Neurone(pos, facteurAttenuation));
137 | }
138 |
139 | public void ajouterNeuroneCumulatif(Position pos, double facteurAttenuation) {
140 | cerveau.add(new Neurone(pos, facteurAttenuation));
141 | }
142 |
143 | public void stimuler(int index, double stimulus) {
144 | cerveau.get(index).recoitStimulus(stimulus);
145 | }
146 |
147 | public double sonder(int index) {
148 | return cerveau.get(index).getSignal();
149 | }
150 |
151 | public void creerConnexions() {
152 |
153 | int tailleCerveau = cerveau.size();
154 | int indiceCerveau = 0;
155 |
156 | cerveau.get(indiceCerveau).connexions.add(cerveau.get(indiceCerveau + 1));
157 | cerveau.get(indiceCerveau).connexions.add(cerveau.get(indiceCerveau + 2));
158 |
159 | indiceCerveau+=1;
160 |
161 | if (cerveau.size() != 0) {
162 | while (indiceCerveau < tailleCerveau - 2) {
163 | if (tailleCerveau >= indiceCerveau + 1) {
164 | cerveau.get(indiceCerveau).connexions.add(cerveau.get(indiceCerveau + 1));
165 | }
166 | if (tailleCerveau >= indiceCerveau + 2) {
167 | cerveau.get(indiceCerveau + 1).connexions.add(cerveau.get(indiceCerveau + 2));
168 | }
169 | indiceCerveau +=2;
170 | }
171 |
172 | }
173 | }
174 |
175 | public String toString() {
176 | System.out.println("Le cerveau contient " + cerveau.size() + " neurones");
177 | for(Neurone neurone : cerveau) {
178 | System.out.println(neurone);
179 | }
180 | return "";
181 | }
182 |
183 | }
184 |
185 |
186 | class SimulateurNeurone {
187 |
188 | public static void main(String[] args) {
189 | // TEST DE LA PARTIE 1
190 | System.out.println("Test de la partie 1:");
191 | System.out.println("--------------------");
192 |
193 | Position position1 = new Position(0, 1);
194 | Position position2 = new Position(1, 0);
195 | Position position3 = new Position(1, 1);
196 |
197 | Neurone neuron1 = new Neurone(position1, 0.5);
198 | Neurone neuron2 = new Neurone(position2, 1.0);
199 | Neurone neuron3 = new Neurone(position3, 2.0);
200 |
201 | neuron1.connexion(neuron2);
202 | neuron2.connexion(neuron3);
203 | neuron1.recoitStimulus(10);
204 |
205 | System.out.println("Signaux : ");
206 | System.out.println(neuron1.getSignal());
207 | System.out.println(neuron2.getSignal());
208 | System.out.println(neuron3.getSignal());
209 |
210 | System.out.println();
211 | System.out.println("Premiere connexion du neurone 1");
212 | System.out.println(neuron1.getConnexion(0));
213 |
214 |
215 | // FIN TEST DE LA PARTIE 1
216 |
217 | // TEST DE LA PARTIE 2
218 | System.out.println("Test de la partie 2:");
219 | System.out.println("--------------------");
220 |
221 | Position position5 = new Position(0, 0);
222 | NeuroneCumulatif neuron5 = new NeuroneCumulatif(position5, 0.5);
223 | neuron5.recoitStimulus(10);
224 | neuron5.recoitStimulus(10);
225 | System.out.println("Signal du neurone cumulatif -> " + neuron5.getSignal());
226 |
227 | // FIN TEST DE LA PARTIE 2
228 |
229 | // TEST DE LA PARTIE 3
230 | System.out.println();
231 | System.out.println("Test de la partie 3:");
232 | System.out.println("--------------------");
233 | Cerveau cerveau = new Cerveau();
234 |
235 | // parametres de construction du neurone:
236 | // la position et le facteur d'attenuation
237 | cerveau.ajouterNeurone(new Position(0,0), 0.5);
238 | cerveau.ajouterNeurone(new Position(0,1), 0.2);
239 | cerveau.ajouterNeurone(new Position(1,0), 1.0);
240 |
241 | // parametres de construction du neurone cumulatif:
242 | // la position et le facteur d'attenuation
243 | cerveau.ajouterNeuroneCumulatif(new Position(1,1), 0.8);
244 | cerveau.creerConnexions();
245 | cerveau.stimuler(0, 10);
246 |
247 | System.out.println("Signal du 3eme neurone -> " + cerveau.sonder(3));
248 | System.out.println(cerveau);
249 | // FIN TEST DE LA PARTIE 3
250 | }
251 | }
--------------------------------------------------------------------------------
/Cryptographie/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Cryptographie/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Cryptographie
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Cryptographie/README.md:
--------------------------------------------------------------------------------
1 | # Cryptography
2 |
3 | ## Topic
4 |
5 | This is a very interesting program about cryptography and more particularly the Ceasar Cipher.
6 |
7 | ## Description
8 |
9 | In this program we built 4 different kind of encrypting and decrypting systems. To do so we first defined an abstract class "Code" that will contain three important methods : affiche(), code() and decode(). Those methods will allow us to first display which encrypting system we are using and then the result of our encrypting system and decrypting system.
10 |
11 | Then we defined a class "ACle" which will actually define the process we use to encrypt and decrypt our messages using a key. This key will be a string composed of letters like "EQUINOXE" for instance.
12 |
13 | To process the encrypting, what we will do is change both the message and the key into a list of numbers which corresponds to their rank in tha alphabet. Then we will superimpose the message and the key so that there is no length problem (if the message length is greater than the key one, we will write the key another time and so on until it matches exactly the message length).
14 |
15 | After that make the sum of the two superimposed numbers and make it count back from 0 if it ever gets higher than this value. Like this we get a serie of number that we then transform into a string of letters following their rank into the alphabet just the opposite of the way we did before.
16 |
17 | At the end we get the encrypted message and display it.
18 |
19 | There are 2 different classes that use this method. One with a predefined key which is "EQUINOXE" and corresponds to the class "ACle" and one with a generated key which is the class "ACleAleatoire". This class is using both code() and decode() methods from the ACle class and defines a generateCle() method to generate the key.
20 |
21 | ## Ceasar Cipher
22 |
23 | In this chapter we also defined a class called Cesar that implements the Ceasar Cipher. It basically uses the code() method with a key that is one single letter and that is enough to produce a representation of a ceasar cipher.
24 |
25 |
26 |
27 | ## Class Diagram
28 |
29 | This diagram shows the global architecture of the program.
30 |
31 |
32 | 
--------------------------------------------------------------------------------
/Cryptographie/crypto_model.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Vincent3112/javaCourseraOOP/e69e62d2a5cd15c425a31a6440f984dc8d8cb360/Cryptographie/crypto_model.png
--------------------------------------------------------------------------------
/Cryptographie/src/ACle.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Vincent3112/javaCourseraOOP/e69e62d2a5cd15c425a31a6440f984dc8d8cb360/Cryptographie/src/ACle.java
--------------------------------------------------------------------------------
/Cryptographie/src/ACleAleatoire.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Vincent3112/javaCourseraOOP/e69e62d2a5cd15c425a31a6440f984dc8d8cb360/Cryptographie/src/ACleAleatoire.java
--------------------------------------------------------------------------------
/Cryptographie/src/Cesar.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Vincent3112/javaCourseraOOP/e69e62d2a5cd15c425a31a6440f984dc8d8cb360/Cryptographie/src/Cesar.java
--------------------------------------------------------------------------------
/Cryptographie/src/Codages.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Vincent3112/javaCourseraOOP/e69e62d2a5cd15c425a31a6440f984dc8d8cb360/Cryptographie/src/Codages.java
--------------------------------------------------------------------------------
/Cryptographie/src/Code.java:
--------------------------------------------------------------------------------
1 | abstract class Code {
2 |
3 | String nom;
4 |
5 | Code(String nom) {
6 | this.nom = nom;
7 | }
8 | Code() {
9 |
10 | }
11 | public abstract void affiche();
12 | public abstract String code(String s);
13 | public abstract String decode(String s);
14 | }
--------------------------------------------------------------------------------
/Cryptographie/src/Secret.java:
--------------------------------------------------------------------------------
1 | public class Secret {
2 |
3 | public static void main(String [] args) {
4 | String message ="VINCENT";
5 | System.out.println("Test CODAGES: ");
6 | System.out.println("----------------------");
7 | System.out.println();
8 | Code [] tab = {
9 | new Cesar("Cesar", 5),
10 | new ACle("a cle", "EQUINOXE"),
11 | new ACleAleatoire(5),
12 | new ACleAleatoire(10)};
13 | Codages codes = new Codages(tab);
14 | codes.test(message);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Cryptographie/src/TableauCodage.java:
--------------------------------------------------------------------------------
1 | import java.util.ArrayList;
2 |
3 | public class TableauCodage {
4 |
5 | public ArrayList cleCodage;
6 |
7 | TableauCodage(int nbrCharacteres) {
8 | cleCodage = new ArrayList();
9 | }
10 |
11 | public void add(Integer integer) {
12 | if (integer != 0)
13 | {
14 | cleCodage.add(integer);
15 | }
16 | }
17 |
18 | public int get(int unInt) {
19 | return cleCodage.get(unInt);
20 | }
21 |
22 | public void getTableau() {
23 | for (int i = 0; i < cleCodage.size(); i++) {
24 | System.out.print(cleCodage.get(i) + ", ");
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/Cryptographie/src/Utils.java:
--------------------------------------------------------------------------------
1 | import java.util.Random;
2 |
3 | public class Utils {
4 |
5 | public static int randomInt (int max) {
6 | Random r = new Random();
7 | int val = r.nextInt();
8 | val = Math.abs(val);
9 | val = val % max;
10 | val += 1;
11 | return val;
12 | }
13 | }
--------------------------------------------------------------------------------
/Employees/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Employees/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/Employees/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | PrimeDeRisque
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Employees/README.md:
--------------------------------------------------------------------------------
1 | # Employees
2 |
3 | ## Topic
4 |
5 | The main topic of week 5 is using both interfaces and the attribut static.
6 |
7 |
8 | ### Description
9 |
10 |
11 | In this file we have many different employees having different salaries and all inheriting from a super class Employe that have different attributs.
12 |
13 | 2 different employees classes have child classes because they are workers that work in a dangerous environnement, thus, they both implements an interface called employeARisque that provides them an extra 200 euros per month on their salaries.
14 |
15 |
16 |
17 | ### Class Diagramm
18 |
19 | 
--------------------------------------------------------------------------------
/Employees/employees.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Vincent3112/javaCourseraOOP/e69e62d2a5cd15c425a31a6440f984dc8d8cb360/Employees/employees.png
--------------------------------------------------------------------------------
/Employees/src/Salaires.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Vincent3112/javaCourseraOOP/e69e62d2a5cd15c425a31a6440f984dc8d8cb360/Employees/src/Salaires.java
--------------------------------------------------------------------------------
/Journey/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Journey/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/Journey/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | AgenceDeVoyage
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Journey/README.md:
--------------------------------------------------------------------------------
1 | # Journey
2 |
3 |
4 | ### Class Diagramm
5 |
6 | 
7 |
--------------------------------------------------------------------------------
/Journey/journeyDiagramm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Vincent3112/javaCourseraOOP/e69e62d2a5cd15c425a31a6440f984dc8d8cb360/Journey/journeyDiagramm.png
--------------------------------------------------------------------------------
/Journey/src/Voyage.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Vincent3112/javaCourseraOOP/e69e62d2a5cd15c425a31a6440f984dc8d8cb360/Journey/src/Voyage.java
--------------------------------------------------------------------------------
/Puissance4/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Puissance4/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/Puissance4/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Puissance4
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Puissance4/README.MD:
--------------------------------------------------------------------------------
1 | # Puissance 4
2 |
3 | ## Topic
4 |
5 | This exercise was about coding a *Puissance 4* game. Basically, I designed this game as an array of an array so that I obtain a 2 dimensional array in order to have my rows and columns.
6 |
7 | The game takes a number as parameter so that it is automatically designed squared.
8 |
9 | Each player is represented by a color, either *R* for the AI or *B* for the player.
10 |
11 | ## How the players actually play
12 |
13 | This game makes one single player play against the AI.
14 |
15 | The rule that makes a player allowed to play is the following. He has to chose a column, if it is full, he has to chose another one and so on. When the column is not full he can play.
16 |
17 | Regarding how the AI plays, we went pretty easy, the program looks for the first column available and plays.
18 |
19 |
20 | ## End of the game
21 |
22 | Like described right above, the players play while certain conditions are matched. Those conditions are that the game is not full... and that nobody wins !
23 |
24 | #### Conditions
25 |
26 | If the game goes full and all the columns are full, it is the end of the game.
27 |
28 | One of the player can also win the game. This is implemented by four different methods that iterate throw the arrays and look if 4 colours are either aligned in rows, columns or diagonal.
29 |
30 | If this is the case, the program stops and announce who won.
31 |
32 | ## Screenshots
33 |
34 | Below you can find some screenshots of what the display of the game is like.
35 |
36 | At the beginning the program asks for a name that has to be written is the console.
37 | Then the AI plays first.
38 |
39 | 
40 |
41 |
42 |
43 | If someone gets 4 colours aligned, he wins.
44 |
45 | 
46 |
47 | The computer can also win obviously... and even in diagonal :
48 |
49 | 
50 |
51 |
52 | ## Class diagram
53 |
54 | Below you can find the class diagram associated with this program.
55 |
56 | 
57 |
58 |
--------------------------------------------------------------------------------
/Puissance4/puissance4_model.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Vincent3112/javaCourseraOOP/e69e62d2a5cd15c425a31a6440f984dc8d8cb360/Puissance4/puissance4_model.jpg
--------------------------------------------------------------------------------
/Puissance4/screenShots/end.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Vincent3112/javaCourseraOOP/e69e62d2a5cd15c425a31a6440f984dc8d8cb360/Puissance4/screenShots/end.png
--------------------------------------------------------------------------------
/Puissance4/screenShots/otherend.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Vincent3112/javaCourseraOOP/e69e62d2a5cd15c425a31a6440f984dc8d8cb360/Puissance4/screenShots/otherend.png
--------------------------------------------------------------------------------
/Puissance4/screenShots/start.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Vincent3112/javaCourseraOOP/e69e62d2a5cd15c425a31a6440f984dc8d8cb360/Puissance4/screenShots/start.png
--------------------------------------------------------------------------------
/Puissance4/src/Jeu.java:
--------------------------------------------------------------------------------
1 | public class Jeu {
2 |
3 | public boolean gagnant = false;
4 | public boolean AIWon = false;
5 | public boolean playerWon = false;
6 | String pion;
7 | private int taille;
8 | private int [][] grille;
9 |
10 | public boolean getVictoryAI() {
11 | return AIWon;
12 | }
13 |
14 | public boolean getVictoryPlayer() {
15 | return playerWon;
16 | }
17 |
18 | public Jeu(int taille) {
19 | initialiseJeu(taille);
20 | }
21 |
22 | public void initialiseJeu(int taille) {
23 | this.taille = taille;
24 | grille = new int [taille] [taille];
25 | for (int row = 0; row < taille; row++) {
26 | for (int col = 0; col < taille; col++) {
27 | grille [col][row] = 0;
28 | }
29 | }
30 | }
31 |
32 | public boolean joueCoup(int col, int couleur) {
33 | if (col < 0 || col >= taille) {
34 | return false;
35 | }
36 | for (int ligne = 0; ligne < taille; ligne++) {
37 | if (grille[col][ligne] == 0) {
38 | grille[col][ligne] = couleur;
39 | return true;
40 | }
41 | }
42 | return false;
43 | }
44 |
45 | public boolean look4InRow() {
46 | for (int row = 0; row < taille; row++) {
47 | for (int col = 0; col < taille - 3; col++) {
48 | if (grille [col][row] == 1) {
49 | if (grille [col+1][row] == 1 & grille [col+2][row] == 1 & grille [col+3][row] == 1) {
50 | gagnant = true;
51 | AIWon = true;
52 | }
53 | }
54 | if (grille [col][row] == 2) {
55 | if (grille [col+1][row] == 2 & grille [col+2][row] == 2 & grille [col+3][row] == 2) {
56 | gagnant = true;
57 | playerWon = true;
58 | }
59 | }
60 | }
61 | }
62 | return gagnant;
63 | }
64 |
65 | public boolean look4InCol() {
66 | for (int row = 0; row < taille - 3; row++) {
67 | for (int col = 0; col < taille; col++) {
68 | if (grille [col][row] == 1) {
69 | if (grille [col][row+1] == 1 & grille [col][row+2] == 1 & grille [col][row+3] == 1) {
70 | gagnant = true;
71 | AIWon = true;
72 | }
73 | }
74 | if (grille [col][row] == 2) {
75 | if (grille [col][row+1] == 2 & grille [col][row+2] == 2 & grille [col][row+3] == 2) {
76 | gagnant = true;
77 | playerWon = true;
78 | }
79 | }
80 | }
81 | }
82 | return gagnant;
83 | }
84 |
85 | public boolean look4InDiagRight() {
86 | for (int row = 0; row < taille - 3; row++) {
87 | for (int col = 0; col < taille - 3; col++) {
88 | if (grille [col][row] == 1) {
89 | if (grille [col+1][row+1] == 1 & grille [col+2][row+2] == 1 & grille [col+3][row+3] == 1) {
90 | gagnant = true;
91 | AIWon = true;
92 | }
93 | }
94 | if (grille [col][row] == 2) {
95 | if (grille [col+1][row+1] == 2 & grille [col+2][row+2] == 2 & grille [col+3][row+3] == 2) {
96 | gagnant = true;
97 | playerWon = true;
98 | }
99 | }
100 | }
101 | }
102 | return gagnant;
103 | }
104 |
105 | public boolean look4InDiagLeft() {
106 | for (int row = 0; row < taille - 3; row++) {
107 | for (int col = 3; col < taille; col++) {
108 | if (grille [col][row] == 1) {
109 | if (grille [col-1][row+1] == 1 & grille [col-2][row+2] == 1 & grille [col-3][row+3] == 1) {
110 | gagnant = true;
111 | AIWon = true;
112 | }
113 | }
114 | if (grille [col][row] == 2) {
115 | if (grille [col-1][row+1] == 2 & grille [col-2][row+2] == 2 & grille [col-3][row+3] == 2) {
116 | gagnant = true;
117 | playerWon = true;
118 | }
119 | }
120 | }
121 | }
122 | return gagnant;
123 | }
124 |
125 | public boolean estPlein() {
126 | for (int row = 0; row < taille; row++) {
127 | for (int col = 0; col < taille; col++) {
128 | if (grille [col][row] == 0) {
129 | return false;
130 | }
131 | }
132 | }
133 | return true;
134 | }
135 |
136 | public int getTaille() {
137 | return taille;
138 | }
139 |
140 | public void afficher() {
141 | for (int ligne = taille - 1; ligne >= 0; ligne--) {
142 | for (int col = 0; col < taille; col++) {
143 | if (grille[col][ligne] == 0) {
144 | System.out.print(" ");
145 | }
146 | else if (grille[col][ligne] == 1) {
147 | System.out.print("R ");
148 | }
149 | else {
150 | System.out.print("B ");
151 | }
152 | }
153 | System.out.println();
154 | }
155 | System.out.println();
156 | for (int i = 0; i < taille; i++) {
157 | System.out.print("- ");
158 | }
159 | System.out.println();
160 | for (int i = 1; i <= taille; i++) {
161 | System.out.print(i + " ");
162 | }
163 | System.out.println();
164 | }
165 | }
--------------------------------------------------------------------------------
/Puissance4/src/JoueurHumain.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Vincent3112/javaCourseraOOP/e69e62d2a5cd15c425a31a6440f984dc8d8cb360/Puissance4/src/JoueurHumain.java
--------------------------------------------------------------------------------
/Puissance4/src/JoueurOrdi.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Vincent3112/javaCourseraOOP/e69e62d2a5cd15c425a31a6440f984dc8d8cb360/Puissance4/src/JoueurOrdi.java
--------------------------------------------------------------------------------
/Puissance4/src/Joueurs.java:
--------------------------------------------------------------------------------
1 | public class Joueurs {
2 |
3 | int couleur;
4 | String nom;
5 |
6 | Joueurs() {
7 | }
8 |
9 | Joueurs(int couleur, String nom) {
10 | this.couleur = couleur;
11 | this.nom = nom;
12 | }
13 |
14 | public int getCouleur() {
15 | return couleur;
16 | }
17 |
18 | public String getNom() {
19 | return nom;
20 | }
21 |
22 | public void joue(Jeu jeu) {
23 | }
24 | }
--------------------------------------------------------------------------------
/Puissance4/src/Partie.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Vincent3112/javaCourseraOOP/e69e62d2a5cd15c425a31a6440f984dc8d8cb360/Puissance4/src/Partie.java
--------------------------------------------------------------------------------
/Puissance4/src/Puissance4.java:
--------------------------------------------------------------------------------
1 | import java.util.Scanner;
2 |
3 | class Puissance4 {
4 |
5 | protected static Scanner scanner = new Scanner(System.in);
6 |
7 | public static void main(String[] args) {
8 | System.out.println("Entrez votre nom: ");
9 | String nom = scanner.nextLine();
10 | System.out.println("--");
11 | Partie p = new Partie(new JoueurOrdi( 1, "ordinatueur"), new JoueurHumain(2, nom));
12 | p.joue();
13 | }
14 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # javaCourseraOOP
2 |
3 | ## Content
4 |
5 | - On this repository, I will commit the code from exercises and assignements that I completed while taking the "Intro to OOP in Java" course on Coursera.
6 |
7 | - This course introduces to all the basic topics of Object Oriented Programming such as objects and classes but quickly goes on to encapsulation, inheritance, polymorphism, interfaces and management of exceptions.
8 |
9 | - I have seen many introduction courses to OOP in Java and I think this one is really the one that allowed me to understand those topics that are not always easy to get for beginner programers.
--------------------------------------------------------------------------------
/Race/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Race/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/Race/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Courses
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.jdt.core.javanature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Race/README.md:
--------------------------------------------------------------------------------
1 | # Course de voitures
2 |
3 |
4 | ### Diagramme
5 |
6 | 
7 |
--------------------------------------------------------------------------------
/Race/diagrammeCourse.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Vincent3112/javaCourseraOOP/e69e62d2a5cd15c425a31a6440f984dc8d8cb360/Race/diagrammeCourse.png
--------------------------------------------------------------------------------
/Race/src/Course.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Vincent3112/javaCourseraOOP/e69e62d2a5cd15c425a31a6440f984dc8d8cb360/Race/src/Course.java
--------------------------------------------------------------------------------