185 動物體系

2021-08-31 07:06:47 字數 939 閱讀 5106

基於繼承關係編寫乙個動物體系,具體的動物包含小狗和小貓。每只動物都有名字和顏色,都能夠做自我介紹(introduce)。此外,小狗有智商屬性(整數),能接飛盤(catchfrisbee(),方法體內輸出一行「catch frisbee」即可),小貓有眼睛顏色屬性,能抓老鼠(catchmouse(),方法體內輸出一行「catch mouse」即可)。各種小動物自我介紹時均介紹自己的姓名和顏色,此外,小狗應介紹自己的智商,小貓應介紹自己的眼睛顏色。小狗介紹時輸出」my name is ***, my color is ***, my iq is ***」, 小貓介紹時輸出「my name is ***, my color is ***, my eyecolor is ***」

構造類testanimal,提供靜態函式introduce(animal),對引數動物自我介紹。提供靜態函式action(animal),根據引數物件的實際型別進行活動,如果是小狗,則讓其接飛盤,如果是小貓,則讓其抓老鼠。

main函式中,根據動物型別構造動物,並呼叫testanimal中的方法進行自我介紹(introduce)和活動(action)

abstract class animal

public abstract void introduce();

}class dog extends animal

public void introduce()

public void catchfrisbee()

}class cat extends animal

public void introduce()

public void catchmouse()

}class testanimal

else

}public static void action(animal a)

else

}}

opencv運動物體檢測

參考資料 python opencv實現動態物體追蹤 python opencv實踐 一 基於顏色的物體追蹤 上 在hsv顏色空間識別區域顏色 opencv python tutorials opencv形態學處理 opencvl輪廓檢測函式 樹莓派智慧型小車結合攝像頭,opencv進行物體追蹤 給...

運動物體的檢測 初

最近為了實現運動物體的檢測這一功能,在網路上找了許多材料,但是大都不容易實現或者晦澀難懂,於是決定從基礎入手,先對兩張大小相同但略有差異的兩張進行操作,基本步驟是首先對兩張進行相減操作,把差值圖放在另外一張大小相同的圖上,之後對這張圖進行闕值化操作,然後再尋找輪廓,用矩形圈去輪廓。在建立差圖時找到了...

運動物體目標檢測實現 基於OpenCV

基於opencv實現的乙個運動目標檢測演算法,可以用來檢測行人,車輛等運動目標。include include include include int main int argc,char argv 宣告iplimage指標 iplimage pframe null iplimage pfrimg ...