initial commit
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
## Getting Started
|
||||
|
||||
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
|
||||
|
||||
## Folder Structure
|
||||
|
||||
The workspace contains two folders by default, where:
|
||||
|
||||
- `src`: the folder to maintain sources
|
||||
- `lib`: the folder to maintain dependencies
|
||||
|
||||
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
|
||||
|
||||
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
|
||||
|
||||
## Dependency Management
|
||||
|
||||
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,44 @@
|
||||
public class Adresse {
|
||||
|
||||
private int numero;
|
||||
private String nomDeRue;
|
||||
private int codePostal;
|
||||
|
||||
public Adresse(){
|
||||
System.out.println("Création d'une adresse par defaut");
|
||||
numero= 0;
|
||||
nomDeRue = "Nom De Rue Par Defaut";
|
||||
codePostal= 0;
|
||||
}
|
||||
|
||||
public Adresse(String nomDeRueInput, int codePostalInput){
|
||||
System.out.println("Création d'une adresse custom " + nomDeRueInput);
|
||||
nomDeRue = nomDeRueInput;
|
||||
codePostal= codePostalInput;
|
||||
}
|
||||
|
||||
public int getNumero(){
|
||||
return this.numero;
|
||||
}
|
||||
|
||||
public void setNumero(int numeroInput){
|
||||
this.numero = numeroInput;
|
||||
}
|
||||
|
||||
public String getNomDeRue(){
|
||||
return this.nomDeRue;
|
||||
}
|
||||
|
||||
public void setNomDeRue(String nomDeRueInput){
|
||||
this.nomDeRue = nomDeRueInput;
|
||||
}
|
||||
|
||||
public int getcodePostal(){
|
||||
return this.codePostal;
|
||||
}
|
||||
|
||||
public void setCodePostal(int codePostalInput){
|
||||
this.codePostal = codePostalInput;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class App {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
//Ville villeParDefaut = new Ville();
|
||||
//Ville paris = new Ville("Paris", 123456, "France");
|
||||
//Ville marseille = new Ville("Marseille", 654321, "France");
|
||||
|
||||
//System.out.println(villeParDefaut.getNomVille());
|
||||
//System.out.println(paris.getNomVille());
|
||||
//System.out.println(marseille.getNomVille());
|
||||
|
||||
Ville v1 = new Ville("Marseille", 123456, "France", 13000);
|
||||
System.out.println("v1 = " + v1.getNomVille() + ", " + v1.getNbreHabitants() + ", " + v1.getNomPays());
|
||||
Ville v2 = new Ville("Rio", 321654, "Brésil", 78945);
|
||||
System.out.println("v2 = " + v2.getNomVille() + ", " + v2.getNbreHabitants() + ", " + v2.getNomPays());
|
||||
|
||||
System.out.println();
|
||||
|
||||
System.out.println("On inverse v1 et v2");
|
||||
|
||||
Ville temp = new Ville();
|
||||
temp = v1;
|
||||
v1 = v2;
|
||||
v2 = temp;
|
||||
|
||||
System.out.println();
|
||||
|
||||
System.out.println("v1 = " + v1.getNomVille() + ", " + v1.getNbreHabitants() + ", " + v1.getNomPays());
|
||||
System.out.println("v2 = " + v2.getNomVille() + ", " + v2.getNbreHabitants() + ", " + v2.getNomPays());
|
||||
|
||||
System.out.println();
|
||||
|
||||
System.out.println("On change les nom de Ville");
|
||||
|
||||
v1.setNomVille("Hong Kong");
|
||||
v2.setNomVille("Dijbouti");
|
||||
|
||||
System.out.println();
|
||||
|
||||
System.out.println(v1.getNomVille() + ", " + v1.getNbreHabitants() + ", " + v1.getNomPays());
|
||||
System.out.println(v2.getNomVille() + ", " + v2.getNbreHabitants() + ", " + v2.getNomPays());
|
||||
|
||||
|
||||
System.out.println("\n ==== Passage à l'exo adresse ====\n");
|
||||
|
||||
Adresse adresse1 = new Adresse("rue toto", 77300);
|
||||
Ville melun = new Ville("Melun", 15000, "France", 77300);
|
||||
System.out.println("code postal = " + adresse1.getcodePostal());
|
||||
|
||||
melun.findVilleFromCodePostal(adresse1.getcodePostal());
|
||||
|
||||
adresse1.getNumero();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
public class Ville {
|
||||
|
||||
private String nomVille;
|
||||
private String nomPays;
|
||||
private int nbreHabitants;
|
||||
private int codePostal;
|
||||
|
||||
public Ville(){
|
||||
|
||||
System.out.println("Création d'une ville par defaut");
|
||||
nomVille= "NomDeVilleParDefaut";
|
||||
nomPays = "NomDePaysParDefaut";
|
||||
nbreHabitants= 0;
|
||||
codePostal= 00000;
|
||||
}
|
||||
|
||||
public Ville(String pNom, int pNbre, String pPays, int pCodePostal){
|
||||
System.out.println("Création d'une ville custom " + pNom);
|
||||
nomVille= pNom;
|
||||
nomPays = pPays;
|
||||
nbreHabitants= pNbre;
|
||||
codePostal = pCodePostal;
|
||||
}
|
||||
|
||||
public void findVilleFromCodePostal(int adresseCodePostal) {
|
||||
|
||||
if(adresseCodePostal == this.codePostal){
|
||||
System.out.println("La ville du code postal " + adresseCodePostal + " est " + this.nomVille);
|
||||
}
|
||||
else{
|
||||
System.out.println("Le code postal " + adresseCodePostal + " ne correspond pas à la ville" + this.nomVille);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int getNbreHabitants() {
|
||||
return nbreHabitants;
|
||||
}
|
||||
|
||||
public void setNbreHabitants(int nbreHabitants) {
|
||||
this.nbreHabitants = nbreHabitants;
|
||||
}
|
||||
|
||||
public String getNomPays() {
|
||||
return nomPays;
|
||||
}
|
||||
|
||||
public void setNomPays(String nomPays) {
|
||||
this.nomPays = nomPays;
|
||||
}
|
||||
|
||||
public String getNomVille() {
|
||||
return nomVille;
|
||||
}
|
||||
|
||||
public void setNomVille(String nomVille) {
|
||||
this.nomVille = nomVille;
|
||||
}
|
||||
|
||||
public int getCodePostal() {
|
||||
return this.codePostal;
|
||||
}
|
||||
|
||||
public void setCodePostal(int codePostal) {
|
||||
this.codePostal = codePostal;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user