设计一个Point类,其x和y坐标可以通过构造器提供。提供一个子类LabeledPoint其构造器接受一个标签值和x,y,坐标,比如;new LabelPoint("Black Thureday"1929,230.07)写出对应的构造器
- package com.java.Homework_;
-
- public class Homework09 {
- public static void main(String[] args) {
- new LabeledPoint("fiveday",293.3,40);
- }
- }
-
- package com.java.Homework_;
-
- public class Point {
- private double x;
- private double y;
-
- public Point(double x, double y) {
- this.x = x;
- this.y = y;
- }
- }
- package com.java.Homework_;
-
- public class LabeledPoint extends Point{
- private String Label;
-
- public LabeledPoint(String label,double x, double y) {
- super(x, y);
- Label = label;
- }
- }