Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. class Point {
  4. double x;
  5. double y;
  6.  
  7. public Point(double x, double y) {
  8. this.x = x;
  9. this.y = y;
  10. }
  11.  
  12. void translate(double a, double b){
  13. x += a;
  14. y += b;
  15. }
  16.  
  17. void scale(double n){
  18. x *= n;
  19. y *= n;
  20. }
  21.  
  22. public double getX() {
  23. return x;
  24. }
  25.  
  26. public void setX(double x) {
  27. this.x = x;
  28. }
  29.  
  30. public double getY() {
  31. return y;
  32. }
  33.  
  34. public void setY(double y) {
  35. this.y = y;
  36. }
  37.  
  38. void show(){
  39. System.out.println(x+" "+y);
  40. }
  41.  
  42. public static void main(String[] args){
  43. Scanner scanner = new Scanner(System.in);
  44. Point point = new Point(scanner.nextDouble(),scanner.nextDouble());
  45. scanner.nextLine();
  46. int z = scanner.nextInt();
  47. switch (z){
  48. case 0:
  49. scanner.nextLine();
  50. point.translate(scanner.nextDouble(),scanner.nextDouble());
  51. point.show();
  52. break;
  53. case 1:
  54. scanner.nextLine();
  55. point.scale(scanner.nextDouble());
  56. point.show();
  57. break;
  58. case 2:
  59. scanner.nextLine();
  60. point.translate(scanner.nextInt(),scanner.nextInt());
  61. scanner.nextLine();
  62. point.scale(scanner.nextDouble());
  63. point.show();
  64. break;
  65. case 3:
  66. scanner.nextLine();
  67. point.scale(scanner.nextDouble());
  68. scanner.nextLine();
  69. point.translate(scanner.nextInt(),scanner.nextInt());
  70. point.show();
  71. break;
  72. case 4:
  73. point.show();
  74. break;
  75. }
  76.  
  77. }
  78.  
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement