class Student {
private String name;
private int age;
public Student() {}
public Student(String name , int age) {
this.name = name;
this.age = age;
}
public void setName (String name){
this.name = name;
}
public String getName() {
return name;
}
public void setAge(int age) {
this.age = age;
}
public int getAge() {
return age;
}
public void show() {
System.out.println("我的姓名是:" + name + "我的年龄是:" + age);
}
}
class Demo5 {
public static void main(String[] args) {
Phone p = new Phone();
p.setBrand("胡志明");
p.setPrice(1);
System.out.println(p.getBrand() +"..." +p.getPrice());
Phone p1 = new Phone("臭比",1);
p1.show();
}
}
class Phone {
private String brand;
private int price;
public Phone() {}
public Phone(String brand , int price) {
this.brand = brand;
this.price = price;
}
public void setBrand(String brand) {
this.brand = brand;
}
public String getBrand() {
return brand;
}
public void setPrice(int price) {
this.price = price;
}
class Dome7 {
public static void main(String[] args) {
Rectangle r = new Rectangle(10,20);
System.out.println(r.getLenght());
System.out.println(r.getArea());
}
}
class Rectangle {
private int hight;
private int width;
public Rectangle() {}
public Rectangle(int hight , int width) {
this.hight = hight;
this.width = width;
}
public void setHight(int hight) {
this.hight = hight;
}
public int getHight() {
return hight;
}
public void setWidth(int width) {
this.width = width;
}
public int getWidth() {
return width;
}
public int getLenght() {
return 2 * (width + hight);
}