Skip to content
Snippets Groups Projects
Commit 59746149 authored by alec.schmidt's avatar alec.schmidt
Browse files

couldn't fix the job/relation bug. Every class now is the same and abstract...

couldn't fix the job/relation bug. Every class now is the same and abstract class Contact() has job and relation
parent c7cf7a9b
No related branches found
No related tags found
No related merge requests found
......@@ -17,8 +17,10 @@ public class App extends Application {
@Override
public void start(Stage stage) throws IOException {
scene = new Scene(loadFXML("main"), 1149, 559);
scene = new Scene(loadFXML("main"), 1150, 560);
stage.setScene(scene);
stage.setTitle("Gestionnaire de contacts");
stage.setResizable(false);
stage.show();
}
......
......@@ -6,7 +6,6 @@ import ch.hepia.contacts.Famille;
import ch.hepia.contacts.Professionel;
import ch.hepia.controller.ContactController;
import ch.hepia.controller.Serializer;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
......@@ -65,6 +64,9 @@ public class FXMLController {
@FXML
private Button btnDelete;
@FXML
private Button btnUpdate;
@FXML
private ComboBox<String> cBoxType;
......@@ -74,7 +76,6 @@ public class FXMLController {
column.setCellValueFactory(
new PropertyValueFactory<>(getter)
);
column.prefWidthProperty().set(width);
return column;
}
......@@ -131,14 +132,12 @@ public class FXMLController {
protected void doneEditing() {
Contact c;
if (cBoxType.getValue().equals("Professionnel")) {
Professionel p = new Professionel();
p.setJob(jobBox.getText());
c = p;
c = new Professionel();
c.setJob(jobBox.getText());
}
else if (cBoxType.getValue().equals("Famille")){
Famille f = new Famille();
f.setRelation(relationBox.getText());
c = f;
c = new Famille();
c.setRelation(relationBox.getText());
}
else
c = new Amis();
......
......@@ -2,6 +2,9 @@ package ch.hepia.contacts;
public class Amis extends Contact {
public Amis() {
super();
}
public String toString() {
return "=====================================\n" +
......
......@@ -9,6 +9,8 @@ abstract public class Contact implements java.io.Serializable{
private List<String> phones;
private List<String> mails;
private List<String> socials;
private String relation;
private String job;
public Contact() {
this.name = "Uninitialized";
......@@ -44,7 +46,13 @@ abstract public class Contact implements java.io.Serializable{
return this.socials;
}
public String getRelation() {
return this.relation;
}
public String getJob() {
return this.job;
}
// SETTERS
public void setName(String s) {
......@@ -71,6 +79,13 @@ abstract public class Contact implements java.io.Serializable{
this.socials = socials;
}
public String setRelation(String relation) {
return this.relation;
}
public void setJob(String job) {
this.job = job;
}
// ADDER TO LISTS
public void addFirstName(String firstName) {
......
package ch.hepia.contacts;
public class Famille extends Contact {
private String relation;
public String getRelation() {
return this.relation;
}
public void setRelation(String relation) {
this.relation = relation;
}
public Famille()
{
this.relation = "Uninitialized";
}
public String toString() {
return "=====================================\n" +
......@@ -24,7 +10,7 @@ public class Famille extends Contact {
"Phone(s) : " + this.getPhones().toString() + "\n" +
"Mail(s) : " + this.getMails().toString() + "\n" +
"Social(s) : " + this.getSocials().toString() + "\n" +
"Job : " + this.getRelation() + "\n" +
"Relation : " + this.getRelation() + "\n" +
"=====================================\n";
}
......
package ch.hepia.contacts;
public class Professionel extends Contact {
private String job;
public String getJob() {
return this.job;
}
public void setJob(String job) {
this.job = job;
}
public Professionel()
{
this.job = "Uninitialized";
}
public String toString() {
return "=====================================\n" +
......
......@@ -43,30 +43,30 @@
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="552.0" prefWidth="1149.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.hepia.FXMLController">
<children>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="559.0" prefWidth="1149.0" VBox.vgrow="ALWAYS">
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="560.0" prefWidth="1150.0" VBox.vgrow="ALWAYS">
<children>
<TextField fx:id="nameBox" layoutX="14.0" layoutY="463.0" />
<TextField fx:id="firstNameBox" layoutX="185.0" layoutY="463.0" />
<TextField fx:id="AddressBox" layoutX="356.0" layoutY="463.0" />
<TextField fx:id="addressBox" layoutX="356.0" layoutY="463.0" />
<TextField fx:id="phoneBox" layoutX="527.0" layoutY="463.0" />
<TextField fx:id="mailBox" layoutX="14.0" layoutY="521.0" />
<TextField fx:id="socialBox" layoutX="185.0" layoutY="521.0" />
<Button layoutX="760.0" layoutY="521.0" mnemonicParsing="false" onAction="#doneEditing" text="Add" />
<Button layoutX="698.0" layoutY="521.0" mnemonicParsing="false" onAction="#doneEditing" text="Add" />
<Button fx:id="btnSave" layoutX="1086.0" layoutY="2.0" mnemonicParsing="false" onAction="#saveLocally" text="Save" />
<TextField layoutX="11.0" layoutY="2.0" promptText="Type here to search" />
<Button layoutX="191.0" layoutY="2.0" mnemonicParsing="false" onAction="#searchAction" text="Search" />
<Button fx:id="btnLoad" layoutX="1021.0" layoutY="2.0" mnemonicParsing="false" onAction="#loadLocalSave" text="Load" />
<ComboBox fx:id="cBoxType" layoutX="707.0" layoutY="463.0" onAction="#selectType" prefWidth="150.0" />
<TableView fx:id="tView" layoutY="36.0" prefHeight="402.0" prefWidth="1149.0">
<ComboBox fx:id="cBoxType" layoutX="698.0" layoutY="463.0" onAction="#selectType" prefWidth="150.0" />
<TableView fx:id="tView" layoutY="36.0" prefHeight="402.0" prefWidth="1150.0">
<columns>
<TableColumn prefWidth="75.0" text="C1" />
<TableColumn prefWidth="75.0" text="C2" />
</columns>
</TableView>
<Label layoutX="14.0" layoutY="447.0" text="Nom" />
<Label layoutX="181.0" layoutY="447.0" text="Prénom(s)" />
<Label layoutX="352.0" layoutY="447.0" text="Adresse(s)" />
<Label layoutX="523.0" layoutY="447.0" text="Téléphone(s)" />
<Label layoutX="187.0" layoutY="447.0" text="Prénom(s)" />
<Label layoutX="356.0" layoutY="447.0" text="Adresse(s)" />
<Label layoutX="527.0" layoutY="447.0" text="Téléphone(s)" />
<Label layoutX="18.0" layoutY="505.0" text="Mail(s)" />
<Label layoutX="185.0" layoutY="505.0" text="Socials" />
<TextField fx:id="jobBox" disable="true" layoutX="356.0" layoutY="521.0" />
......@@ -75,6 +75,7 @@
<TextField fx:id="relationBox" disable="true" layoutX="527.0" layoutY="521.0" />
<Label layoutX="527.0" layoutY="505.0" text="Relation" />
<Button layoutX="271.0" layoutY="2.0" mnemonicParsing="false" onAction="#homeAction" text="Home" />
<Button fx:id="btnUpdate" layoutX="782.0" layoutY="521.0" mnemonicParsing="false" text="Update" />
</children>
</AnchorPane>
</children>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment