Last active
November 25, 2021 13:47
-
-
Save HW-Lee/80116e671c27e5488be26031d2419391 to your computer and use it in GitHub Desktop.
TaiwanConsensus
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
public abstract class People { | |
abstract public String getNationality(); | |
abstract public String getAdjective(); | |
public interface Thinkable { | |
String getOppose(); | |
String getConsensus(); | |
} | |
public String getDeclaration() { | |
StringBuilder builder = new StringBuilder(); | |
if (!(this instanceof Thinkable)) | |
return builder.append("I'm a person from ").append(getNationality()).append(". ^^").toString(); | |
return builder.append("The ").append(getAdjective()) | |
.append(" will never accept ").append(((Thinkable) this).getOppose()).append(". Instead, ") | |
.append("\"").append(((Thinkable) this).getConsensus()).append("\" ") | |
.append("is the consensus of the vast majority of ").append(getAdjective()).append(".") | |
.toString(); | |
} | |
} |
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 android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.widget.TextView; | |
public class TaiwanConsensusActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
TextView tv = findViewById(R.id.text_view); | |
tv.setText(new ThinkableTaiwanese().getDeclaration()); | |
} | |
} |
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
public class Taiwanese extends People { | |
@Override | |
public String getNationality() { | |
return "Taiwan"; | |
} | |
@Override | |
public String getAdjective() { | |
return "Taiwanese"; | |
} | |
} |
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
public class ThinkableTaiwanese extends Taiwanese implements People.Thinkable { | |
@Override | |
public String getOppose() { | |
return "one country, two systems"; | |
} | |
@Override | |
public String getConsensus() { | |
return "Taiwan is a sovereign-independent country"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment