Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.learning;
- abstract class Smartphone {
- protected final String name;
- public Smartphone(String name) {
- this.name = name;
- }
- public String getName() {
- return name;
- }
- }
- class Iphone extends Smartphone {
- public Iphone() {
- super("Iphone");
- }
- }
- class Nokia extends Smartphone {
- public Nokia() {
- super("Nokia");
- }
- }
- interface SmartphoneProducer {
- Smartphone produce();
- }
- final class ChinaProducer implements SmartphoneProducer {
- public Smartphone produce() {
- return new Iphone();
- }
- }
- final class NonExistentProducer implements SmartphoneProducer {
- public Smartphone produce() {
- return new Nokia();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment