ricskooo

Untitled

Feb 19th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. ZH1Felk1.
  2.  
  3. public class Main {
  4. public static void main(String args[]) {
  5. Butorlap ButorObject = new Butorlap(2033, 20200, ButorlapType.HATLAP); //ButoprlapType.TARTOLAP || ButorlapType.HATLAP
  6. Butor ButorkaObject = new Butor(30);
  7.  
  8. System.out.println(ButorObject.arSzamol());
  9. ButorkaObject.lapHozzaad();
  10. ButorkaObject.kiir();
  11.  
  12. }
  13. }
  14.  
  15.  
  16. public class Butor {
  17. private int butorlap;
  18. private int[] array = new int[100];
  19.  
  20. public Butor(int butorlap) {
  21. this.butorlap = butorlap;
  22. }
  23.  
  24. public void lapHozzaad(){
  25. array[0]+=1; // nem érettem pontosan mi lett volna a feladat.
  26. }
  27.  
  28. public int arSzamol(){
  29. int price=0;
  30. for (int i = 0; i < array.length; i++) {
  31. price+=array[i]*1000; //nem értem pontosan itt mit kellene
  32. }
  33. return price;
  34. }
  35.  
  36. public int lapSzam(){
  37. int lapszam=0;
  38. for (int i = 0; i < array.length; i++) {
  39. lapszam+=array[i];
  40. }
  41. return lapszam;
  42. }
  43.  
  44. public void kiir(){
  45. System.out.println(this);
  46. }
  47.  
  48. @Override
  49. public String toString() {
  50. return "Butor: {" +
  51. "lapokszama = " + lapSzam() + " " +
  52. "butorlapara = " + arSzamol() +
  53. '}';
  54. }
  55. }
  56.  
  57.  
  58. public class Butorlap {
  59. private int width;
  60. private int length;
  61.  
  62. private ButorlapType type;
  63.  
  64. final static int tartoprice = 5000;
  65. final static int hatlapprice = 500;
  66.  
  67. public Butorlap(int width, int length,ButorlapType type) {
  68. this.width = width/100;
  69. this.length = length/100;
  70. this.type = type;
  71. }
  72.  
  73. public int arSzamol(){
  74. switch (type){
  75. case HATLAP:
  76. return hatlapprice*width*length;
  77. case TARTOLAP:
  78. return tartoprice*width*length;
  79. }
  80. return 0;
  81. }
  82. }
  83.  
  84.  
  85. public enum ButorlapType {
  86. HATLAP,
  87. TARTOLAP;
  88. }
Advertisement
Add Comment
Please, Sign In to add comment