找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 3715|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

java命令行顯示愛(ài)心形的源程序

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:109770 發(fā)表于 2016-3-22 20:09 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
本帖最后由 51黑bing 于 2016-3-22 20:10 編輯



public class Human

{
        public Human(String name, String sex, float height, float money, boolean handsome, boolean beautiful)
        {
                this.name = name;
                this.sex = sex;
                this.height = height;
                this.money = money;
                this.handsome = handsome;
        }

        public boolean ifTallRichHandsomeOrBeautiful()
        {
                if (sex.equals("man"))
                {
                        if (height >= 1.70f && money >= 10000f && handsome)
                        {
                                System.out.println("高富帥!\n\n");
                                return true;
                        }
                        else
                        {
                                System.out.println("靜下心來(lái),好好想一下未來(lái)的路,相信你一定會(huì)成功。n\n");
                                return false;
                        }
                }
                else if (sex.equals("woman"))
                {
                        if (height >= 1.70f && money >= 10000f && beautiful)
                        {
                                System.out.println("白富美!\n\n");
                                return true;
                        }
                        else
                        {
                                System.out.println("靜下心來(lái),好好想一下未來(lái)的路,相信你一定會(huì)成功!\n\n");
                                return false;
                        }
                }
                else
                {
                        System.out.println("我是基的。。。\n\n");
                        return false;
                }
        }

        public String name;
        private String sex;
        private float height;
        private float money;
        private boolean beautiful;
        private boolean handsome;
}


-------------------------------------------------------------------------------------------------------------------------------------------------


public class Test
{
        public static void main(String args[])
        {
                Human nanmei = new Human("楠妹", "woman", 1.70f, 5000f, true, false);
                System.out.println("我的名字是:" + nanmei.name + "\n" + ",哈!");
                nanmei.ifTallRichHandsomeOrBeautiful();
                int x = 0, y = 0;
                double result = 0, m = 0, n = 0, j = 0, k = 0;
                int[][] a = new int[80][30];

                for (y = 0; y < 30; ++y)
                {
                        for (x = 0; x < 80; ++x)
                        {
                                if (y <= 7 & x <= 40)
                                {
                                        j = (7.0 - y) / 6.0;
                                        k = (40.0 - x) / 16.0 - 1;
                                        m = Math.pow(j, 2);
                                        n = Math.pow(k, 2);
                                        result = m + n;
                                        if (result > 1)
                                        {
                                                a[x][y] = 1;
                                        }
                                        else
                                        {
                                                a[x][y] = 0;
                                        }
                                }
                                if (y <= 7 & x > 40)
                                {
                                        j = (7.0 - y) / 6.0;
                                        k = (x - 40.0) / 16.0 - 1;
                                        m = Math.pow(j, 2);
                                        n = Math.pow(k, 2);
                                        result = m + n;
                                        if (result > 1)
                                        {
                                                a[x][y] = 1;
                                        }
                                        else
                                        {
                                                a[x][y] = 0;
                                        }
                                }
                                if (y > 7 & x <= 40)
                                {
                                        j = (7.0 - y) / 18.0;
                                        k = (40.0 - x) / 32.0;
                                        m = Math.pow(j, 2);
                                        n = Math.pow(k, 0.5);
                                        result = m + n;
                                        if (result > 1)
                                        {
                                                a[x][y] = 1;
                                        }
                                        else
                                        {
                                                a[x][y] = 0;
                                        }
                                }
                                if (y > 7 & x > 40)
                                {
                                        j = (7.0 - y) / 18.0;
                                        k = (x - 40.0) / 32.0;
                                        m = Math.pow(j, 2);
                                        n = Math.pow(k, 0.5);
                                        result = m + n;
                                        if (result > 1)
                                        {
                                                a[x][y] = 1;
                                        }
                                        else
                                        {
                                                a[x][y] = 0;
                                        }
                                }
                        }
                }
                for (y = 0; y < 25; ++y)
                {
                        for (x = 0; x < 80; ++x)
                        {
                                System.out.print(a[x][y]);
                        }
                }
        }
}


分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表