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

Java Inheritance 1,Eassy class Design an Essay class that extends the GradedActi

ID: 3547639 • Letter: J

Question

Java Inheritance



1,Eassy class


Design an Essay class that extends the GradedActivty class presented in this chapter. the Essay class should determine the grade a student receives for an essay. The student's essay score can be up to 100 and is determined in the following manner:


Grammar: 30 points

Spelling: 20 points

Correct lenght: 20 points

Content: 30 points



Demonstrate the class in a simple program.









2,Person and Customer Classes


Design a class named Person with fields for holding a person's name, address, and telephone number. Write one or more constructors and the appropriate mutator and accessor methods for the class's fields.



Next, design a class named Customer, which extends the Person class. The Customer class should have a field for a customer number and a boolean field indicating whether the customer wishes to be on a mailing list. Write one or more constructors and the appropriate mutator and accessor methods for the class's fields. Demonstrate an object of the Customer class in a simple program.

Explanation / Answer

In Question -1, please provide GradedActivty class.


For Question-2, please find the classes below :


Person Class :


public class Person {


private String name;

private String address;

private int telephoneNumber;

public Person() {


}


public Person(String name, String address, int telephoneNumber) {


this.name=name;

this.address=address;

this.telephoneNumber=telephoneNumber;

}

public String getName() {

return name;

}


public void setName(String name) {

this.name = name;

}


public String getAddress() {

return address;

}


public void setAddress(String address) {

this.address = address;

}


public int getTelephoneNumber() {

return telephoneNumber;

}


public void setTelephoneNumber(int telephoneNumber) {

this.telephoneNumber = telephoneNumber;

}

}


Customer Class :

public class Customer extends Person {


private int customerNumber;

private boolean requireMailingList;

public Customer() {


}

public Customer(int customerNumber,boolean requireMailingList) {

this.customerNumber=customerNumber;

this.requireMailingList=requireMailingList;

}


public Customer(String name, String address, int telephoneNumber,int customerNumber,boolean requireMailingList) {

super(name, address, telephoneNumber);

this.customerNumber=customerNumber;

this.requireMailingList=requireMailingList;

}

public int getCustomerNumber() {

return customerNumber;

}


public void setCustomerNumber(int customerNumber) {

this.customerNumber = customerNumber;

}


public boolean isRequireMailingList() {

return requireMailingList;

}


public void setRequireMailingList(boolean requireMailingList) {

this.requireMailingList = requireMailingList;

}


// This method is to print the values in the object

public void printDetails() {

System.out.println("The created object has the following values : name " + this.getName() + " address " + this.getAddress()

+ " telephoneNumber " + this.getTelephoneNumber() + " customerNumber " + this.getCustomerNumber() + " requireMailingList " + requireMailingList

);

}

}

CreateObject Class to see the created object :


public class CreateObject {


public static void main(String[] args) {

Customer c = new Customer("James", "newyork", 1234567, 888, true);

c.printDetails();

}

}

The created object has the following values : name James address newyork telephoneNumber 1234567 customerNumber 888 requireMailingList true


I hope this will help.

Please feel free to write to me on sharadsrivastava005@gmail.com in case of any issue/query.


Thanks


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote