Question: The language is java. Most of the code is already written except the StudentMain. Please write the code to fit the prompt. Also, please do

The language is java.
Most of the code is already written except the StudentMain. Please write the code to fit the prompt. Also, please do not use extremely complex java functions that a intro to computer science student should NOT know and WRITE comments too please.
 The language is java. Most of the code is already written
except the StudentMain. Please write the code to fit the prompt. Also,
The following THREE codes are for person, myday, and student.
import CS180Lab.MyDay;
/*
This class discribes a person with the following parameters
String : first name
String : last name
MyDate : date of birth
methods:
constructors
/o need for set method
get method
*/
public class Person
{
protected String fname;
private String lname;
private MyDay dob;
//default constructor
public Person()
{
//dummy person with no name, last name, and dob
}
//intial valued contructor
public Person(String n, String ln, MyDay d)
{
fname=n;
lname=ln;
dob=new MyDay(d); //create new MyDay object from given object MyDay d
}
public Person(Person a)
{
this(a.fname,a.lname,a.dob);
}
//set methods
public void setFirst(String n){fname=n;}
public void setLast(String l){lname=l;}
public void setDoB(MyDay d)
{
dob=new MyDay(d);
}
//get methods
public String getFirst(){return fname;}
public String getLast(){return lname;}
public MyDay getDoB(){return dob;}
public String toString()
{
return String.format("%s,%s[%s]",lname,fname,dob);
}
}
import CS180Lab.MyDay;
public class Student extends Person
{
private int grade[];
//methods and constructors
public Student()
{
super(); //call default contructor of super class
grade=new int[0]; /o grade
}
//initial values constructor
public Student(String n, String ln, MyDay d, int g[])
{
super(n,ln,d); //call initial valued contructor of super class
grade=new int[g.length];
for(int i=0;i
grade[i]=g[i]; //copy grades into grade array
}
public Student(Student s)
{
//this(s.fname,s.lname,s.dob,s.grade);
this(s.fname,s.getLast(),s.getDoB(),s.grade);
}
public int[] getGrade() {return grade;}
//override toString in subclass
public String toString()
{
String person=super.toString(); //explicit call
String gr="";
for(int i=0;i
gr=gr+grade[i]+" ";
return person+" "+gr;
}
}
package CS180Lab;
/*
Class describes a day object with three parameters:
day, month, year and
some methods:
Constructors, compareTo, and toString
*/
public class MyDay
{
private int day;
private int month;
private int year;
public MyDay()
{
day=1;
month=1;
year=1900;
}
public MyDay(int d,int m, int y)
{
//first make sure that year is between 1900 and 2018
if(y2018)
year=1900; //if year is not approriate make it 1900
else
year=y;
/ext make sure that month is betweeb 1 and 12
if(m>12 || m
month=1;
else
month=m;
/ow make sure tat day is between 1 and 28, or 29, 30, or 31
if(month==2) // if it is February
{
if(leap(year)) // if it is a leap year day is betwen 1-29
if(d>29)
day=1;
else
day=d;
else //else day is between 1-28
if(d>28)
day=1;
else
day=d;
}
else if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
if(d>31)
day=1;
else
day=d;
else
if(d>30)
day=1;
else
day=d;
}
public MyDay(MyDay d) // creating object from object
{
this(d.day,d.month,d.year); //call initial constructor
}
public void setDay(int n)
{
day=n;
}
public int getDay() { return day;}
public int getMonth(){ return month;}
public int getYear() { return year;}
public static int compareTo(MyDay a, MyDay b)
{
//convert two day into YYYYMMDD string and compare then using String comparision method
String str1=String.format("%4d%02d%02d",a.year,a.month,a.day);
String str2=String.format("%4d%02d%02d",b.year,b.month,b.day);
if(str1.compareTo(str2)
return 1;
else if(str1.compareTo(str2)>0)
return -1;
else
return 0;
}
public String toString()
{
return String.format("%02d/%02d/%4d",month,day,year);
}
public boolean leap(int y)
{
if((y%4==0 && y%100!=0)||y%400==0)
return true;
else
return false;
}
}
CS 180 Lab8(25 pts) Objective: Hierarchy, methods, and array of objects. In this lab, we will be implementing the following classes. Class Person Parameters: String first name String last name Day birth day Methods Default and Initial valued Constructors Set/get methods toString method Class Student Parameter Integer array to store grade Methods Default and Initial valued constructors Set/get methods toString method As we have implemented these classes during the lecture, they are available in the vlab In the StudentMain class you will do the following: In main method: Note: Always use objects to retrieve any data 1) 2) 3) 4) 5) Create 4 Person objects Create 4 Student objects Create array of size 8 of a Person class and assign those 8 objects into the array Print last and first name of all in sorting order[You must call sort method to sort objects) For all students: print their First name Last Name Min Max Average 6) Enter a random number, say k, between 0-7 from console If k-th object is a Person, display last name and birth year If k-th object is a Student display first name and last grade. Sort method takes array of a Person class and sorts the based on their last name

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!