Maxim_Leo

Untitled

Apr 24th, 2022
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. public class Graph {
  2. Axis Ox=new Axis();
  3. Axis Oy=new Axis();
  4. Grid grid=new Grid();
  5. Legend legend=new Legend();
  6.  
  7. void CreateGraph(Curve curve,int a,int b){
  8. Legend legend1=new Legend();
  9. legend1.AddLegend(curve);
  10. this.legend=legend1;
  11. Ox.ChangeAxis(0,10,1);
  12. Oy.ChangeAxis(0,10,1);
  13. Ox.show();
  14. Oy.show();
  15. curve.Tab(a,b);
  16. grid.CreateGrid(Ox,Oy);
  17. grid.show();
  18. }
  19. void addCurve(Curve curve,int a,int b){
  20. Legend legend2=new Legend();
  21. legend2.AddLegend(curve);
  22. curve.Tab(a,b);
  23. }
  24. }
  25.  
  26.  
  27. class Axis{
  28. private double a;
  29. private double b;
  30. private double step;
  31. double getA(){
  32. return a;
  33. }
  34. double getB(){
  35. return b;
  36. }
  37. double getStep(){
  38. return step;
  39. }
  40. Axis(){}
  41. Axis(double start,double end,double mystep){
  42. this.a=start;
  43. this.b=end;
  44. this.step=mystep;
  45. }
  46. void ChangeAxis(double start,double end,double mystep){
  47. this.a=start;
  48. this.b=end;
  49. this.step=mystep;
  50. }
  51. void show(){
  52. System.out.println("Начало оси: "+a);
  53. System.out.println("Конец оси: "+b);
  54. System.out.println("Шаг оси: "+step);
  55. System.out.println();
  56. }
  57. }
  58.  
  59. public class Curve {
  60. double[] x;
  61. double[] y;
  62. private String name;
  63. private String color;
  64. String getName(){
  65. return name;
  66. }
  67. String getColor(){
  68. return color;
  69. }
  70. Curve(double x1[],double y1[],String name1,String color1){
  71. this.x=x1;
  72. this.y=y1;
  73. this.name=name1;
  74. this.color=color1;
  75. }
  76. void Tab(int a,int b){
  77. for(int i=a;i<b;i++){
  78. System.out.println("x: "+x[i]+" "+"y: "+y[i]);
  79. }
  80. System.out.println();
  81. }
  82. }
  83.  
  84. import java.sql.SQLOutput;
  85.  
  86. public class Grid {
  87. private double step1=0;
  88. private double step2=0;
  89. private double step3=0;
  90. double getStep1(){
  91. return step1;
  92. }
  93. double getStep2(){
  94. return step2;
  95. }
  96. double getStep3(){
  97. return step3;
  98. }
  99. void CreateGrid(Axis Ox, Axis Oy) {
  100. this.step1=Ox.getStep();
  101. this.step2=Oy.getStep();
  102. }
  103. void show(){
  104. System.out.println("Шаг 1: "+getStep1());
  105. System.out.println("Шаг 2: "+getStep2());
  106. System.out.println("Шаг 3: "+getStep3());
  107. System.out.println();
  108. }
  109. }
  110.  
  111. public class Legend {
  112. void AddLegend(Curve curve){
  113. System.out.println("Легенда: ");
  114. System.out.println("----- "+curve.getName());
  115. System.out.println();
  116. }
  117. }
  118.  
  119.  
Advertisement
Add Comment
Please, Sign In to add comment