Below is the code I would like some help with. I'm just trying to understand if there a better way to use getters and setters. Can someone fill me in on the correct way to use them if there is a textfield, JRadioButton set that I am trying to get info from?
//This class sets gets all the information that the user has entered.
package edu.witc.TrainTicket.model;
import java.text.NumberFormat;
import javax.swing.JOptionPane;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import edu.witc.TrainTicket.view.*;
public class Destination {
//Constructor with no arguments
public Destination() {
}
public Destination(JRadioButton chicago, JRadioButton newYork, JRadioButton seattle, JRadioButton sanFransisco, JTextField name, JTextField phone) {
String selectedDestination = getRadioButtonValue(chicago, newYork, seattle, sanFransisco);
String custName = getCustName(name);
String custPhone = getPhoneNum(phone);
}
public String getCustName(JTextField name){
return name.getText();
}
public String getPhoneNum(JTextField phone){
return phone.getText();
}
//get the type of paint
public String getRadioButtonValue(JRadioButton chicago, JRadioButton newYork, JRadioButton seattle, JRadioButton sanFransisco) {
String selected = "";
if(chicago.isSelected())
selected = "Chicago";
if(newYork.isSelected())
selected = "New York";
if(seattle.isSelected())
selected= "Seattle";
if(sanFransisco.isSelected())
selected= "San Fransisco";
//JOptionPane.showMessageDialog(null, selected);
return selected;
}
}
//Constructor with no argumentsisn't one.//Parameterless constructor required for xyzis more informative. \$\endgroup\$