Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Voce implements Comparable<Voce>{
- private String ime;
- private double zapremina;
- public Voce(String ime, double zapremina) {
- this.ime = ime;
- this.zapremina = zapremina;
- }
- public String getIme() {
- return ime;
- }
- public double getZapremina() {
- return zapremina;
- }
- @Override
- public String toString() {
- return "Voce [ime=" + ime + ", zapremina=" + zapremina + "]";
- }
- @Override
- public int compareTo(Voce o) {
- return Double.compare(this.zapremina, o.getZapremina());
- }
- }
- /-----------------------------------------------------------------------
- public class Jabuka extends Voce{
- private boolean crvljivo;
- public Jabuka(String ime, double zapremina, boolean crvljivo) {
- super(ime, zapremina);
- this.crvljivo = crvljivo;
- }
- public boolean isCrvljivo() {
- return crvljivo;
- }
- }
- /-----------------------------------------------------------------------
- public class Ananas extends Voce{
- public Ananas(String ime, double zapremina) {
- super(ime, zapremina);
- // TODO Auto-generated constructor stub
- }
- @Override
- public double getZapremina() {
- return super.getZapremina() * 0.5;
- }
- }
- /-----------------------------------------------------------------------
- public interface Kontejner {
- public double zapremina();
- public int komada();
- }
- /-----------------------------------------------------------------------
- public interface Cediljka {
- public void cedi();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement