Merge branch 'bird-v1' of github.com:kanmaytacker/fundamentals

This commit is contained in:
Tanmay 2022-09-07 19:46:17 +01:00
commit 8d06e862bf
5 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,16 @@
package com.scaler.lld.bird;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor
@Getter
public abstract class Bird {
private Integer weight;
private String colour;
private String size;
private String beakType;
private BirdType type;
public abstract void fly();
}

View File

@ -0,0 +1,5 @@
package com.scaler.lld.bird;
public enum BirdType {
Eagle, Penguin, Parrot
}

View File

@ -0,0 +1,14 @@
package com.scaler.lld.bird;
public class Eagle extends Bird {
public Eagle(Integer weight, String colour, String size, String beakType, BirdType type) {
super(weight, colour, size, beakType, type);
}
@Override
public void fly() {
System.out.println("\nEagle is flying");
}
}

View File

@ -0,0 +1,14 @@
package com.scaler.lld.bird;
public class Parrot extends Bird {
public Parrot(Integer weight, String colour, String size, String beakType, BirdType type) {
super(weight, colour, size, beakType, type);
}
@Override
public void fly() {
System.out.println("\nParrot is flying");
}
}

View File

@ -0,0 +1,11 @@
package com.scaler.lld.bird;
public class Runner {
public static void main(String[] args) {
Bird parrot = new Parrot(10, "Green", "Small", "Sharp", BirdType.Parrot);
parrot.fly();
Bird eagle = new Eagle(20, "Brown", "Medium", "Sharp", BirdType.Eagle);
eagle.fly();
}
}