store.java package com.LOL; import java.util.Scanner; public class store { public static void main(String[] args) { //首先初始化15个英雄. Hero[] hero = new Hero[15]; //这段是初始化英雄,手动打. hero[0] = new Hero(1," 无极剑圣","打野",450); hero[1] = new Hero(2," 众星之子","辅助",450); hero[2] = new Hero(3," 审判天使","中单",450); hero[3] = new Hero(4," 熔岩巨兽","上单",1350); hero[4] = new Hero(5," 牛头酋长","辅助",1350); hero[5] = new Hero(6," 麦林炮手","ADC",1350); hero[6] = new Hero(7," 大发明家","中单",3150); hero[7] = new Hero(8," 德邦总管","打野",3150); hero[8] = new Hero(9," 暮光之眼","上单",3150); hero[9] = new Hero(10,"赏金猎人","ADC",3150); hero[10] = new Hero(11,"暗夜猎手","ADC",4800); hero[11] = new Hero(12,"仙灵女巫","辅助",6300); hero[12] = new Hero(13,"发条魔灵","中单",6300); hero[13] = new Hero(14,"龙血武姬","打野",6300); hero[14] = new Hero(15,"迷失之牙","上单",6300); //初始化英雄结束... //开始构建系统用户交互 Scanner reader=new Scanner(System.in); System.out.println("请问您要进入LOL英雄商店么?(1.是,2.否)"); int agree = reader.nextInt(); if(agree==1){ System.out.println("编号 英雄名 类型 价格"); for(int i=0;i<hero.length;i++ ){ hero[i].inf(); } System.out.println("请选择你要购买的英雄(输入编号),按y结束输入"); int sum=0; int m=0; while(reader.hasNextInt()){ int x=reader.nextInt(); m=m+1; sum=sum+hero[x-1].price; hero[x-1].x=1; } System.out.println("您购买了"+m+"个英雄"); System.out.println("您选择的英雄有:"); for(int i=0;i<hero.length;i++) if(hero[i].x==1) { hero[i].inf(); } System.out.println("您这次购买合计金钱为:"+sum); } } }
飞扬的研究僧程序猿
2014-09-01
2 回答
举报
0/150
提交
取消