Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Locale;
- class Vector2D{
- double vx, vy;
- public Vector2D(){
- vx = 1;
- vy = 1;
- }
- public Vector2D(double vx, double vy){
- this.vx = vx;
- this.vy = vy;
- }
- public Vector2D(Vector2D v){
- this(v.vx, v.vy);
- }
- @Override
- public String toString() {
- return "("
- + vx + ", " + vy +
- ")" ;
- }
- }
- public class Main {
- public static void main(String[] args) {
- Vector2D v = new Vector2D(1.2374, 2.2334);
- Vector2D v2 = new Vector2D();
- Vector2D v3 = new Vector2D(v);
- System.out.println(String.format(Locale.US, "%.2f", v));
- System.out.println(String.format(Locale.US, "%.2f", v2));
- System.out.println(String.format(Locale.US, "%.2f", v3));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement