publicclassPoint{int x;int y;Point(){}Point(int x0,int y0){
x = x0;
y = y0;}voidmovePoint(int dx,int dy){int x = dx +5;int y = dy +5;
System.out.println(x+","+y);}}
Point p1 =newPoint(10,20);
p1.movePoint(10,20);
Point p2 =newPoint();
p2.movePoint(30,18)
定义两个类,描述如下: [必做题] 4.1定义一个人类Person: 4.1.1定义一个方法sayHello(),可以向对方发出问候语“hello,my name is XXX” 4.1.2有三个属性:名字、身高、体重 4.2定义一个PersonCreate类: 4.2.1创建两个对象,分别是zhangsan,33岁,1.73;lishi,44,1.74 4.2.2分别调用对象的sayHello()方法。
publicclassPerson{
String name ="Lebron";double heigth =203;int age;int weigth =113;voidsayHello(){
System.out.println("hello,my name is "+ name);}Person(){}Person(String name,int age,double heigth){}}
Person x =newPerson();
x.name ="zhangsan";
x.age =33;
x.heigth =1.73;
x.sayHello();
Person y =newPerson();
y.name ="lishi";
y.age =44;
y.heigth =1.74;
y.sayHello();
Person i =newPerson("zhangsan",33,1.73);
i.sayHello();
Person j =newPerson("lishi",44,1.74);
j.sayHello();