Created
June 21, 2016 20:34
-
-
Save josinSbazin/bedf5a61f54b8d331db3c95d2890a499 to your computer and use it in GitHub Desktop.
level15.lesson12.home10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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