Question: Inheritance Workshop - Please Answer complete post (break it up into multiple steps if needed) - I really need help and need this post answered
Inheritance Workshop - Please Answer complete post (break it up into multiple steps if needed) - I really need help and need this post answered completely. 




Again, please please answer the complete post. Thank you!
5. As a group, come up with another example of a has-a relationship. a. Which class is the instance variable? b. What is the other class? "Adapted from POGIL Activities for CS py meien mu. nIs work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License Inheritance Workshop \#1 pg 5 of 7 c. State the relationship between your two classes using the phrase "has a". 6. As a group, come up with an example of an is-a relationship. a. Which class is the more general class? b. Which class is the more specialized class? c. State the relationship between your two classes using the phrase "every is a 7. Consider the BlackJackCard and PlayingCard classes again, especially your answer to CTQ 2e. a. How could this extra method be implementing by adding an instance variable? 6. As a group, come up with an example of an is-a relationship. a. Which class is the more general class? b. Which class is the more specialized class? c. State the relationship between your two classes using the phrase "every is a 7. Consider the BlackJackCard and PlayingCard classes again, especially your answer to CTQ 2e. a. How could this extra method be implementing by adding an instance variable? b. How could this extra method be implementing by adding code instead of an instance variable? c. Which class would you add the instance variable or new code to? The more general class is typically known as the parent class, super class, or base class. The more specific class is typically know as the child class, sub class, or derived class. The Java keyword extends allows you to indicate that one class should be the child class of the original parent class. The child will then inherit everything from the parent class, including variables and methods. Consider the Person and Student classes below: public class student extends Person \{ private int studentid; \} *Adapted from POGIL Activities for CS by Helen Hu. This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License Inheritance Workshop \# 1 pg6 of 7 private string name; public void setName (String nameofPerson) \{ name = nameofPerson; \} public string getName () \{ private string name; public void setName (String nameofPerson) \{ name = nameofPerson; public String getName() \{ return name; \} public String tostring() \{ return "Person: " name; public boolean equals (Person other) \{ return this.name. equals (other.name); \} ritical Thinking Questions 8. Examine the Person class. a. Identify the instance variable in the Person class. b. Has the variable been declared as public or private? c. Identify the methods that are in the Person class. d. Have they been declared as public or private? e. What do the access modifiers (public or private) mean for how the Student class may use the instance variable and methods that it inherits from the Person class? 9. Now consider the Student class. a. What instance variable is declared in the Student class? b. What methods are missing from the Student class that would usually be present, given that its instance variable is private? *Adapted from POGIL Activities for CS by Helen Hu. This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License nheritance Workshop \#1 pg7 of 7 c. What instance variable has been inherited from the Person class? d. What methods have been inherited from the Person class? e. Examine the code from the inherited methods in the Person class. Which of these inherited methods are appropriate as-is for the Student class? f. Which of the inherited methods are not quite appropriate for the Student class? Explain what is missing from these methods
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
