Write a class called Student that extends the provided Perso

Write a class called Student that extends the provided Person class. Ensure that your student class is a concrete class. The foo method for a person should display (to standard output) the person\'s age and name in a nice way (e.g, \"Nigel\'s age is 14\"). When a person makes a noise it is their name repeated N times where N is the person\'s age.

public abstract class Person implements Noisy Person Class public String name; 3 ublic int age; s public abstract void foo); public interface Noisy 2 String noise) 1 public interface Noisy{ Noisy Interface 1 public interface Comparable 2 i Comparable Interface int compareTo(Type other); 1 public class Date 2 int day, month, year; Date Class public Date(int d, int m, int y){ dayd; month - m; year-y;

Solution

public class Student extends Person{

Student(String name, int age){

this.name = name;                                               // initialising the student properties

this.age = age;

}

public void foo(){

if(isNoisy()){                               //check if person makes noise

for(int i=0 ; i< age; i++ ){

System.out.print(\" \"+name+\" \");

}

}else{

System.out.println(name+\"\\\'s age is \"+age);

}

}

}

// Note: Information about the Noisy class is required.

Write a class called Student that extends the provided Person class. Ensure that your student class is a concrete class. The foo method for a person should disp

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site