A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 满天星是偶的 初级黑马   /  2018-8-29 20:47  /  954 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文


接上一篇帖子,既然是一名程序猿,最喜欢的东西自然是代码,听着代码,哒哒哒的声音,就已经很兴奋了!!!
第六天的学习内容:
public class Circle {
    int r;

    public Circle() {
    }

    public Circle(int r) {
        this.r = r;
    }

    public int getR() {
        return r;
    }

    public void setR(int r) {
        this.r = r;
    }

    public void showArea(){
        System.out.println("半径为:"+ r +",面积为:"+ ( 3.14 * r * r));
    }

    public void showPerimeter(){
        System.out.println("半径为:"+ r +",面积为:"+ ( 2 * 3.14 * r));
    }
}


====================================================================================================================================================================================
   



public class MyDate {
    int year;
    int month;
    int day;

    public MyDate(int year, int month, int day) {
        this.year = year;
        this.month = month;
        this.day = day;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public int getMonth() {
        return month;
    }

    public void setMonth(int month) {
        this.month = month;
    }

    public int getDay() {
        return day;
    }

    public void setDay(int day) {
        this.day = day;
    }

    public void showDate() {
        System.out.println("日期:" +
                year +
                "年" + month +
                "月" + day +
                "日");
    }

    public void isBi() {

        if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
            System.out.println(year + "年是闰年");
        } else {
            System.out.println(year + "年不是闰年");
        }
    }
}
============================================================
========================================================================================================================
    public class Card {
        private String ds; // 点数
        private String hs; // 花色
   
        public Card(String ds, String hs) {
            this.ds = ds;
            this.hs = hs;
        }
   
        public void showCard() {
            System.out.println( ds +    hs  );
        }
    }

- 测试类:

    public class Test5 {
        public static void main(String[] args) {
            Card card = new Card("黑桃", "A");
            card.showCard();
        }
    }
========================================================================================================================
    public class Card {
        private String ds; // 点数
        private String hs; // 花色
   
        public Card(String ds, String hs) {
            this.ds = ds;
            this.hs = hs;
        }
   
        public void showCard() {
            System.out.println( ds +    hs  );
        }
    }

- 测试类:

    public class Test5 {
        public static void main(String[] args) {
            Card card = new Card("黑桃", "A");
            card.showCard();
        }
    }

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马