Skip to content
Snippets Groups Projects
Commit 299fb72c authored by vincent.steinman's avatar vincent.steinman
Browse files

edit relation/workplace

parent 222e2614
No related branches found
No related tags found
No related merge requests found
...@@ -66,6 +66,7 @@ public class HelloController { ...@@ -66,6 +66,7 @@ public class HelloController {
*/ */
@FXML @FXML
protected void AddCt() { protected void AddCt() {
//enhanced switch, doesn't need break
switch (cbxType.getValue().toString()){ //Use the combo box value switch (cbxType.getValue().toString()){ //Use the combo box value
case "Friend" -> AddPal(); case "Friend" -> AddPal();
case "Family" -> AddFam(); case "Family" -> AddFam();
...@@ -240,21 +241,23 @@ public class HelloController { ...@@ -240,21 +241,23 @@ public class HelloController {
List<String> social = SplitLine(txtSocial.getText(), " "); List<String> social = SplitLine(txtSocial.getText(), " ");
String job = txtJob.getText(); String job = txtJob.getText();
String other = txtOther.getText(); String other = txtOther.getText();
int selected_id = LstCt.getSelectionModel().getSelectedIndex();
contactArray.get(LstCt.getSelectionModel().getSelectedIndex()).setFirstName(firstName); contactArray.get(selected_id).setFirstName(firstName);
contactArray.get(LstCt.getSelectionModel().getSelectedIndex()).setLastName(lastName); contactArray.get(selected_id).setLastName(lastName);
contactArray.get(LstCt.getSelectionModel().getSelectedIndex()).setAddr(address); contactArray.get(selected_id).setAddr(address);
contactArray.get(LstCt.getSelectionModel().getSelectedIndex()).setPhone(phone); contactArray.get(selected_id).setPhone(phone);
contactArray.get(LstCt.getSelectionModel().getSelectedIndex()).setEmail(emails); contactArray.get(selected_id).setEmail(emails);
contactArray.get(LstCt.getSelectionModel().getSelectedIndex()).setSocial(social); contactArray.get(selected_id).setSocial(social);
contactArray.get(LstCt.getSelectionModel().getSelectedIndex()).setJob(job); contactArray.get(selected_id).setJob(job);
if(contactArray.get(LstCt.getSelectionModel().getSelectedIndex()).getType().equals("Family")){ if(contactArray.get(LstCt.getSelectionModel().getSelectedIndex()) instanceof Family){
// Family fam = (Family)contactArray.get(LstCt.getSelectionModel().getSelectedIndex()); Family fam = (Family)contactArray.get(selected_id);
// fam.editRelation(other); fam.setRelation(other);
// int tmp = LstCt.getSelectionModel().getSelectedIndex(); contactArray.set(selected_id, fam);
// contactArray.get(tmp) = fam;
} else if(contactArray.get(LstCt.getSelectionModel().getSelectedIndex()).getType().equals("Professional")){ } else if(contactArray.get(LstCt.getSelectionModel().getSelectedIndex()).getType().equals("Professional")){
Professional pro = (Professional)contactArray.get(selected_id);
pro.setWork(other);
contactArray.set(selected_id, pro);
} }
ShowAll(); ShowAll();
} }
...@@ -366,7 +369,8 @@ public class HelloController { ...@@ -366,7 +369,8 @@ public class HelloController {
List<String> emailList = Arrays.asList(emails.split("/")); List<String> emailList = Arrays.asList(emails.split("/"));
List<String> socialList = Arrays.asList(social.split("/")); List<String> socialList = Arrays.asList(social.split("/"));
Professional pro = new Professional(first_name_list, lastName, address, phoneList, emailList, socialList, job, wp); Professional pro = new Professional(first_name_list, lastName, address, phoneList,
emailList, socialList, job, wp);
Add(pro); Add(pro);
} }
/** /**
...@@ -448,11 +452,4 @@ public class HelloController { ...@@ -448,11 +452,4 @@ public class HelloController {
public List<String> SplitLine(String str, String splitter){ public List<String> SplitLine(String str, String splitter){
return Arrays.asList(str.split(splitter)); return Arrays.asList(str.split(splitter));
} }
//TODO
/*
Unit Test,
edit relation/job?
*/
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment