Add lab6
This commit is contained in:
37
lab/lab6/Question3/Dot.java
Normal file
37
lab/lab6/Question3/Dot.java
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Author: CHEN Yongyuan (Walter) 1930006025 from OOP(1007).
|
||||
* Date: 2022/03/27
|
||||
* Description: This is the Dot class.
|
||||
*/
|
||||
|
||||
public class Dot extends Shape {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param x double
|
||||
* @param y double
|
||||
*/
|
||||
public Dot(double x, double y) {
|
||||
super(x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the area method. Dot has no (0.0) area.
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
@Override
|
||||
public double area() {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test
|
||||
*/
|
||||
public static void testDot() {
|
||||
Dot d1 = new Dot(1.0, 2.0);
|
||||
System.out.println(d1.getX() == 1.0);
|
||||
System.out.println(d1.getY() == 2.0);
|
||||
System.out.println(d1.area() == 0.0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user