How to create a 2D point data structure with two floating-point numbers in Dart

2 Answers

0 votes
class Point {
    double x = 0, y = 0;
  
    Point(double x, double y) {
        this.x = x;
        this.y = y;
    }
}

void main() {
    var p = Point(3.14, 2.78);

    print(p.x);
    print(p.y);
}




/*
run:

3.14
2.78

*/

 



answered Dec 26, 2022 by avibootz
0 votes
class Point {
    double y = 0;
    double x = 0;
 
    Point(this.x, this.y);
}
 
main() {
    var p = Point(11.34, 12.78);
   
    print(p.x);
    print(p.y);
}
 
 
 
/*
run:
 
11.34
12.78
 
*/

 



answered Dec 26, 2022 by avibootz
...