Guest User

Grid Cell as object in Java

a guest
Oct 14th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class GridCell{
  4. //V for variable so it doesn't interfere with simple getter names
  5. private int aV;
  6. private int bV;
  7. private int cV;
  8. private int dV;
  9. private int eV;
  10. private int fV;
  11. private int nV;
  12. private int xV;
  13. private int tV;
  14. private int xplusnV;
  15. private int dplusnV;
  16. private int xplusnsquaredV;
  17. private int dplusnsquaredV;
  18. private int uV;
  19. private int bignV;
  20. private boolean oddxplusnsquaredV;
  21. private String description;
  22.  
  23. public GridCell(int aSend, int bSend){
  24. aV = aSend;
  25. bV = bSend;
  26. cV = aV*bV;
  27. dV = (int)Math.floor((int)Math.sqrt(cV));
  28. eV = cV-(dV*dV);
  29. fV = eV-((2*dV)+1);
  30. nV = ((aV+bV)/2)-dV;
  31. xV = dV-aV;
  32. tV = 0;
  33. if(eV%2==0){
  34. tV = (xV+2)/2;
  35. } else {
  36. tV = (xV+1)/2;
  37. }
  38. xplusnV = xV+nV;
  39. dplusnV = dV+nV;
  40. xplusnsquaredV = xplusnV*xplusnV;
  41. dplusnsquaredV = dplusnV*dplusnV;
  42. uV = 0;
  43. oddxplusnsquaredV = true;
  44. if(xplusnsquaredV%2==0){
  45. oddxplusnsquaredV = false;
  46. uV = xplusnV/2;
  47. } else {
  48. uV = (xplusnV-1)/2;
  49. }
  50. bignV = ((cV+1)/2)-dV;
  51. description = "("+eV+","+nV+","+tV+") = {"+eV+":"+nV+":"+dV+":"+xV+":"+aV+":"+bV+"}, f="+fV+", c="+cV+", u="+uV;
  52. }
  53.  
  54. public int a(){
  55. return aV;
  56. }
  57.  
  58. public int b(){
  59. return bV;
  60. }
  61.  
  62. public int c(){
  63. return cV;
  64. }
  65.  
  66. public int d(){
  67. return dV;
  68. }
  69.  
  70. public int e(){
  71. return eV;
  72. }
  73.  
  74. public int f(){
  75. return fV;
  76. }
  77.  
  78. public int n(){
  79. return nV;
  80. }
  81.  
  82. public int x(){
  83. return xV;
  84. }
  85.  
  86. public int t(){
  87. return tV;
  88. }
  89.  
  90. public int xplusn(){
  91. return xplusnV;
  92. }
  93.  
  94. public int dplusn(){
  95. return dplusnV;
  96. }
  97.  
  98. public int xplusnsquared(){
  99. return xplusnsquaredV;
  100. }
  101.  
  102. public int dplusnsquared(){
  103. return dplusnsquaredV;
  104. }
  105.  
  106. public int u(){
  107. return uV;
  108. }
  109.  
  110. public int bign(){
  111. return bignV;
  112. }
  113.  
  114. public boolean oddxplusnsquared(){
  115. return oddxplusnsquaredV;
  116. }
  117.  
  118. public String print(){
  119. return description;
  120. }
  121. }
Advertisement
Add Comment
Please, Sign In to add comment