Monday, September 26, 2016

CST 338 Week 4

Week 4

This week has been pretty difficult for me and I expect next week will be more challenging due to personal life conflicts with school. Despite that, while difficult, I feel that I was able to contribute to the group assignment pretty well this week. We worked really hard and I'd like to say we did everything correctly, but I'm still expecting to get a few points knocked off because that's how the past couple of assignment have been. My team has been great though and really powering through.

For the project, we focused on implementing a class based on the methods defined by an interface. We additionally got practice working with multiple java objects and having them interact.

Specific Prompts

Give an example of polymorphism and what what be inherited between classes.

An example of polymorphism would be a ProPlayer that inherits Player. ProPlayer would inherit the methods defined in Player, like getName(). However, ProPlayer can override methods in Player to create their own implementation. ProPlayer can add their player number to the getName() method. The only exception to this would be if the methods were defined as static.

After the learning this week, can you identify the difference between Abstract classes and Interfaces? Be specific.

Abstract classes and interfaces are similar in that they both will essentially contain method stubs that are intended to be implemented by a derived class (actually, they're enforced). The difference is that an interface is completely full of these stubbed out methods and an abstract class may have complete methods in addition to their stubbed out methods. Any class that inherits either of these will be required to implement the missing classes. In Java 7 and lower (I believe) one could only implement multiple interfaces and one abstract class, but I think Java 8 allows you to inherit multiple abstract classes now. The main difference is the method implementation differences, but there are other, more detailed, ones too.

1 comment: