第12周作业

Posted 李芊

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了第12周作业相关的知识,希望对你有一定的参考价值。

1.

package School.Day11;

public class Point {
    int x;
    int y;

    public Point(){

    }

    public  Point(int x,int y){
        this.x = x;
        this.y = y;
    }

    public void movePoint(int x,int y){
        this.x = x;
        this.y = y;
    }
}

  

package School.Day11;

public class PointTest {
    public static void main(String[] args){
        Point p1 = new Point(5,5);
        Point p2 = new Point(10,10);
        p1.movePoint(10,10);
        p2.movePoint(5,5);
        System.out.println("p1的坐标是: (" + p1.x + "," + p1.y + ")");
        System.out.println("p2的坐标是: (" + p2.x + "," + p2.y + ")");
    }
}

  

2.

package School.Day11;

public class Rectangle {
    int length;
    int width;

    public Rectangle(){

    }

    public Rectangle(int length,int width){
        this.length = length;
        this.width = width;
    }

    public void showAll(){
        System.out.println("长是: " + this.length);
        System.out.println("宽是: " + this.width);
        System.out.println("面积是: " + this.length * this.width);
        System.out.println("周长是: " + (this.length + this.width) * 2);
    }
}

  

package School.Day11;

public class RectangleTest {
    public static void main(String[] args) {
        Rectangle r = new Rectangle(10,5);
        r.showAll();
    }
}

  

3.

package School.Day11;

public class Computer {
    char color;
    int cpu;

    public Computer() {
    }

    public Computer(char color, int cpu) {
        this.color = color;
        this.cpu = cpu;
    }

    public void showAll(){
        System.out.println("颜色: " + this.color);
        System.out.println("型号: " + this.cpu);
    }
}

  

package School.Day11;

public class ComputerTest {
    public static void main(String[] args) {
        Computer c = new Computer(\'黑\',9700);
        c.showAll();
    }
}

  

以上是关于第12周作业的主要内容,如果未能解决你的问题,请参考以下文章

第1415教学周作业

第14~15周作业

Python数据分析第七周作业随笔记录

第12周作业

201621123057 《Java程序设计》第9周学习总结

第1周小组博客作业--1703班06组