Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.33 KB | None | 0 0
  1. package wwsis.javacode.examples;
  2.  
  3. public class DrawFunction {
  4.     private int width;
  5.     private int height;
  6.     private int a;
  7.     private int b;
  8.     private int c;
  9.     public int getC() {
  10.         return c;
  11.     }
  12.  
  13.     public void setC(int c) {
  14.         this.c = c;
  15.     }
  16.  
  17.     public int getWidth() {
  18.         return width;
  19.     }
  20.  
  21.     public void setWidth(int width) {
  22.         this.width = width;
  23.     }
  24.  
  25.     public int getHeight() {
  26.         return height;
  27.     }
  28.  
  29.     public void setHeight(int height) {
  30.         this.height = height;
  31.     }
  32.  
  33.     public int getA() {
  34.         return a;
  35.     }
  36.  
  37.     public void setA(int a) {
  38.         this.a = a;
  39.     }
  40.  
  41.     public int getB() {
  42.         return b;
  43.     }
  44.  
  45.     public void setB(int b) {
  46.         this.b = b;
  47.     }
  48.    
  49.     public int drawFunction(int i) {
  50.         double functionx = a * Math.pow(i, 2) + b*i + c;
  51.  
  52.     //  functionx += var.getHeight() / 2;
  53.  
  54.         int y = (int) functionx;
  55.         return y;
  56.  
  57.     }
  58.     public int drawDelta() {
  59.         double delta = Math.pow(b, 2) - 4 * a + c;
  60.         //fy *= var.getHeight() / 2;
  61.         //fy += var.getHeight() / 2;
  62.  
  63.         int deltax = (int) delta;
  64.         return deltax;
  65.  
  66.     }
  67.     public double[] drawZeroPoints(DrawFunction delta) {
  68.         Variables variables = new Variables();
  69.         int deltax = delta.drawDelta();
  70.             double x1 = (- b - Math.sqrt(deltax))/2 * a;
  71.             double x2 = (- variables.getB() + Math.sqrt(deltax))/2 * variables.getA();
  72.         double[] zeropoints = {x1, x2};
  73.         return zeropoints; 
  74.         }
  75.    
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement