• 第八周上机


    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);
        }
  • 相关阅读:
    HTML页面跳转的5种方法
    ngixn配置
    redis秒杀
    php 设计模式
    MySQL之事务的四大特性
    [置顶] JNI之java传递数据给c语言
    jQuery 快速结束当前动画
    编绎OpenJDK
    CF#231DIV2:A Good Number
    CF#213DIV2:B The Fibonacci Segment
  • 原文地址:https://www.cnblogs.com/fff1479/p/12807877.html
Copyright © 2020-2023  润新知