Skip to content

Instantly share code, notes, and snippets.

@josinSbazin
Created June 21, 2016 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josinSbazin/bedf5a61f54b8d331db3c95d2890a499 to your computer and use it in GitHub Desktop.
Save josinSbazin/bedf5a61f54b8d331db3c95d2890a499 to your computer and use it in GitHub Desktop.
level15.lesson12.home10
package com.javarush.test.level15.lesson12.home10;
/* ООП - наследование
Исправить класс Hrivna так, чтоб избежать ошибку StackOverflowError, класс Money менять нельзя.
*/
public class Solution {
public static void main(String[] args) {
System.out.println(new Hrivna().getAmount());
}
public static abstract class Money {
abstract Money getMoney();
public Object getAmount() {
return getMoney().getAmount();
}
}
//add your code below - добавь код ниже
public static class Hrivna extends Money {
public double amount = 123d;
@Override
public Object getAmount() {
return (Double) amount;
}
public Hrivna getMoney() {
return this;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment