package oriented_byobjects;
import java.awt.;
import java.awt.event.;
import javax.swing.;
import static javax.swing.JOptionPane.;
public class Oriented_byObjects extends JFrame implements ActionListener {
Font grande = new Font("Serif",Font.BOLD,50);
 //variaveis de Jogo
   int Energia = 10;
   int Fome = 0;
   int $ = 0;
   
   
JLabel showE;
JLabel showF;
JLabel show$;
//instanciamento dos JButtons
JButton b = new JButton("Correr");
JButton b3 = new JButton("Dormir");
JButton c = new JButton("Comer");
JButton t = new JButton("Trabalhar");
JButton b2 = new JButton("Sair");
  
   
   
   //actions dos JButtons
@Override
public void actionPerformed(ActionEvent e){
    
    //Correr Settings
   if(e.getSource() == b){
   JOptionPane.showMessageDialog(null, "Você correu!");
   Energia--;
   Fome++;
       System.out.println("Energia: "+Energia+"/10");
       System.out.println("Fome: "+Fome+"/10");
       if(Energia==0){
           JOptionPane.showMessageDialog(null, "Sua energia acabou");
       System.exit(0);
       }
   }
   //Sair Settings
   if(e.getSource() == b2){
       JOptionPane.showMessageDialog(null, "Tchau");
   System.exit(0);
   
   }
   //Dormir Settings
   if(e.getSource() == b3){
       JOptionPane.showMessageDialog(null, "Você dorme bem!");
       Energia = 10;
       System.out.println("Energia: "+Energia+"/10");
 
   
   }
   //Comer Settings
   if(e.getSource() == c){
       if($ < 1){
           JOptionPane.showMessageDialog(null, "Não pode comprar comida"
                   + " sem dinheiro");
       
       }else{JOptionPane.showMessageDialog(null, "Você comeu um pão quentinho");
       Fome--;
       $--;
       System.out.println("Dinheiro: "+$);
       if(Fome < 0){
       Fome++;
           System.out.println("Fome: "+Fome+"/10");
       }else{System.out.println("Fome: "+Fome+"/10");
       }}
       
       if(Fome > 10){
           JOptionPane.showMessageDialog(null, "Você morreu de fome");
           System.exit(0);
       }
       
       }
   //Trabalhar Settings
   if(e.getSource() == t){
           $++;
           System.out.println("Dinheiro: "+$);
           Energia--;
           System.out.println("Energia: "+Energia+"/10");
           if(Energia < 1){
               JOptionPane.showMessageDialog(null, "Você morreu de sono!");
               System.exit(0);
               
           }
           
       }
   }
//Método construtor
public Oriented_byObjects(){
this.setLayout(
new BoxLayout(this, BoxLayout.Y_AXIS));
   //adicionando actionListener
   b.addActionListener(this);
    b2.addActionListener(this);
    b3.addActionListener(this);
    c.addActionListener(this);
    t.addActionListener(this);
    //setBounds de cada JButton
    
    b.setBounds(5, 5, 100, 30);
    
    b2.setBounds(5, 500, 150, 30);
    
    b3.setBounds(5, 40, 100, 30);
    
    c.setBounds(5, 80, 100, 30);
    
    t.setBounds(5, 120, 100, 30);
    //instanciando uma JFrame j
    
    JFrame j = new JFrame();
    
   
    j.setLayout(null);
    
    //Configs da janela
    j.setSize(800, 600);
    j.setVisible(true);
    j.setTitle("Joguinho da vida");
    //adicionar os JButtons
    j.add(b);
    j.add(b2);
    j.add(b3);
    j.add(c);
    j.add(t);
    
    //adicionar as legendas e configs das mesmas
    showE = new JLabel("Teste");showE.setLocation(45, 5);
    j.add(showE);
    show$ = new JLabel("Teste");showE.setLocation(45, 40);
    j.add(show$);
    showF = new JLabel("Teste");showF.setLocation(45, 80);
}
//método principal: main
public static void main(String[] args) {
    //Rodar os codigos anteriores
    new Oriented_byObjects();
}
}




