Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

User input in class constructors OOP

$
0
0
I have setters and getters to receive an employee's name and can run the program fine when I set the name as something, but have trouble receiving a name from the user?

Constructor class:

public class employeeName {

	private String name;

   	public String showName ( ) { //do I need to put a getLine or scanner here?
	   return name;
	}

	public String setName(String Name) {
	   name = Name;
	   return Name;
	}

}


main class
public class employeeInformation
 {

	public static void main ( String [ ] args ) {

	employeeName n1 = new employeeName ( );

	

	n1.setName (  );//not sure what to put here 

	System.out.println ( "The employee's name is " + n1.showName ( ) ); 
  
	}
}

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>