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

refurn Pinal txan 40 points Question #1 a) Crea te a class Sehoolkid that is the

ID: 3732075 • Letter: R

Question

refurn Pinal txan 40 points Question #1 a) Crea te a class Sehoolkid that is the base class for children at a school. It should have attributes for the child's name and age, the nane of the child's teacher, and a greeting. accessor and mutator nethods for each of the attributes ) Derive a class Exaggeratingkid from sehoolkid. The new class should override the accessor . It also should override the accessor tor method for the age, reporting the actual age plus a the greeting, returning the child'a greeting concatenated with the worda "I am the best c) Create teating class 40 points Question 2 an abetzact class DiacountPolicy, It should have a aingle abstract method computeDiacount that wi1 return the discount trom the purchase ot a given number ot a singie stem. The method has two parameters, count and itemcost conatructor that b) Derive a class buywztemadetonePree trom Discount Policy. It should have a has a single parameter n· The data member of this class will be n. In addition, the elass should define the method computeDiscount so that every nth item is free. For example, if n is 3 and the eustomer buys 7 itema and the cost of each item is $10, then the discount vill be $20 since every 3rd item will be free. If n ia 4 and the cost of each item is $10 and if the user buys 7 items, then the diacount will be $10. c) Create testing class Question #3 20 point Create a LeftArrow class that derives from the Shape class. tail 8 head 11 head/25 head/2-1 4 0 1 3 head/2-2

Explanation / Answer

//test.java Question1


class SchoolKid
{
    String name;
    int age ;
    String nameOfTeacher;
    String greeting;

    public SchoolKid(String name,int age,String nameOfTeacher,String greeting )
    {
        this.name = name;
        this.age = age;
        this.nameOfTeacher = nameOfTeacher;
        this.greeting = greeting;
    }

    String getStudentName()
    {   return this.name;
    }

    int getStudentage()
    {   return this.age;
    }
  
    String getnameOfTeacher()
    {   return this.nameOfTeacher;
    }

    String getgreeting()
    {   return this.greeting;
    }

    void setStudentName(String name)
    {   this.name = name;
    }

    void setStudentage(int age)
    {   this.age = age ;
    }
  
    void setnameOfTeacher(String nameOfTeacher)
    {   this.nameOfTeacher = nameOfTeacher;
    }

    void setgreeting(String greeting)
    {   this.greeting = greeting;
    }

  

}

class ExaggeratingKid extends SchoolKid
{
    public ExaggeratingKid(String name,int age,String nameOfTeacher,String greeting)
    {   super(name,age,nameOfTeacher,greeting);
    }
  
    int getStudentage()
    {   return this.age + 2;
    }
  
    String getgreeting()
    {   return "I am the best. " + this.greeting ;
    }

}

public class test
{
    public static void main(String[] args)
    {
        SchoolKid schoolkid = new SchoolKid("John",12,"Adrew","Hello Good Morning");
        ExaggeratingKid exaggeringkid = new ExaggeratingKid("David",11,"Mike","Good Day") ;
        System.out.println(schoolkid.getStudentName() + " age : " + schoolkid.getStudentage() + " Teacher : " + schoolkid.getnameOfTeacher() + " Greeting : " + schoolkid.getgreeting());
        System.out.println(" "+exaggeringkid.getStudentName() + " age : " + exaggeringkid.getStudentage() + " Teacher : " + exaggeringkid.getnameOfTeacher() + " Greeting : " + exaggeringkid.getgreeting());
      

    }

}