package com.example.egzamin;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    public int iloscPolubien = 0;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button polubBtn = findViewById(R.id.polubBtn);
        Button usunBtn = findViewById(R.id.usunBtn);

        polubBtn.setOnClickListener(view -> {
            iloscPolubien++;
            updateLikeCounter();
        });

        usunBtn.setOnClickListener(view -> {
            if(iloscPolubien == 0) return;
            iloscPolubien--;
            updateLikeCounter();
        });
    }

    protected void updateLikeCounter() {
        TextView polubienia = findViewById(R.id.polubienia);

        polubienia.setText(iloscPolubien + " polubień");
    }
}