当前位置: 首页 > news >正文

福州短视频seo网站优化师的工作内容

福州短视频seo网站,优化师的工作内容,机箱做的网站主机怎么查看ftp,网站建设技术支持牛商网上一章链接: 《HeadFirst设计模式(第二版)》第九章代码——迭代器模式_轩下小酌的博客-CSDN博客 前面说到,当一个菜单里面出现了子菜单的时候,前面的迭代器模式得换成组合模式。 组合模式: 允许将对象组合成树形结构来表现部分-整…

上一章链接:

《HeadFirst设计模式(第二版)》第九章代码——迭代器模式_轩下小酌的博客-CSDN博客

        前面说到,当一个菜单里面出现了子菜单的时候,前面的迭代器模式得换成组合模式。

组合模式:

        允许将对象组合成树形结构来表现部分-整体层次结构。组合让用户可以统一处理个别对象和对象组合。

代码文件结构:

 

MenuComponent
package Chapter9_CompositePattern;/*** @Author 竹心* @Date 2023/8/18**/public abstract class MenuComponent {public void add(MenuComponent menuComponent) {throw new UnsupportedOperationException();}public void remove(MenuComponent menuComponent) {throw new UnsupportedOperationException();}public MenuComponent getChild(int i) {throw new UnsupportedOperationException();}public String getName() {throw new UnsupportedOperationException();}public String getDescription() {throw new UnsupportedOperationException();}public double getPrice() {throw new UnsupportedOperationException();}public boolean isVegetarian() {throw new UnsupportedOperationException();}public void print() {throw new UnsupportedOperationException();}
}
MenuItem
package Chapter9_CompositePattern;/*** @Author 竹心* @Date 2023/8/18**/public class MenuItem extends MenuComponent{String name;String description;boolean vegetarian;double price;public MenuItem(String name,String description,boolean vegetarian,double price){this.name = name;this.description = description;this.vegetarian = vegetarian;this.price = price;}public String getName() {return name;}public String getDescription() {return description;}public double getPrice() {return price;}public boolean isVegetarian() {return vegetarian;}public void print() {System.out.print("  " + getName());if (isVegetarian()) {System.out.print("(v)");}System.out.println(", " + getPrice());System.out.println("     -- " + getDescription());}
}
Menu
package Chapter9_CompositePattern;import java.util.ArrayList;
import java.util.Iterator;/*** @Author 竹心* @Date 2023/8/18**/public class Menu extends MenuComponent{//菜单组合ArrayList<MenuComponent> menuComponents = new ArrayList<MenuComponent>();String name;String description;public Menu(String name, String description) {this.name = name;this.description = description;}public void add(MenuComponent menuComponent) {menuComponents.add(menuComponent);}public void remove(MenuComponent menuComponent) {menuComponents.remove(menuComponent);}public MenuComponent getChild(int i) {return (MenuComponent)menuComponents.get(i);}public String getName() {return name;}public String getDescription() {return description;}public void print() {System.out.print("\n" + getName());System.out.println(", " + getDescription());System.out.println("---------------------");//这里递归打印Iterator<MenuComponent> iterator = menuComponents.iterator();while (iterator.hasNext()) {MenuComponent menuComponent =(MenuComponent)iterator.next();menuComponent.print();}}
}
Waitress 
package Chapter9_CompositePattern;/*** @Author 竹心* @Date 2023/8/18**/public class Waitress {MenuComponent allMenus;//菜单根节点public Waitress(MenuComponent allMenus) {this.allMenus = allMenus;}public void printMenu() {allMenus.print();}
}
MenuTestDrive
package Chapter9_CompositePattern;/*** @Author 竹心* @Date 2023/8/18**/public class MenuTestDrive {public static void main(String args[]) {MenuComponent pancakeHouseMenu =new Menu("PANCAKE HOUSE MENU", "Breakfast");MenuComponent dinerMenu =new Menu("DINER MENU", "Lunch");MenuComponent cafeMenu =new Menu("CAFE MENU", "Dinner");MenuComponent dessertMenu =new Menu("DESSERT MENU", "Dessert of course!");MenuComponent coffeeMenu = new Menu("COFFEE MENU", "Stuff to go with your afternoon coffee");MenuComponent allMenus = new Menu("ALL MENUS", "All menus combined");allMenus.add(pancakeHouseMenu);allMenus.add(dinerMenu);allMenus.add(cafeMenu);pancakeHouseMenu.add(new MenuItem("K&B's Pancake Breakfast","Pancakes with scrambled eggs and toast",true,2.99));dinerMenu.add(new MenuItem("Vegetarian BLT","(Fakin') Bacon with lettuce & tomato on whole wheat",true,2.99));dinerMenu.add(dessertMenu);dessertMenu.add(new MenuItem("Apple Pie","Apple pie with a flakey crust, topped with vanilla icecream",true,1.59));cafeMenu.add(coffeeMenu);coffeeMenu.add(new MenuItem("Coffee Cake","Crumbly cake topped with cinnamon and walnuts",true,1.59));Waitress waitress = new Waitress(allMenus);//这示例代码怎么这么多。。。waitress.printMenu();}
}

http://www.khdw.cn/news/38504.html

相关文章:

  • 做网站都需要建哪些文件夹站长工具app官方下载
  • 云南放心seo整站优化正规专业短期培训学校
  • 网站外链建设方法seo关键词排名优化
  • 郑州网站高端设计以服务营销出名的企业
  • 网站做分布式部署营销手段有哪些
  • 网站建设明细表市场营销策略
  • 朋友要给我做网站长沙seo推广外包
  • 室内设计ppt优秀方案seo平台是什么意思
  • 建网站公司的资质需要哪些好的营销网站设计公司
  • wordpress安装语言seo行业
  • 成功网站案例有哪些近期国家新闻
  • 网站ie兼容性免费网站在线观看人数在哪直播
  • 做科技汽车的视频网站有哪些内容如何申请百度竞价排名
  • 找人做网站需要什么网络公司品牌推广
  • 珠海主题网站设计模板口碑营销案例
  • 免费推广企业网站网站如何优化一个关键词
  • 北京网站设计入门厦门seo收费
  • 网站做等保网站建设山东聚搜网络
  • 咸阳做网站开发公司哪家好网络营销方案策划
  • 外贸soho做网站怎么做b2b平台有哪些
  • 专业的手表网站seo厂家电话
  • 深圳施工图制作手机优化大师下载
  • 网站建设哪家更专业一个关键词要刷多久
  • 男女激烈做羞羞事网站推广团队在哪里找
  • 衍艺武汉网站设计公司站长工具ping检测
  • 网站怎么自己做优化今天的新闻有哪些
  • 个人网站做商城网址缩短在线生成器
  • 三只松鼠的网站建设理念四川seo平台
  • 图书管理系统网站开发开鲁seo网站
  • 湖南新备案的网站搜索引擎关键词优化方案