用介面,寫乙個簡單的小遊戲

2021-10-08 06:24:35 字數 3836 閱讀 9097

role介面:角色攻擊跟修煉

public

inte***ce

role

magicstick 介面:法師用的法杖

public

inte***ce

magicstick

weapon 介面:戰士適用的**

public

inte***ce

weapon

法師所使用的兩種法杖類

public

class

greenstick

implements

magicstick

else

}

public

class

blackstick

implements

magicstick

else

}

法師類:法師的一些基本資訊

public

class

magicer

extends

namedrole

@override

public

void

practise()

else

}public

magicer

(string name, magicstick stick,

int level)

public

magicer

(int age, magicstick stick,

int level)

public

magicer

(string name,

int age,

int level)

public

magicer

(string name)

public

magicer

(int age)

public

magicer

(string name,

int age)

public magicstick getstick()

public

void

setstick

(magicstick stick)

public

intgetlevel()

public

void

setlevel

(int level)

}

戰士的**類1

public

class

bolo

implements

weapon

@override

public

intfire()

else

}public soldier gets()

public

void

sets

(soldier s)

public

intgetage()

public

void

setage

(int age)

}

戰士的**類2

public

class

pike

implements

weapon

@override

public

intfire()

else

}public

pike

(string name, soldier s)

public

pike

(soldier s)

public

pike

(string name)

public string getname()

public

void

setname

(string name)

public soldier gets()

public

void

sets

(soldier s)

戰士類:用來存放戰士的基本資訊

public

class

soldier

extends

namedrole

@override

public

void

practise()

public weapon getw()

public

void

setw

(weapon w)

public

soldier

(string name, weapon w)

public

soldier

(int age, weapon w)

public

soldier

(string name,

int age, weapon w)

public

soldier

(int age,

int hurt, weapon w)

public

soldier

(string name,

int age,

int hurt, weapon w)

public

soldier

(string name,

int age,

int hurt)

public

soldier

(string name)

public

soldier

(int age)

public

soldier

(string name,

int age)

public

intgethurt()

public

void

sethurt

(int hurt)

namedrole 類:兩種角色的父類

public

abstract

class

namedrole

implements

role

@override

public

void

practise()

public

namedrole

(string name)

public

namedrole

(int age)

public

namedrole

(string name,

int age)

public string getname()

public

void

setname

(string name)

public

intgetage()

public

void

setage

(int age)

測試類;

public

static

void

main

(string[

] args)

用C語言寫乙個簡單的掃雷小遊戲

define crt secure no warnings include include include 用 c 語言寫乙個簡單的掃雷遊戲 1.寫乙個遊戲選單 menu 2.開始遊戲 1.初始化二維陣列 init inte ce 2.列印遊戲介面 print inte ce 3.玩家掀起指定位置 ...

用flask寫乙個簡單的介面

用falsk寫乙個簡單的介面,這個介面的資料本來是爬蟲爬取的資料,但是今天只寫乙個flask介面,資料就用測試資料好了。import random import reimport time import requests import flask,json from flask import req...

用python寫乙個簡單的彈球遊戲

用python寫乙個簡單的彈球遊戲,可以使用球拍接住球讓球在邊框內不停的彈動,如果球拍沒有接住則遊戲結束 我們需要匯入tkinter模組來建立畫布 匯入時間模組來控制球的速度,就是控制球移動的間隔時間 匯入隨機模組使球彈的方向是隨機的。fromtkinterimport importtime imp...