接上一篇帖子,既然是一名程序猿,最喜欢的东西自然是代码,听着代码,哒哒哒的声音,就已经很兴奋了!!!
第六天的学习内容:
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();
}
}
|
|