Write a class called Person.java that has instance variables matric number, name, date of birth, and gender. Use appropriate data types for these instance variables. Include constructor and set and get methods for all instance variables.
public class Q1L6{
class Person {
String name;
int DOB;
int MatricNum;
char gender;
}
class printingPerson{
public static void main(String[] args) {
Student printingPerson = new Student();
System.out.println("Name: \t" + printingPerson.name);
System.out.println("Date of Birth:\t" + printingPerson.DOB);
System.out.println("Matric Number:\t" + printingPerson.MatricNum);
System.out.println("Gender:\t " + printingPerson.gender);
}//End Main Method
}
public givingPerson(String name,int DOB,int MatricNum,char gender ) {
printingPerson.name = name;
printingPerson.DOB = DOB;
printingPerson.MatricNum = MatricNum;
printingPerson.gender = gender;
}
//NAME
public name getName() {
return name;
}
//DOB
public DOB getDOB() {
return DOB;
}
//MATRIC NUMBER
public MatricNum getMatricNum() {
return MatricNum;
}
//GENDER
public gender getgender() {
return gender;
}
}