Hackerrank Day 13: Abstract Classes


My Solution in Java 8: 

Hacker Rank did not allow submissions in Ruby or Javascript for this problem so I got to experiment with Java!  Syntax was pretty similar to Javascript so it wasn’t too difficult.  Took me a while to solve because I didn’t know to declare price as private.

A couple things to note:

  • You must implement the abstract method in your subclass
  • To pass a new argument into the subclass (that wasn’t in the parent class), declare it as private or public first, then define it as an instance variable.


Hackerrank Day 13: Abstract Classes

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s