3、定义一个笔记本类,该类有颜色(char)和cpu
型号(int)两个属性。 [必做题]
• 3.1 无参和有参的两个构造方法;有参构造方法可
以在创建对象的同时为每个属性赋值;
• 3.2 输出笔记本信息的方法
• 3.3 然后编写一个测试类,测试笔记本类的各个
方法。

package zps;

public class cff {
    char color;
    int model;

    cff() {

    }

    cff(char color, int model) {
        this.color = color;
        this.model = model;
    }

    void a() {
        System.out.println("颜色:" + color + "  型号:" + model);
}
}
package zps;

public class vxx {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        cff a = new cff('a', 7623);
        a.a();
    }

}

5、定义两个类,描述如下: [必做题]

• 5.1定义一个人类Person:
• 5.1.1定义一个方法sayHello(),可以向对方发出问
候语“hello,my name is XXX”
• 5.1.2有三个属性:名字、身高、年龄
• 5.2定义一个PersonCreate类:
• 5.2.1创建两个对象,分别是zhangsan,33岁,1.73
;lishi,44,1.74
• 5.2.2分别调用对象的sayHello()方法。

package zps;

public class Person {
     String name;
        double length;
        int age;
        public void sayHello() {
            System.out.println("Hello,my name is" + name + "我的身高是" + length + "年龄是" + age+ "");
        }    
}
package zps;

public class PersonCreate {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
Person zhangsan = new Person();
        
        zhangsan.name = "zhangsan";
        zhangsan.age = 33;
        zhangsan.length=1.73;
        
        Person lishi = new Person();
        lishi.name = "lishi";
        lishi.length = 1.74;
        lishi.age = 44;
        
        zhangsan.sayHello();
        lishi.sayHello();
    }

}