OOP design table chair bench
abstract class material{ int weight; } class wood extends material{ } class plastic extends material{ } class metal extends material{ } interface furniture { material getMaterial(); void setMaterial(material m); } class table implements furniture{ material mat; public material getMaterial(){ return mat; } public void setMaterial(material m){ mat =m; } } class bench implements furniture{ material mat; public material getMaterial(){ return mat; } public void setMaterial(material m){ mat =m; } } class chair implements furniture{ material mat; public material getMaterial(){ return mat; } public void setMaterial(material m){ mat =m; } }
There are 3 products table,chair and bench. Product can be of wood ,metal and plastic . Design a class structures for this.
浙公网安备 33010602011771号