zoukankan      html  css  js  c++  java
  • 上机作业

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

    public class Computer {
        char color;
        int model;
    
        Computer() {
    
        }
    
        Computer(char color, int model) {
            this.color = color;
            this.model = model;
        }
    
        void a() {
            System.out.println("颜色:" + color + "  型号:" + model);
        }
    
        public static void main(String[] args) {
        Computer a = new Computer('a', 9527);
            a.a();
        }
    }

    2.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()方法。

    public class Person {
        String name;
        double height;
        int age;
    
        Person(String name, double height, int age) {
            this.name = name;
            this.height = height;
            this.age = age;
        }
    
        void sayHello() {
            System.out.println("hello,my name is  " + name+" "+height+"m"+" "+age+"岁");
        }
    }
    public class Constructor {
    
        public static void main(String[] args) {
            Person a = new Person("zhangsan", 1.73, 33);
            Person b = new Person("lishi", 1.74, 44);
    
            a.sayHello();
            b.sayHello();
    
        }
    
    }
  • 相关阅读:
    python模块之PIL模块(生成随机验证码图片)
    3.5 黑盒测试方法-逻辑推断法
    3.4 黑盒测试用例的设计方法之-等价类划分与边界值分析
    三、测试用例
    LoadRunner性能测试工具下载
    二、软件测试的流程
    优秀的软件测试人员应该具备的素质
    一、测试基础
    实现人脸识别性别之路------前端突破点
    day2
  • 原文地址:https://www.cnblogs.com/reddead/p/12759464.html
Copyright © 2011-2022 走看看