Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Simple Java Inheritance practice problem Description Write a class Person.java that acts as a person with Strings to hold their name and address. This class
Simple Java Inheritance practice problem
Description Write a class Person.java that acts as a person with Strings to hold their name and address. This class should also contain: A constructor, Person (String name, String address) Getters and Setters for name and address, respectively. . o String getName () o void setName (String name) o String getAddress () o void setAddress (String address) In addition, you will also create two subclasses of Person called Student.java and Professor.java. The Student class should contain: Unique Instance Variables: o String[] courses o char[] grades A constructor, Student(String name, string address) o You should initialize courses and grades here. - A new student's course array should have all entries as "none'" A new student's grades array should have all entries as A . A student can take at most 6 courses, therefore both courses and grades should be of length 6 Getters for courses and grades A unique method, boolean addCourse (string course) o This method will enroll the student in the given course so long as: . They are not currently enrolled in the course. . They are not already taking 6 courses, i.e. one or more entries in their courses array is none O New courses should be added to thelowest-numbered available slotin the courses arrayStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started