• 第八周上机


    public class fff
    public class Rectangle {
        int length;
        int width;
    
        public void getPer() {
            System.out.println("矩形的周长=" + (length + width) * 2);
        }
    
        public void getArea() {
            System.out.println("矩形的面积=" + length * width);
        }
    
        public void showAll() {
            System.out.println("长=" + length);
            System.out.println("宽=" + width);
            getArea();
            getPer();
        }
    
    }
    
    
    
    package sdd;
    
    import java.util.Scanner;
    
    public class Tese {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
    
            Rectangle a = new Rectangle();
            Scanner input = new Scanner(System.in);
            System.out.print("请输入长:");
            a.length = input.nextInt();
            System.out.print("请输入宽:");
            a.width = input.nextInt();
            a.showAll();
    
        }
    
    }
    
    
    package Test;
    
    public class Bijiben {
        char yanse;
        int cpu;
    
        public void Showyanse() {
            System.out.println("笔记本颜色为:" + yanse+"色");
        }
    
        public void Showcpu() {
            System.out.print("cpu型号是:" + cpu);
        }
    }
    
    
    
    package Test;
    
    public class sed {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            Bijiben a = new Bijiben();
            a.yanse = '白';
            a.cpu = 2020;
            a.Showyanse();
            a.Showcpu();
        }
    
    }
    复制代码
    package Test;
    
    public class Person {
    
        String name;
        int nianling;
        double shengao;
        int tizhong;
    
        public void sayHello() {
            System.out.println("Hello,my name is " + name);
            System.out.println(name + '、' + shengao + '、' + nianling + "岁");
    
        }
    
    }
    
    
    package Test;
    
    public class Constructor {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
    
            Person a = new Person();
            a.name = "zhangsan";
            a.shengao = 1.73;
            a.nianling = 33;
            a.sayHello();
            Person b = new Person();
            b.name = "lishi";
            b.shengao = 1.74;
            b.nianling = 44;
            b.sayHello();
        }
    
    }
    {
        int x;
        int y;
    
        Point() {
    
            System.out.println(x);
            System.out.println(y);
            System.out.println("调用后:");
        }
    
        Point(int x0, int y) {
            x = x;
            y = y;
            System.out.println(x);
            System.out.println(y);
        }
    
        void movePoint(int dx, int dy) {
    
            dx = x + 100;
            dy = y + 100;
            System.out.println("p1的坐标为" + dx + "
    " + "p2的坐标为" + dy);
    
        }
    
    }
    
    
    package bbt;
    
    public class bbt {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            Point p=new Point();
               p.x=100;
               p.y=200;
              p.movePoint(p.x,p.y);
        }
  • 相关阅读:
    element-ui 中日期控件限制时间跨度
    自定义指令值绑定问题
    vuejs 深度监听
    vscode 快捷键
    JS跳转方式
    JSON
    面向对象编程
    DOM
    JS响应事件
    登录事件
  • 原文地址:https://www.cnblogs.com/fff1479/p/12807877.html
Copyright © 2020-2023  润新知