diff --git a/tp/.idea/.gitignore b/tp/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..26d33521af10bcc7fd8cea344038eaaeb78d0ef5 --- /dev/null +++ b/tp/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/tp/.idea/compiler.xml b/tp/.idea/compiler.xml new file mode 100644 index 0000000000000000000000000000000000000000..9f9a1c2dbf55559ceb837794da5a4f9184c5b2c4 --- /dev/null +++ b/tp/.idea/compiler.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="CompilerConfiguration"> + <annotationProcessing> + <profile name="Maven default annotation processors profile" enabled="true"> + <sourceOutputDir name="target/generated-sources/annotations" /> + <sourceTestOutputDir name="target/generated-test-sources/test-annotations" /> + <outputRelativeToContentRoot value="true" /> + <module name="tp" /> + </profile> + </annotationProcessing> + </component> +</project> \ No newline at end of file diff --git a/tp/.idea/encodings.xml b/tp/.idea/encodings.xml new file mode 100644 index 0000000000000000000000000000000000000000..aa00ffab7828f4818589659c804ec2cfd99baed3 --- /dev/null +++ b/tp/.idea/encodings.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="Encoding"> + <file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" /> + <file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" /> + </component> +</project> \ No newline at end of file diff --git a/tp/.idea/jarRepositories.xml b/tp/.idea/jarRepositories.xml new file mode 100644 index 0000000000000000000000000000000000000000..712ab9d985c20018a0c97b93d2148ac1ffe588a5 --- /dev/null +++ b/tp/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="RemoteRepositoriesConfiguration"> + <remote-repository> + <option name="id" value="central" /> + <option name="name" value="Central Repository" /> + <option name="url" value="https://repo.maven.apache.org/maven2" /> + </remote-repository> + <remote-repository> + <option name="id" value="central" /> + <option name="name" value="Maven Central repository" /> + <option name="url" value="https://repo1.maven.org/maven2" /> + </remote-repository> + <remote-repository> + <option name="id" value="jboss.community" /> + <option name="name" value="JBoss Community repository" /> + <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" /> + </remote-repository> + </component> +</project> \ No newline at end of file diff --git a/tp/.idea/misc.xml b/tp/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..4258c62fd9edaffc241e79c34ec36a478505f4f1 --- /dev/null +++ b/tp/.idea/misc.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ExternalStorageConfigurationManager" enabled="true" /> + <component name="MavenProjectsManager"> + <option name="originalFiles"> + <list> + <option value="$PROJECT_DIR$/pom.xml" /> + </list> + </option> + </component> + <component name="ProjectRootManager" version="2" languageLevel="JDK_18" default="true" project-jdk-name="18" project-jdk-type="JavaSDK"> + <output url="file://$PROJECT_DIR$/out" /> + </component> +</project> \ No newline at end of file diff --git a/tp/.idea/vcs.xml b/tp/.idea/vcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..6c0b8635858dc7ad44b93df54b762707ce49eefc --- /dev/null +++ b/tp/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="$PROJECT_DIR$/.." vcs="Git" /> + </component> +</project> \ No newline at end of file diff --git a/tp/pom.xml b/tp/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..f56050452a998ba2b858bd8eaf0e9f60b44fb176 --- /dev/null +++ b/tp/pom.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.example</groupId> + <artifactId>tp</artifactId> + <version>1.0-SNAPSHOT</version> + + <properties> + <maven.compiler.source>18</maven.compiler.source> + <maven.compiler.target>18</maven.compiler.target> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + +</project> \ No newline at end of file diff --git a/tp/src/main/java/org/example/Address.java b/tp/src/main/java/org/example/Address.java new file mode 100644 index 0000000000000000000000000000000000000000..bffb6da981914d12c43d3592f40664cddb43415b --- /dev/null +++ b/tp/src/main/java/org/example/Address.java @@ -0,0 +1,30 @@ +package org.example; + +public class Address { + private int number; + private String type; + private String name; + private String npa; + private String city; + private String state; + private String country; + + public Address(int number, String type, String name, String npa, String city, String state, String country){ + if(number <= 0){ + throw new RuntimeException("Number need to be bigger than 0"); + } + this.number = number; + this.type = type; + this.name = name; + this.npa = npa; + this.city = city; + this.state = state; + this.country = country; + } + + @Override + public String toString(){ + return Integer.toString(this.number) + " " + this.type + " " + this.name + ", " + this.npa + " " + this.city + ", " + this.state + + ", " + this.country; + } +} diff --git a/tp/src/main/java/org/example/Contact.java b/tp/src/main/java/org/example/Contact.java new file mode 100644 index 0000000000000000000000000000000000000000..14dff85e1f64e8f5c278482f3482ba8a63b098df --- /dev/null +++ b/tp/src/main/java/org/example/Contact.java @@ -0,0 +1,88 @@ +package org.example; + +public class Contact { + //Fields + private Person pers; + private Address addr; + private String[] phone; + private String[] email; + private String[] social; + private String job; + + //Ctor + public Contact(Person pers, Address addr, String[] phone, String[] email, + String[] social, String job){ + this.pers = pers; + this.addr = addr; + this.phone = phone; + this.email = email; + this.social = social; + this.job = job; + } + + //Getter + + public Address getAddr() { + return addr; + } + + public String[] getPhone() { + return phone; + } + + public String[] getEmail() { + return email; + } + + public String[] getSocial() { + return social; + } + + public String getJob() { + return job; + } + + + //Setter + + public void setAddr(Address addr) { + this.addr = addr; + } + + public void setPhone(String[] phone) { + this.phone = phone; + } + + public void setEmail(String[] email) { + this.email = email; + } + + public void setSocial(String[] social) { + this.social = social; + } + + public void setJob(String job) { + this.job = job; + } + + //Methodes + @Override + public String toString(){ + String w_phone = ""; + String w_email = ""; + String w_social = ""; + + for(String elem: this.phone){ + w_phone += elem + " "; + } + for(String elem: this.email){ + w_email += elem + " "; + } + for(String elem: this.social){ + w_social += elem + " "; + } + + return pers.toString() + "\n" + this.addr.toString() + "\n" + w_phone + "\n" + w_email + "\n" + + w_social + "\n" + this.job; + } +} diff --git a/tp/src/main/java/org/example/Main.java b/tp/src/main/java/org/example/Main.java new file mode 100644 index 0000000000000000000000000000000000000000..08578ea8a4e6bfa25c2ec7cb5443962ba30ae6cf --- /dev/null +++ b/tp/src/main/java/org/example/Main.java @@ -0,0 +1,16 @@ +package org.example; + +public class Main { + public static void main(String[] args) { + Address addr1 = new Address(4, "ch", "de qqpart", "1876", "idk", "ligma", + "balls"); + Person p1 = new Person("John", "Doe"); + String[] phone = {"079 779 77 99"}; + String[] email = {"fdp@gmail.com", "yo@gmail.com"}; + String[] social = {"None"}; + Contact ct1 = new Contact(p1, addr1, phone, email, social, "Homeless"); + + System.out.println(addr1.toString()); + System.out.println(ct1.toString()); + } +} \ No newline at end of file diff --git a/tp/src/main/java/org/example/Person.java b/tp/src/main/java/org/example/Person.java new file mode 100644 index 0000000000000000000000000000000000000000..4650d2173b49a1b2c2a2624a7775172834d8138e --- /dev/null +++ b/tp/src/main/java/org/example/Person.java @@ -0,0 +1,49 @@ +package org.example; + +public class Person { + private String last_name; + private String[] add_last_name; + private String first_name; + private String[] middle_name; + + public Person(String last_name, String first_name){ + this.last_name = last_name; + this.first_name = first_name; + } + public Person(String last_name, String[] add_last_name, String first_name, String[] middle_name){ + this.last_name = last_name; + this.add_last_name = add_last_name; + this.first_name = first_name; + this.middle_name = middle_name; + } + public Person(String last_name, String first_name, String[] middle_name){ + this.last_name = last_name; + this.first_name = first_name; + this.middle_name = middle_name; + } + public Person(String last_name, String[] add_last_name, String first_name){ + this.last_name = last_name; + this.add_last_name = add_last_name; + this.first_name = first_name; + } + + @Override + public String toString() { + String w_last = ""; + String w_middle = ""; + + if(this.add_last_name != null){ + for(int i = 0; i < this.add_last_name.length; i++){ + w_last += this.add_last_name[i] + " "; + } + } + + if(this.middle_name != null){ + for(int i = 0; i < this.middle_name.length; i++){ + w_middle += this.middle_name[i] + " "; + } + } + + return this.first_name + " " + w_middle + " " + this.last_name + " " + w_last; + } +} diff --git a/tp/target/classes/org/example/Address.class b/tp/target/classes/org/example/Address.class new file mode 100644 index 0000000000000000000000000000000000000000..7c34d20d538d5d24bba2b7fc57e1fe110e0b4bb5 Binary files /dev/null and b/tp/target/classes/org/example/Address.class differ diff --git a/tp/target/classes/org/example/Contact.class b/tp/target/classes/org/example/Contact.class new file mode 100644 index 0000000000000000000000000000000000000000..f10690f1ae5b05e56b3aabbe20d397a5200bca50 Binary files /dev/null and b/tp/target/classes/org/example/Contact.class differ diff --git a/tp/target/classes/org/example/Main.class b/tp/target/classes/org/example/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..408afad89cb648fafc7cdb60f5cdd52ab92db623 Binary files /dev/null and b/tp/target/classes/org/example/Main.class differ diff --git a/tp/target/classes/org/example/Person.class b/tp/target/classes/org/example/Person.class new file mode 100644 index 0000000000000000000000000000000000000000..1b4732a24aea1b9f8b319d63ef33c4d7fd771121 Binary files /dev/null and b/tp/target/classes/org/example/Person.class differ