更新内容:
1、修正文件返回菜单错误
2、加入金币系统
3、使防御能够正常起作用
4、武器商店开放
5、背包管理
6、治疗中心会收取一定费用


PS:
预计中的:
怪物掉落物品
存取档功能
还未实现

还是6个java文件
1、allObject.java
package com.home.jiangfan;

public interface allObject {
   void escap();
   void generalAttack();
   void magicAttack();
  
}



2、UserFace.java
package com.home.jiangfan;
import java.util.*;

public class UserFace {
 public String name;
 //欢迎提示
 public void welcome(){
  System.out.println("您好!欢迎进入梦游世界!");
  System.out.println("现在创建新人物,请您输入人物昵称:");
  Scanner in=new Scanner(System.in);
  this.name=in.nextLine();
  System.out.println("☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆");
  
 }
 //显示人物当前数据
 public void printPlayer(Player p){
  System.out.println("人物昵称:"+p.name);
  System.out.println("等级:"+p.lv);
  System.out.println("hp:"+p.hp);
  System.out.println("mp:"+p.mp);
  System.out.println("攻击力:"+p.attack);
  System.out.println("防御力:"+p.armor);
  System.out.println("技能:"+p.skill);
  System.out.println("装备:"+p.iteams);
  System.out.println("当前经验:"+p.exp);
  System.out.println("梦游币:"+p.gold);
  System.out.println("升级到下级所需经验:"+(p.lv+p.lv)*10);
  System.out.println("");
  System.out.println("按任意键继续");
  Scanner in=new Scanner(System.in);
  String choose=in.nextLine();
  System.out.println("☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆");
  printOperations(p);
  if(choose==null || choose==""){
   printOperations(p);
  }
 }
 public void printMonster(Monster m,Player p){
  System.out.println("怪物名称:"+m.name);
  System.out.println("等级:"+m.lv);
  System.out.println("hp:"+m.hp);
  System.out.println("mp:"+m.mp);
  System.out.println("攻击力:"+m.attack);
  System.out.println("防御力:"+m.armor);
  System.out.println("技能:"+m.skill);
  System.out.println("");
  System.out.println("按任意键继续");
  Scanner in=new Scanner(System.in);
  String choose=in.nextLine();
  System.out.println("☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆");
  printOperations(p);
  if(choose==null || choose==""){
   printOperations(p);
  
 }
 }

    //游戏操作总菜单
 public void printOperations(Player player){
  Operations o1=new Operations();
  System.out.println("1,刷怪练级  2,挑战Boss  3,治疗  4,人物状态  5,武器商店  6,背包状态");
  Scanner in=new Scanner(System.in);
  String choose=in.nextLine();
  System.out.println("☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆");
  if(choose.equals("1")){
   o1.lianji(player);
  }
  if(choose.equals("2")){
   o1.vsBoss(player);
   System.out.println("挑战boss");
  }
  if(choose.equals("3")){
   o1.heal(player);
   System.out.println("治疗");
  }
  if(choose.equals("4")){
   printPlayer(player);
  }
  if(choose.equals("5")){
   o1.weaponShop(player);
  }
  if(choose.equals("6")){
   o1.bag(player);
  }
  else{
   printOperations(player);
   }
 }
 
 //程序入口点
 public static void main(String[] args){
  //创建人物
  UserFace uf=new UserFace();
  uf.welcome();
  Player p1=new Player(1,1,"天神下凡","黑龙*爪",uf.name);
  //uf.printPlayer(p1);
  System.out.println(p1.name+",欢迎进入梦游世界!");
  //新人物进入操作界面
  uf.printOperations(p1);
 }
}



3、Operations.java
package com.home.jiangfan;

import java.util.Scanner;

public class Operations {
 //战斗操作界面
 public void fight(Monster monster,Player player){
  while(monster.hp>0 & player.hp>0){
   System.out.println("1,普通攻击 2,法术攻击 3,自身状态 4,怪物状态");
   Scanner inInner=new Scanner(System.in);
   String chooseInner = inInner.nextLine();
   System.out.println("☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆");
   //选择普通攻击
   if(chooseInner.equals("1")){
    JudgementPK pkkaikai=new JudgementPK();
    pkkaikai.judgementGA(player, monster);
   }
   //选择法术攻击
   if(chooseInner.equals("2")){
    JudgementPK pkkaikai=new JudgementPK();
    pkkaikai.judgementMA(player, monster);
   }
   //自身状态
   if(chooseInner.equals("3")){
    System.out.println("人物昵称:"+player.name);
    System.out.println("等级:"+player.lv);
    System.out.println("hp:"+player.hp);
    System.out.println("mp:"+player.mp);
    System.out.println("攻击力:"+player.attack);
    System.out.println("防御力:"+player.armor);
    System.out.println("技能:"+player.skill);
    System.out.println("装备:"+player.iteams);
    System.out.println("当前经验:"+player.exp);
    System.out.println("梦游币:"+player.gold);
    System.out.println("升级到下级所需经验:"+(player.lv+player.lv)*10);
    System.out.println("");
    System.out.println("按任意键继续");
    Scanner in=new Scanner(System.in);
    String choose=in.nextLine();
    fight(monster,player);
    if(choose==null || choose==""){
     fight(monster,player);
    }
    
   }
   //怪物状态
   if(chooseInner.equals("4")){
    System.out.println("怪物名称:"+monster.name);
    System.out.println("等级:"+monster.lv);
    System.out.println("hp:"+monster.hp);
    System.out.println("mp:"+monster.mp);
    System.out.println("攻击力:"+monster.attack);
    System.out.println("防御力:"+monster.armor);
    System.out.println("技能:"+monster.skill);
    System.out.println("");
    System.out.println("按任意键继续");
    Scanner in=new Scanner(System.in);
    String choose=in.nextLine();
    System.out.println("☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆");
    fight(monster,player);
    if(choose==null || choose==""){
     fight(monster,player);
    }
 
   }else{
    fight(monster,player);
   }
  }
 }
 
 //二级操作界面--刷怪练级
 public void lianji(Player player){
  System.out.println("欢迎进入练级区域:请输入您想挑战的怪物:");
  System.out.println("1,凯凯 2,力力 3,黑客 4,研究生");
  Scanner in=new Scanner(System.in);
  String choose=in.nextLine();
  System.out.println("☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆");
  if(choose.equals("1")){
   System.out.println("您选择拿凯凯练级!");
   Monster kaikai=new Monster(11,1,"凯凯发傻","凯凯");
   fight(kaikai,player);
  }
  if(choose.equals("2")){
   System.out.println("您选择拿力力练级!");
   Monster lili=new Monster(12,5,"力力发呆","力力");
   fight(lili,player);
  }
  if(choose.equals("3")){
   System.out.println("您选择拿黑客练级!");
   Monster hacker=new Monster(13,15,"黑客病毒","黑客");
   fight(hacker,player);
  }
  if(choose.equals("4")){
   System.out.println("您选择拿研究生练级!");
   Monster graduate=new Monster(14,45,"知识就是力量","研究生");
   fight(graduate,player);
  }else{
   lianji(player);
  }

 }
 
 
 //二级操作界面--vsBoss
 public void vsBoss(Player player){
  System.out.println("挑战Boss请小心:请输入您想挑战的Boss:");
  System.out.println("1,小皮 2,未开放 3,未开放 4,未开放");
  Scanner in=new Scanner(System.in);
  String choose=in.nextLine();
  System.out.println("☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆");
  if(choose.equals("1")){
   System.out.println("您选择挑战小皮!");
   Monster xiaopi=new Monster(101,100,"食量无限","小皮");
   fight(xiaopi,player);
  }
  if(choose.equals("2")){
   System.out.println("未开放!看不懂啊!!!");
   vsBoss(player);
  }
  if(choose.equals("3")){
   System.out.println("未开放!看不懂啊!!!");
   vsBoss(player);
  }
  if(choose.equals("4")){
   System.out.println("未开放!看不懂啊!!!");
   vsBoss(player);
  }else{
   System.out.println("谢谢啊~~你按错了~你个2~!");
   vsBoss(player);
  }

 }
 
 
 //二级操作界面--治疗
 public void heal(Player player){
  System.out.println("欢迎您来到治疗中心!目前版本为免费治疗~~");
  System.out.println("请选择:1、治疗自己 2、查看当前状态 3离开");
  Scanner in=new Scanner(System.in);
  int choose=in.nextInt();
  System.out.println("☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆");
  //治疗自己
  if(choose==1){
   System.out.println("您目前的等级,在治疗中心恢复hp需要:"+player.lv*player.lv+"个梦游币。确认请按1,返回治疗中心请按2");
   Scanner inInner=new Scanner(System.in);
   String chooseInner=inInner.nextLine();
   //确认治疗,判断金币是否足够治疗
    if(chooseInner.equals("1")){
     if(player.gold>=player.lv*player.lv){
      player.hp=player.lv*200;
      player.gold-=player.lv*player.lv;
      System.out.println("恭喜您~治疗完毕!您的当前hp为:"+player.hp);
      System.out.println("消耗梦游币:"+player.lv*player.lv);
      heal(player);
     }else{
      System.out.println("您的梦游币不足!返回治疗中心");
      heal(player);
     }
    }else{
     heal(player);
    }

  }
  if(choose==2){
   UserFace back=new UserFace();
   back.printPlayer(player);
  }if(choose==3){
   UserFace back=new UserFace();
   back.printOperations(player);
  }
   }
  
 //二级操作界面---武器商店
 public void weaponShop(Player player){
  System.out.println("欢迎光临武器店");
  System.out.println("1,购买武器 2,离开");
  Scanner in=new Scanner(System.in);
  String choose=in.nextLine();
  if(choose.equals("1")){
  System.out.println("请选择您要购买的武器的号码:");
  System.out.println("1、无情打击之刃  属性:攻击+1000    价格:10000梦游币");
  System.out.println("2、斩龙者        属性:攻击+10000   价格:99999梦游币");
  Scanner inInner=new Scanner(System.in);
  String chooseInner=inInner.nextLine();
  if(chooseInner.equals("1")){
   if(player.gold>=10000){
    if(player.bag1==0 || player.bag2==0){
     System.out.println("恭喜购买 无情打击之刃 成功");
     player.gold-=10000;
     System.out.println("梦游币减少:10000");
     System.out.println("无情打击之刃 装入您的背包");
     if(player.bag1==0){
      player.bagIteam1="无情打击之刃";
      player.bag1=1;
     }else{
      player.bagIteam2="无情打击之刃";
      player.bag2=1;
     }
    }else{
     System.out.println("背包位置不够,请确认背包有空闲位置再进行购买!");
     weaponShop(player);
    }
   }else{
    System.out.println("您的梦游币不足!");
    weaponShop(player);
   }
  }
  if(chooseInner.equals("2")){
   if(player.gold>=99999){
    if(player.bag1==0 || player.bag2==0){
     System.out.println("恭喜购买 斩龙者 成功");
     player.gold-=99999;
     System.out.println("梦游币减少:99999");
     System.out.println("斩龙者 装入您的背包");
     if(player.bag1==0){
      player.bagIteam1="斩龙者";
      player.bag1=1;
     }else{
      player.bagIteam2="斩龙者";
      player.bag2=1;
     }
    }else{
     System.out.println("背包位置不够,请确认背包有空闲位置再进行购买!");
     weaponShop(player);
    }
   }else{
    System.out.println("您的梦游币不足!");
    weaponShop(player);
   }
  }
  }
  //离开
  else{
   UserFace back=new UserFace();
   back.printOperations(player);
  }
 }
 
 //二级操作界面--背包状态
 public void bag(Player player){
  System.out.println("背包界面:1、查看背包 2、更换装备 3、返回");
  Scanner in=new Scanner(System.in);
  String choose=in.nextLine();
  //查看背包
  if(choose.equals("1")){
   System.out.println("您现在背包的状态:");
   System.out.println("格子一:"+player.bagIteam1);
   System.out.println("格子二:"+player.bagIteam2);
   
   System.out.println("1、清理背包 2、返回");
   Scanner inInner=new Scanner(System.in);
   String chooseInner=inInner.nextLine();
   
   if(chooseInner.equals("1")){
    System.out.println("1、清空格子一 2、清空格子二 3、返回");
    Scanner in2=new Scanner(System.in);
    String choose2=in2.nextLine();
    if(choose2.equals("1")){
     System.out.println("格子一已经清空");
     player.bag1=0;
     player.bagIteam1="无";
     bag(player);
    }else if(choose2.equals("2")){
     System.out.println("格子二已经清空");
     player.bag2=0;
     player.bagIteam2="无";
     bag(player);
    }else{
     bag(player);
    }
   }else{bag(player);}
  }
  //更换装备
  if(choose.equals("2")){
   if(player.bag1==0 && player.bag2==0){
   System.out.println("你背包里什么都没有,你换啥啊你?!");
   }
   if(player.bag1==1 || player.bag2==1){
    System.out.println("背包格一:"+player.bagIteam1);
    System.out.println("背包格二:"+player.bagIteam2);
    System.out.println("请选择更换哪个格子内的装备到人物身上:");
    System.out.println("1、背包格一 2、背包格二 3、返回:");
    Scanner in3=new Scanner(System.in);
    String choose3=in3.nextLine();
    if(choose3.equals("1")){
     player.attack-=player.weapon;
     String c="";
     c=player.iteams;
     player.iteams=player.bagIteam1;
     player.bagIteam1=c;
     System.out.println("你装备上了:"+player.iteams);
     if(player.iteams.equals("斩龙者")){
      player.weapon=10000;
      player.attack = (player.lv*player.lv+10)+player.weapon;

     }else if(player.iteams.equals("无情打击之刃")){
      player.weapon=1000;
      player.attack = (player.lv*player.lv+10)+player.weapon;
     }else{
      player.weapon=10;
      player.attack = (player.lv*player.lv+10)+player.weapon;

     }
    }
    if(choose3.equals("2")){
     player.attack-=player.weapon;
     String c="";
     c=player.iteams;
     player.iteams=player.bagIteam2;
     player.bagIteam2=c;

     System.out.println("你装备上了:"+player.iteams);
     if(player.iteams.equals("斩龙者")){
      player.weapon=10000;
      player.attack = (player.lv*player.lv+10)+player.weapon;

     }else if(player.iteams.equals("无情打击之刃")){
      player.weapon=1000;
      player.attack = (player.lv*player.lv+10)+player.weapon;

     }else{
      player.weapon=10;
      player.attack = (player.lv*player.lv+10)+player.weapon;
     }
    }else{
     bag(player);
    }
    
   }
  }
  //返回
  else{
    UserFace back=new UserFace();
    back.printOperations(player);
   }
 }
 }