最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

黑馬程序員Java零基礎視頻教程_上部(Java入門,含斯坦福大學練習題+力扣算

2023-07-06 16:20 作者:快樂的竹小豬  | 我要投稿

交作業(yè)啦啦啦,超級好玩

Main方法

  • package ONE;
import Role.Role;

import java.lang.*;

public class Main {

    public static void main(String[] args) {
        Role role = new Role("鳩摩智", "劍眉星目", true);
        Role role01 = new Role("掃地僧", "彎腰駝背,面容模糊", true);
        Role role02 = new Role("不知水舞", false);
        role01.showRole();
        role02.showRole();
        role.showRole();
        while (true) {
            if (role01.getAgility() > role02.getAgility()) {
                role01.attack(role02);
                if (role02.getBlood() <= 0) {
                    System.out.println(role02.getName() + "KO");
                    break;
                }
                role02.attack(role01);
                if (role01.getBlood() <= 0) {
                    System.out.println(role01.getName() + "KO");
                    break;
                }
            }
            else {
                role02.attack(role01);
                if (role01.getBlood() <= 0) {
                    System.out.println(role01.getName() + "KO");
                    break;
                }
                role01.attack(role02);
                if (role02.getBlood() <= 0) {
                    System.out.println(role02.getName() + "KO");
                    break;
                }
            }
        }
    }
}

Role類

package Role;

import java.util.Random;

public class Role {
    private static Random r=new Random();
    enum skillGrade{};
    private static String []skills=new String[]{
            "%s使出了一招[背心釘] ,轉(zhuǎn)到對方的身后,一掌向%s背心的靈臺穴拍去。\n",
            "%s使出了一招[游空探爪] ,飛起身形自半空中變掌為抓鎖向%s。\n",
            "%s大喝一聲,身形下伏,一招[劈雷墜地] ,捶向%s雙腿。\n",
            "%s運氣于掌,一瞬間掌心變得血紅,一式[掌心雷] ,推向%s。\n",
            "%s陰手翻起陽手跟進,一招[沒遮攔] ,結(jié)結(jié)實實的捶向%s。\n",
            "%s上步搶身,招中套招,一招[劈掛連環(huán)]連環(huán)攻向%s。\n"
    };
    private static String []injureds=new String[]{
            "結(jié)果%s退了半步,毫發(fā)無損。,受到%d點傷害。\n",                 //無傷
            "結(jié)果給%s造成一處瘀傷,受到%d點傷害。\n",                     //傷害*0.5
            "結(jié)果一擊命中,%s痛得彎下腰,受到%d點傷害。\n",                 //傷害*0.75
            "結(jié)果%s痛苦地悶哼了一聲,顯然受了點內(nèi)傷,受到%d點傷害。\n",      //正常傷害
            "結(jié)果%s搖搖晃晃,一跤摔倒在地,受到%d點傷害。\n",             //傷害*1.25
            "結(jié)果%s臉色一下變得慘白,連退了好幾步結(jié)果轟~~!的一聲,口中鮮血狂噴而出,受到%d點傷害。\n",  //傷害*1.50
            "結(jié)果%s一聲慘叫,像灘軟泥般塌了下去,受到%d點傷害。\n"            //傷害*2
    };
    String Name,face;
    boolean gender;
    int blood=100;
    String[] boyface={"風流俊朗","氣宇軒昂","五官端正","相貌平平","一塌糊涂","面目猙獰"};
    String[] girlface={"沉魚落雁","前凸后翹","亭亭玉立","相貌平平","黃臉婆娘","歪瓜裂棗"};
    int agility=r.nextInt(100);
    public Role() {
    }
    public Role(String name,String face, boolean gender) {
        Name = name;
        this.face = face;
        this.gender = gender;
    }
    public Role(String name,boolean gender) {
        Name = name;
        this.gender = gender;
        face=gender==true?boyface[FaceIndex()]:girlface[FaceIndex()];
        blood=100;
    }

    public int FaceIndex(){
        int num=r.nextInt(100);
        if(num>=95){
            return 0;
        }
        else if(num>=80){
            return 1;
        }else if(num>=70){
            return 2;
        }else if(num>=60){
            return 3;
        }else if(num>=40){
            return 4;
        }else {
            return 5;
        }
    }
    public void showRole(){
        System.out.println("角色名稱:\t"+getName()+"\n性別為:\t\t"+getGender()+"\n長相為:\t\t"+getFace());
        System.out.printf("敏捷為:%d\n",getAgility());
        System.out.println("血量為:\t\t"+getBlood());
        System.out.println("");
    }

    public void attack(Role role){
        int n1=getSkillNum();
        int n2=getInjuredNum();
        int injured=(int)((r.nextInt(20)+5)*getInjuredIdex(n1,n2));
        role.setBlood(role.getBlood()-injured);
        System.out.printf(skills[n1]+injureds[n2],getName(),role.getName(),role.getName(),injured);
        System.out.println("此時"+role.getName()+"血量為"+role.getBlood());
    }

    //傷害計算
    public static int getSkillNum(){
        int num=r.nextInt(6);
        return num;
    }
    public static int getInjuredNum(){
        int num=r.nextInt(7);
        return num;
    }
    public static double getInjuredIdex(int n1,int n2){
        switch (n2){
            case 0:return 0.0;
            case 1:return 0.5;
            case 2:return 0.75;
            case 3:return 1;
            case 4:return 1.25;
            case 5:return 1.5;
            case 6:return 2.0;
        }
        return 1.0;
    }


    public int getAgility() {
        return agility;
    }

    public void setAgility(int agility) {
        this.agility = agility;
    }

    public String getGender(){
        if(gender==true){
            return "♂";
        }else return "♀";
    }

    public String getName() {
        return "("+Name+")";
    }

    public void setName(String name) {
        Name = name;
    }

    public String getFace() {
        return face;
    }

    public void setFace(String face) {
        this.face = face;
    }

    public void setGender(boolean gender) {
        this.gender = gender;
    }

    public int getBlood() {
        return blood;
    }

    public void setBlood(int blood) {
        this.blood = blood;
    }

    public String[] getBoyface() {
        return boyface;
    }

    public void setBoyface(String[] boyface) {
        this.boyface = boyface;
    }

    public String[] getGirlface() {
        return girlface;
    }

    public void setGirlface(String[] girlface) {
        this.girlface = girlface;
    }
}


黑馬程序員Java零基礎視頻教程_上部(Java入門,含斯坦福大學練習題+力扣算的評論 (共 條)

分享到微博請遵守國家法律
湛江市| 即墨市| 临汾市| 山阴县| 当阳市| 营口市| 盐池县| 寿光市| 乌兰县| 无棣县| 中山市| 清新县| 长垣县| 饶阳县| 元江| 台安县| 微山县| 上思县| 项城市| 金阳县| 梨树县| 无极县| 崇信县| 色达县| 富平县| 尚义县| 岳西县| 邵东县| 比如县| 兴山县| 乌拉特后旗| 兰溪市| 淮滨县| 遂川县| 临泉县| 庐江县| 涪陵区| 义乌市| 开化县| 桂平市| 原平市|