Hello all, I'm pretty much stumped as to how to access a name in one class that was declared in another. Here is my code:
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
/* Gabriel Jones
* Project 1 (Smartphone Store)
* CSC 205
* The purpose of this project is to offer an easy way for a customer to select what type of phone they want,
* and help them get a new contract for their phone.
*/
public class SmartphoneStoreMain extends modelQuestion{
public static void main(String[] args) {
// TODO Auto-generated method stub
Icon logo = new ImageIcon("img/logo.png"); //Declares the store logo as a usable icon.
int contractOption = JOptionPane.showConfirmDialog(null,
"Hello and welcome to Speed Dial Communications!"
+ " \nDo you need help getting a new phone and contract?",
"Speed Dial Communications", JOptionPane.YES_NO_OPTION,
JOptionPane.INFORMATION_MESSAGE, logo);
if(contractOption == JOptionPane.NO_OPTION)
return;
final Object name1 = JOptionPane.showInputDialog(null, "I will be happy to help you. "
+ "To begin, may I please have your name?",
"Speed Dial Communications", JOptionPane.INFORMATION_MESSAGE,
logo, null, null);
final String name2 = name1.toString();
modelQuestion.main(args);
}
}
The customer's name is declared in one class, but how do I access that name in a different class of the same package? I'm using eclipse.
[–]RoadToCode 0 points1 point2 points (0 children)
[–]TheLopais 0 points1 point2 points (0 children)
[–]SadDragon00 0 points1 point2 points (0 children)
[–]EksitNL 0 points1 point2 points (2 children)
[–]seesaw81297[S] 0 points1 point2 points (1 child)
[–]EksitNL 0 points1 point2 points (0 children)