public class Application {
public static void main(String args[]){
User user=new User();
for(int i=0;i<5;i++){
user.setAccount(i);
user.select();
user.playGame();
System.out.println();
}
}
}
public class User {
Character role;
int account;
void setRole(Character role) {
this.role = role;
}
void select(){
int account1=account%6;
switch (account1){
case 0:Swordsman swordsman=new Swordsman("帅气的服装","帅气的头发","帅气的外表","Swordsman");
setRole(swordsman);
break;
case 1:Thief thief=new Thief("黑色的服装","黑色的头发","伪装的外表","Thief");
setRole(thief);
break;
case 2:Constable constable=new Constable("官府的服装","官方的发型","官方权威的外表","Constable");
setRole(constable);
break;
case 3:Civilian civilian=new Civilian("普通的服装","普通的头发","普通的外表","Civilian");
setRole(civilian);
break;
default:OfficerZhiFu zhiFu=new OfficerZhiFu("官方的服装","官方的头发","官方的外表","ZhiFu");
setRole(zhiFu);
break;
}
}
void setAccount(int account1){
account=account1;
}
void playGame(){
role.playGame();
}
}
abstract public class Character {
String clothes;
String hairColor;
String appearance;
String name;
abstract void walk();
abstract void run();
abstract void show();
abstract void speak();
abstract void playGame();
public Character(String clothes,String hairColor,String appearance,String name){
this.clothes=clothes;
this.hairColor=hairColor;
this.appearance=appearance;
this.name=name;
}
}
class Civilian extends Character{
public Civilian(String clothes,String hairColor,String appearance,String name){
super(clothes,hairColor,appearance,name);
}
void walk() {
System.out.println("普通地走");
}
void run() {
System.out.println("普通地跑:时速10Km/h");
}
void show() {
System.out.println("普通地展示:"+this.clothes+" "+this.hairColor+" "+this.appearance+" "+this.name);
}
void speak() {
System.out.println("普通地说话:我赢了");
}
void playGame(){
walk();
run();
show();
speak();
}
}
class Constable extends Character{
public Constable(String clothes,String hairColor,String appearance,String name){
super(clothes,hairColor,appearance,name);
}
void walk() {
System.out.println("威风地走");
}
void run() {
System.out.println("威风地跑:时速30Km/h");
}
void show() {
System.out.println("威风地展示:"+this.clothes+" "+this.hairColor+" "+this.appearance+" "+this.name);
}
void speak() {
System.out.println("威风地说话:我赢了");
}
void playGame(){
walk();
run();
show();
speak();
}
}
class Swordsman extends Character{
public Swordsman(String clothes,String hairColor,String appearance,String name){
super(clothes,hairColor,appearance,name);
}
void walk() {
System.out.println("帅气地走");
}
void run() {
System.out.println("帅气地跑:时速50Km/h");
}
void show() {
System.out.println("帅气地展示:"+this.clothes+" "+this.hairColor+" "+this.appearance+" "+this.name);
}
void speak() {
System.out.println("依本大侠看,帅气地说话……:我赢了");
}
void playGame(){
walk();
run();
show();
speak();
}
}
class Thief extends Character{
public Thief(String clothes,String hairColor,String appearance,String name){
super(clothes,hairColor,appearance,name);
}
void walk() {
System.out.println("偷偷摸摸地走");
}
void run() {
System.out.println("偷偷摸摸地跑:时速40Km/h");
}
void show() {
System.out.println("偷偷摸摸地展示:"+this.clothes+" "+this.hairColor+" "+this.appearance+" "+this.name);
}
void speak() {
System.out.println("偷偷摸摸地说话:我赢了");
}
void playGame(){
walk();
run();
show();
speak();
}
}
class OfficerZhiFu extends Character {
public OfficerZhiFu(String clothes,String hairColor,String appearance,String name){
super(clothes,hairColor,appearance,name);
}
void walk() {
System.out.println("官方地走");
}
void run() {
System.out.println("官方地跑:时速25Km/h");
}
void show() {
System.out.println("官方地展示:"+this.clothes+" "+this.hairColor+" "+this.appearance+" "+this.name);
}
void speak() {
System.out.println("依本知府看,官方发言:……");
}
void sentence(){
System.out.println("升堂审案");
}
void playGame(){
walk();
run();
show();
speak();
sentence();
}
}