I NEED THIS ANSWER IN NETBEANS ONLY-You will create a Virtual World application
ID: 3598743 • Letter: I
Question
I NEED THIS ANSWER IN NETBEANS ONLY-You will create a Virtual World application as your final project. This Virtual World will have several objects including a MyClone object and another object of your choice. It would be an excellent idea to review the Final Project Guidelines at this time. For this Third Final Project Milestone, you will finish development of your MyClone class and create another class of your choice. In Module Two, you started development of the MyClone class. You will continue to develop the MyClone class by adding accessor methods, mutator methoda, and an introduction() method. The introduction() method will introduce yourself to the virtual world by displaying a greeting, your first and last name, and anything else you would want to say. You will also create another class of your choice. Your programmer-defined class should have at a minimum two instance variables and one method. The instance variables and method should be representative of the data and behavior that objects of this class will have. You will demonstrate your understanding of encapsulation by declaring the instance varibales as private and by creating accessors and mutatora for each instance variable. You should have at least one constructor created that initializes all instance variables. Document your code.
Explanation / Answer
public class VirtualWorld {
//Data members of VirtualWorld
private static MyClone clone;
private static Student student;
public static void main(String[] args) {
//Creating objects of MyClone and Student
clone=new MyClone("Mathew", "Wade");
student= new Student("Yuvraj Singh", 25);
clone.introduction();//displaying clone data
System.out.println("*******************************************");
student.displayStudentDetails();//displayinfg student data
}
}
public class Student {
//Private data members
private String name;
private int age;
//Constructor
public Student(String name, int age) {
this.name = name;
this.age = age;
}
//Setter getter
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
//Method to display data
public void displayStudentDetails() {
System.out.println("Student details are:");
System.out.println("Name: "+getName());
System.out.println("Age: "+getAge());
}
}
public class MyClone {
//Private data members
private String firstName;
private String lastName;
//Constructor to create MyClone objects
public MyClone(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
//Setters getters
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
//Introduction method to display
public void introduction() {
System.out.println("Hi "+getFirstName()+" "+getLastName()+". Welcome to the Virtual World");
}
}
*********************************************************************************************************************
I hope this helps you.
If you find my answer helpful,
Kindly rate the answer.
All the best :)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.