From 05a68119caf9eed8670250e63edc6f4b4d8035b9 Mon Sep 17 00:00:00 2001
From: "vincent.steinman" <vincent.steinmann@etu.hesge.ch>
Date: Mon, 30 Jan 2023 17:02:25 +0100
Subject: [PATCH] changed a bit some comments

---
 .../com/example/tpfx/HelloController.java     | 23 ++++++++++++-------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/tp/src/main/java/com/example/tpfx/HelloController.java b/tp/src/main/java/com/example/tpfx/HelloController.java
index dcbd284..890ee72 100644
--- a/tp/src/main/java/com/example/tpfx/HelloController.java
+++ b/tp/src/main/java/com/example/tpfx/HelloController.java
@@ -12,7 +12,7 @@ import java.util.regex.Pattern;
 
 public class HelloController {
     static ArrayList<Contact> contactArray = new ArrayList<>();
-    int selectedID = 0;
+    int selectedID = 0; //Save the id of the selected item in the list view
     boolean imported = false; //Used to know whenever we should enable or disable button save/edit
     ObservableList<String> ctType = FXCollections.observableArrayList("Friend", "Family", "Professional");
     //Fx fields
@@ -194,12 +194,13 @@ public class HelloController {
         txtEmail.setText(data.get(5));
         txtSocial.setText(data.get(6));
         txtJob.setText(data.get(7));
+
+        //Family and professional have one more arguments
         if(data.size() > 8){
             txtOther.setVisible(true);
             lblOther.setVisible(true);
             txtOther.setText(data.get(8));
             if(contactArray.get(LstCt.getSelectionModel().getSelectedIndex()) instanceof Family){
-                //contactArray.get(LstCt.getSelectionModel().getSelectedIndex()).EditRelation(other);
                 lblOther.setVisible(true);
                 lblOther.setText("Relation");
                 txtOther.setVisible(true);
@@ -210,7 +211,7 @@ public class HelloController {
                 txtOther.setVisible(true);
                 cbxType.setValue("Professional");
             }
-        } else {
+        } else { //Reset when it comes back to friends
             txtOther.setVisible(false);
             lblOther.setVisible(false);
             cbxType.setValue("Friend");
@@ -288,18 +289,20 @@ public class HelloController {
      */
     @FXML
     protected void ShowAll() {
-        int cpt = 0;
+        int cpt_id = 0;
         imported = false;
         btnEdit.setDisable(true);
         btnAdd.setDisable(true);
-        for(Contact cont: contactArray){
-            cont.setId(cpt);
-            cpt++;
+
+        for(Contact cont: contactArray){ //Give the correct id to the contact (based on their place in the list
+            cont.setId(cpt_id);
+            cpt_id++;
         }
         LstCt.getItems().clear();
         for(Contact c: contactArray){
             LstCt.getItems().add(c.toString());
         }
+
         txtFirst.setText("");
         txtLast.setText("");
         txtAdd.setText("");
@@ -384,6 +387,7 @@ public class HelloController {
     }
     /**
      * Import a Friend
+     * @param str_array Friends informations
      */
     public void ImportFriend(List<String> str_array){
         Friend f = new Friend(
@@ -400,6 +404,7 @@ public class HelloController {
     }
     /**
      * Import a Family Member
+     * @param str_array Family member  informations
      */
     public void ImportFamily(List<String> str_array){
         Family f = new Family(
@@ -418,6 +423,7 @@ public class HelloController {
 
     /**
      * Import a Professional
+     * @param str_array Professional informations
      */
     public void ImportProfessional(List<String> str_array){
         Professional f = new Professional(
@@ -435,13 +441,14 @@ public class HelloController {
     }
     /**
      * Add a contact (any type) to the list
+     * @param str_array contact info
+     * @param checker checker to verify contact type
      */
     public void AddContactToList(List<String> str_array, int checker){
         switch (checker){
             case 1 -> ImportFriend(str_array);
             case 2 -> ImportFamily(str_array);
             case 3 -> ImportProfessional(str_array);
-            default -> System.out.println("Error contact type");
         }
     }
     /**
-- 
GitLab