Created
April 8, 2021 04:25
-
-
Save sairajm/0d819c00240435f223472e76ef8d145b to your computer and use it in GitHub Desktop.
Java packages example
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.example.shapes; | |
public class Circle implements Shapes { | |
@Override | |
public String getShape() { | |
return "Circle"; | |
} | |
@Override | |
public String getColor() { | |
return "Red"; | |
} | |
} |
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.example.tools; | |
public class Hammer implements Tools { | |
@Override | |
public String getTool() { | |
return "Hammer"; | |
} | |
@Override | |
public String getSize() { | |
return "7"; | |
} | |
} |
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
import com.example.shapes.Circle; | |
import com.example.shapes.Shapes; | |
import com.example.shapes.Square; | |
import com.example.tools.Hammer; | |
import com.example.tools.Tools; | |
import com.example.tools.Wrench; | |
public class Main { | |
public static void main(String args[]) { | |
Shapes circle = new Circle(); | |
Shapes square = new Square(); | |
Tools hammer = new Hammer(); | |
Tools wrench = new Wrench(); | |
} | |
} |
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.example.shapes; | |
public interface Shapes { | |
public String getShape(); | |
public String getColor(); | |
} |
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.example.shapes; | |
public class Square implements Shapes { | |
@Override | |
public String getShape() { | |
return "Square"; | |
} | |
@Override | |
public String getColor() { | |
return null; | |
} | |
} |
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.example.tools; | |
public interface Tools { | |
public String getTool(); | |
public String getSize(); | |
} |
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.example.tools; | |
public class Wrench implements Tools { | |
@Override | |
public String getTool() { | |
return "Wrench"; | |
} | |
@Override | |
public String getSize() { | |
return "6"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment