Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ZH1Felk1.
- public class Main {
- public static void main(String args[]) {
- Butorlap ButorObject = new Butorlap(2033, 20200, ButorlapType.HATLAP); //ButoprlapType.TARTOLAP || ButorlapType.HATLAP
- Butor ButorkaObject = new Butor(30);
- System.out.println(ButorObject.arSzamol());
- ButorkaObject.lapHozzaad();
- ButorkaObject.kiir();
- }
- }
- public class Butor {
- private int butorlap;
- private int[] array = new int[100];
- public Butor(int butorlap) {
- this.butorlap = butorlap;
- }
- public void lapHozzaad(){
- array[0]+=1; // nem érettem pontosan mi lett volna a feladat.
- }
- public int arSzamol(){
- int price=0;
- for (int i = 0; i < array.length; i++) {
- price+=array[i]*1000; //nem értem pontosan itt mit kellene
- }
- return price;
- }
- public int lapSzam(){
- int lapszam=0;
- for (int i = 0; i < array.length; i++) {
- lapszam+=array[i];
- }
- return lapszam;
- }
- public void kiir(){
- System.out.println(this);
- }
- @Override
- public String toString() {
- return "Butor: {" +
- "lapokszama = " + lapSzam() + " " +
- "butorlapara = " + arSzamol() +
- '}';
- }
- }
- public class Butorlap {
- private int width;
- private int length;
- private ButorlapType type;
- final static int tartoprice = 5000;
- final static int hatlapprice = 500;
- public Butorlap(int width, int length,ButorlapType type) {
- this.width = width/100;
- this.length = length/100;
- this.type = type;
- }
- public int arSzamol(){
- switch (type){
- case HATLAP:
- return hatlapprice*width*length;
- case TARTOLAP:
- return tartoprice*width*length;
- }
- return 0;
- }
- }
- public enum ButorlapType {
- HATLAP,
- TARTOLAP;
- }
Advertisement
Add Comment
Please, Sign In to add comment