我希望能够根据用户输入动态创建员工对象。我有两种不同的课程,一种已经成为经理,另一种已经成为经理。我应该能够输入要创建的员工类型以及该员工的姓名和年龄。 我该怎么办?
while (true){
System.out.print("Input the type of employee: ");
String type = Input.next();
//Can only be "manager" or "associate"
System.out.print("Input the name of the employee: ");
String name = Input.next();
System.out.print("Input the age of the employee: ");
int age = Input.nextInt();
/*The name of the object should also be the name of the employee
*Depending on what "Type" is given from the user determines what type of object the new object is going to be
*/
type name = new type(name,age)
//type is not the reference type but a variable holding the reference *type
*/
}
我希望我应该能够创建任意数量的引用类型为对象的对象:管理器或关联对象。不同的名字和年龄