Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Project Inheritance-java Develop a Person class, that has the name, address, phy

ID: 3890484 • Letter: P

Question

Project Inheritance-java

Develop a Person class, that has the name, address, physical description (weight, height, eye color), gender, date of birth, age (to be calculated based on date of birth).

Have a class US Citizen that inherits the Person class (have a Boolean attribute, if true then generate a SSN automatically, otherwise make the SSN = 999 99 9999)-it is your choice to have the SSN as a String or an integer.

Develop two more classes Student and Teacher that both inherit US. Citizen class.

For the student class, has a student ID (generated automatically with every intention to an object), number of courses taken, an array listing the names of the courses taken by the student (an array of Strings) and the grade for each course (an array of int), the overall GPA for the student.

For the teacher class, we need an ID (generated automatically –like the student ID but make it start from a different number than the student), and number of Courses, and the names of the courses that this instructor is teaching.

Write a driver that tests the Student and the Teacher classes by instantiating different objects using default values, and asking the user to enter the information, and outputting the information for each object before and after modification.

If the student is not a US. Citizen then insert which visa does s/he have, using the following information

F1 Visa

Academic Studies

The "F" visa is for academic studies. An F1 visa is issued to students who are attending an academic program or English Language Program. F1 visas are by far the most common form of international student visa in the U.S. F1 students must maintain the minimum course load for full-time student status. F-1 status allows for part-time, on-campus employment (fewer than 20 hours per week). Additionally, students can work on optional practical training (OPT) for up to one year after completion of their academic program. Students are expected to complete their studies by the expiration date on the I-20 form (Certificate of Eligibility for Nonimmigrant Student Status).

J1 Visa

Practical Training

A J1 visa is issued to students who need to obtain practical training that is not available in their home country to complete their academic program. J-1 student status allows for similar employment as the F-1

visa, with similar restrictions, as long as permission is given by the exchange visitor program sponsor.

M1 Visa

Non-Academic / Vocational Studies

An M1 visa is issued to a student who is going to attend a non-academic or vocational school. M-1 visa holders for technical and vocational programs are not permitted to work during the course of their studies. The M-1 student visa applicants must have evidence that sufficient funds are immediately available to pay all tuition and living costs for the entire period of intended stay.

You can include the visa information in the Citizen class. Remember, we will assume that in order to be able to work in the united state you must be a US. Citizen.

Draw UMLfor each class and show the relationship between classes. Draw the UML for every instantiated object.
You must have the setters and getters to all attributes in all classes You must have a toString method in every class

Have a default constructor for every class, and at least one overloaded constructor for every class. Use Super as needed.
Validate a user’s entry when applicable.
Document your code properly. (Don’t forget @override when overriding)

------------------------------------- This is the code I have so far for the classes perosn, us_citizen, student and teacher-----------------------

public class person {
private String name;
private String address;
private int height;
private String Eye_color;
private String gender;
private int DOB;
private int age;


public person() {
name = "Rojin";
address = "34 Bayberryway Irvine Ca";
height = 173;
Eye_color = "brown";
gender = "female";
DOB = 1994;
age = 23;
}
public person (String name, String address, int height, String Eye_color, String gender, int DOB, int age)
{
this.name = name;
this.address = address;
this.height = height;
this.Eye_color = Eye_color;
this.gender = gender;
this.DOB = DOB;
this.age = age;
}
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
public String address(){
return address;
}
public void setAddress(String address){
this.address = address;
}
public int getHeight(){
return height;
}
public void setHeight(int height){
this.height = height;
}
public String getEye_color(){
return Eye_color;
}
public void setEye_color(String Eye_color){
this.Eye_color = Eye_color;
}
public String gender(){
return gender;
}
public void setGender(String gender){
this.gender = gender;
}
public int DOB(){
return DOB;
}
public void setDOB(int DOB){
this.DOB = DOB;
}
public int age(){
return age;
}
public void setAge(int age){
this.age = age;
}
}
---------------------------------------------------------------------------

public class us_citizen extends person {
private int SSN;
  
public us_citizen(){
super();
SSN = 183264964;
  
}
public us_citizen(int SSN){
this.SSN = SSN;
}
public us_citizen(String name, String address, int height, String Eye_color, String gender, int DOB, int age)
{
super(name, address, height, Eye_color, gender, DOB, age);
this.SSN=SSN;
}
public int getSSN(){
return SSN;
}
public void setSSN( int SSN){
this.SSN = SSN;
}

}

---------------------------------------------

public class student extends us_citizen {
private int Student_ID;
private int Number_courses;
  
public student(){
super();
Student_ID = 17376682;
Number_courses = 5;
}
  
public student(int Student_ID, int Number_courses){
this.Student_ID=Student_ID;
this.Number_courses=Number_courses;
  
}
public student (int SSN, int Student_ID, int Number_courses){
super(SSN);
this.Student_ID=Student_ID;
this.Number_courses=Number_courses;
  
}
public int getStudent_ID(){
return Student_ID;
}
public int getNumber_courses(){
return Number_courses;
  
}
public void setStudent_ID(int Student_ID){
this.Student_ID = Student_ID;
}
public void setNumber_courses(int Number_courses){
this.Number_courses = Number_courses;
}
}

---------------------------------------------------------------

public class teacher extends us_citizen {
private int teacher_ID;
private int teaching_courses_number;
private String course_name;
  

public teacher () {
super();
teacher_ID = 13596682;
teaching_courses_number = 4;
course_name = "CECS277";

}

public teacher (int SSN, int teacher_ID, int teaching_courses_number, String course_name){
super (SSN);
this.teacher_ID = teacher_ID;
this.teaching_courses_number = teaching_courses_number;
this.course_name = course_name;
}
public int getTeacher_ID(){
return teacher_ID;
  
}
public void setTeacher_ID(int teacher_ID){
this.teacher_ID = teacher_ID;
}
public int getTeaching_courses_number (){
return teaching_courses_number;
}
public void setTeaching_courses_number(int teaching_courses_number){
this.teaching_courses_number=teaching_courses_number;
  
}
public String getCourse_name(){
return course_name;
}
public void setCourse_name(String course_name){
this.course_name = course_name;
  
}
}

--------------------------------------------------------

public class driver{

public static void main(String[] args) {
// For Auto-generated method
person p = new person();
us_citizen us = new us_citizen();
student stu = new student();
teacher tea = new teacher();
System.out.println(p);
System.out.println(us);
System.out.println(stu);
System.out.println(tea);
  
}
}
  

Explanation / Answer

see below code, comments are added whenever necessary

and please give u a feedback, to work for you in consistent manner, if any doubt exists plase ask me in the comments,

thanks

Code:

import java.util.Date;

public class person

{

private String name;

private String address;

private int height;

private String Eye_color;

private String gender;

private Date DOB;// DOB is of Type Date

private int age;

public person() {

name = "Rojin";

address = "34 Bayberryway Irvine Ca";

height = 173;

Eye_color = "brown";

gender = "female";

DOB = new Date();

age = 23;

}

public person (String name, String address, int height, String Eye_color, String gender, Date DOB)

{

this.name = name;

this.address = address;

this.height = height;

this.Eye_color = Eye_color;

this.gender = gender;

this.DOB = DOB;

this.age = calculateAge(DOB);

}

private int calculateAge(Date dOB2)

{

Date currentDate=new Date();

int cyear=currentDate.getYear();

int dobyear=dOB2.getYear();

return cyear-dobyear;

}

public String getName(){

return name;

}

public void setName(String name){

this.name = name;

}

public String address(){

return address;

}

public void setAddress(String address){

this.address = address;

}

public int getHeight(){

return height;

}

public void setHeight(int height){

this.height = height;

}

public String getEye_color(){

return Eye_color;

}

public void setEye_color(String Eye_color){

this.Eye_color = Eye_color;

}

public String gender(){

return gender;

}

public void setGender(String gender){

this.gender = gender;

}

public Date getDOB(){

return DOB;

}

public void setDOB(Date DOB){

this.DOB = DOB;

}

public int age(){

return age;

}

public void setAge(int age){

this.age = calculateAge(getDOB());

}

}

import java.util.Date;

import java.util.Random;

public class us_citizen extends person

{

//SSN is made String

private String SSN;

//boolean value indicated whether person is us_citizen ir not.

private boolean isCitizen;

  

public us_citizen(){

super();

SSN = "999999999";

  

}

public us_citizen(boolean isCitizen)

{

//if us citizen then value is generated automatically and assigned.

if(isCitizen)

{

setSSN();

}

this.SSN="999999999";

}

public us_citizen(String name, String address, int height, String Eye_color, String gender, Date DOB, int age)

{

super(name, address, height, Eye_color, gender, DOB);

setSSN();

}

public String getSSN(){

return SSN;

}

public void setSSN()

{

Random rand=new Random();

this.SSN =String.valueOf(rand.nextLong());

  

}

public boolean isCitizen() {

return isCitizen;

}

public void setCitizen(boolean isCitizen) {

this.isCitizen = isCitizen;

}

}

import java.util.Random;

public class student extends us_citizen {

private String Student_ID;

//Student id is made String, when large number of student will be there in school,

//some times int wont be able to hold that much big number

private int Number_courses;

  

public student(){

super();

Student_ID = "Student17376682";

Number_courses = 5;

}

  

public student(String Student_ID, int Number_courses){

this.Student_ID=Student_ID;

this.Number_courses=Number_courses;

  

}

public student (boolean isCitizen, String Student_ID, int Number_courses){

super(isCitizen);

this.Student_ID=Student_ID;

this.Number_courses=Number_courses;

  

}

public String getStudent_ID(){

return Student_ID;

}

public int getNumber_courses(){

return Number_courses;

  

}

public void setStudent_ID()

{

//this method set the student_id automatically

Random rand=new Random();

int randNo=rand.nextInt();

this.Student_ID = "Student"+randNo;

}

public void setNumber_courses(int Number_courses){

this.Number_courses = Number_courses;

}

}

public class teacher extends us_citizen {

private String teacher_ID;

//made to string , because of same reason as that of student class.

private int teaching_courses_number;

private String course_name;

  

public teacher ()

{

super();

teacher_ID = "Teacher13596682";

teaching_courses_number = 4;

course_name = "CECS277";

}

public teacher (boolean isCitizen, String teacher_ID, int teaching_courses_number, String course_name){

super (isCitizen);

this.teacher_ID = teacher_ID;

this.teaching_courses_number = teaching_courses_number;

this.course_name = course_name;

}

public String getTeacher_ID()

{

return teacher_ID;

}

public void setTeacher_ID(String teacher_ID){

this.teacher_ID = teacher_ID;

}

public int getTeaching_courses_number (){

return teaching_courses_number;

}

public void setTeaching_courses_number(int teaching_courses_number){

this.teaching_courses_number=teaching_courses_number;

  

}

public String getCourse_name(){

return course_name;

}

public void setCourse_name(String course_name){

this.course_name = course_name;

  

}

}

import java.rmi.StubNotFoundException;

import java.util.Scanner;

public class driver{

public static void main(String[] args)

{

Scanner sc=new Scanner(System.in);

System.out.println("Are you 1.Student or 2.Teacher");

int i=sc.nextInt();

if(i==1)

{

System.out.println("Hey student, Enter your name:");

String name= sc.nextLine();

student stud=new student();

stud.setName(name);

System.out.println("Do you want to modify your records y/n?");

String choice=sc.nextLine();

if(choice.equals("y"))

{

System.out.println("Before modification");

System.out.println("Name: "+stud.getName()+" Height: "+stud.getHeight());

System.out.println("Enter height for modification");

int height=sc.nextInt();

stud.setHeight(height);

System.out.println("Before modification");

System.out.println("Name: "+stud.getName()+" Height: "+stud.getHeight());

}

else

{

return;

}

}

else

{

System.out.println("Hey Teacher, Enter your name:");

String name =sc.nextLine();

teacher teach=new teacher();

teach.setName(name);

System.out.println("Do you want to modify your records y/n?");

String choice=sc.nextLine();

if(choice.equals("y"))

{

System.out.println("Before modification");

System.out.println("Name: "+teach.getName()+" Height: "+teach.getHeight());

System.out.println("Enter height for modification");

int height=sc.nextInt();

teach.setHeight(height);

System.out.println("Before modification");

System.out.println("Name: "+teach.getName()+" Height: "+teach.getHeight());

}

else

{

return;

}

}

  

  

}

}