Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Point {
- double x;
- double y;
- public Point(double x, double y) {
- this.x = x;
- this.y = y;
- }
- void translate(double a, double b){
- x += a;
- y += b;
- }
- void scale(double n){
- x *= n;
- y *= n;
- }
- public double getX() {
- return x;
- }
- public void setX(double x) {
- this.x = x;
- }
- public double getY() {
- return y;
- }
- public void setY(double y) {
- this.y = y;
- }
- void show(){
- System.out.println(x+" "+y);
- }
- public static void main(String[] args){
- Scanner scanner = new Scanner(System.in);
- Point point = new Point(scanner.nextDouble(),scanner.nextDouble());
- scanner.nextLine();
- int z = scanner.nextInt();
- switch (z){
- case 0:
- scanner.nextLine();
- point.translate(scanner.nextDouble(),scanner.nextDouble());
- point.show();
- break;
- case 1:
- scanner.nextLine();
- point.scale(scanner.nextDouble());
- point.show();
- break;
- case 2:
- scanner.nextLine();
- point.translate(scanner.nextInt(),scanner.nextInt());
- scanner.nextLine();
- point.scale(scanner.nextDouble());
- point.show();
- break;
- case 3:
- scanner.nextLine();
- point.scale(scanner.nextDouble());
- scanner.nextLine();
- point.translate(scanner.nextInt(),scanner.nextInt());
- point.show();
- break;
- case 4:
- point.show();
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement