Rabu, 30 Mei 2012

Membuat Kalkulator sederhana dengan java


Ni dia kode programnya..
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * kalku.java
 *
 * Created on May 23, 2012, 8:16:01 AM
 */
package kalkulator_mini;

/**
 *
 * @author adic
 */
public class kalku extends javax.swing.JFrame {
String angka;
Double total,angka1,angka2;
int pilih;
    /** Creates new form kalku */
    public kalku() {
        initComponents();
        angka= "";
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                        
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        cmdclear = new javax.swing.JButton();
        cmdminplus = new javax.swing.JButton();
        cmdkurang = new javax.swing.JButton();
        cmdtambah = new javax.swing.JButton();
        cmdsamadengan = new javax.swing.JButton();
        cmd9 = new javax.swing.JButton();
        cmd8 = new javax.swing.JButton();
        cmd7 = new javax.swing.JButton();
        cmd6 = new javax.swing.JButton();
        cmdpersen = new javax.swing.JButton();
        cmd0 = new javax.swing.JButton();
        cmdtampil = new javax.swing.JTextField();
        cmdkali = new javax.swing.JButton();
        cmd2 = new javax.swing.JButton();
        cmd3 = new javax.swing.JButton();
        cmdbagi = new javax.swing.JButton();
        cmd4 = new javax.swing.JButton();
        cmdkoma = new javax.swing.JButton();
        cmd5 = new javax.swing.JButton();
        cmd1 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("KALKULATOR MINI");
        setBackground(new java.awt.Color(0, 255, 0));
        setForeground(new java.awt.Color(204, 0, 255));

        jPanel1.setBackground(new java.awt.Color(51, 255, 0));
        jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 5));

        cmdclear.setFont(new java.awt.Font("Tahoma", 1, 11));
        cmdclear.setText("C");
        cmdclear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdclearActionPerformed(evt);
            }
        });

        cmdminplus.setFont(new java.awt.Font("Tahoma", 1, 11));
        cmdminplus.setText("+/-");
        cmdminplus.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdminplusActionPerformed(evt);
            }
        });

        cmdkurang.setFont(new java.awt.Font("Tahoma", 1, 11));
        cmdkurang.setText("-");
        cmdkurang.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdkurangActionPerformed(evt);
            }
        });

        cmdtambah.setFont(new java.awt.Font("Tahoma", 1, 11));
        cmdtambah.setText("+");
        cmdtambah.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdtambahActionPerformed(evt);
            }
        });

        cmdsamadengan.setFont(new java.awt.Font("Tahoma", 1, 11));
        cmdsamadengan.setText("=");
        cmdsamadengan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdsamadenganActionPerformed(evt);
            }
        });

        cmd9.setFont(new java.awt.Font("Tahoma", 1, 11));
        cmd9.setText("9");
        cmd9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmd9ActionPerformed(evt);
            }
        });

        cmd8.setFont(new java.awt.Font("Tahoma", 1, 11));
        cmd8.setText("8");
        cmd8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmd8ActionPerformed(evt);
            }
        });

        cmd7.setFont(new java.awt.Font("Tahoma", 1, 11));
        cmd7.setText("7");
        cmd7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmd7ActionPerformed(evt);
            }
        });

        cmd6.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        cmd6.setText("6");
        cmd6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmd6ActionPerformed(evt);
            }
        });

        cmdpersen.setFont(new java.awt.Font("Tahoma", 1, 11));
        cmdpersen.setText("%");
        cmdpersen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdpersenActionPerformed(evt);
            }
        });

        cmd0.setFont(new java.awt.Font("Tahoma", 1, 11));
        cmd0.setText("0");
        cmd0.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmd0ActionPerformed(evt);
            }
        });

        cmdtampil.setBackground(new java.awt.Color(255, 255, 0));
        cmdtampil.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        cmdtampil.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 3));
        cmdtampil.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdtampilActionPerformed(evt);
            }
        });

        cmdkali.setFont(new java.awt.Font("Tahoma", 1, 11));
        cmdkali.setText("*");
        cmdkali.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdkaliActionPerformed(evt);
            }
        });

        cmd2.setFont(new java.awt.Font("Tahoma", 1, 11));
        cmd2.setText("2");
        cmd2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmd2ActionPerformed(evt);
            }
        });

        cmd3.setFont(new java.awt.Font("Tahoma", 1, 11));
        cmd3.setText("3");
        cmd3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmd3ActionPerformed(evt);
            }
        });

        cmdbagi.setFont(new java.awt.Font("Tahoma", 1, 11));
        cmdbagi.setText("/");
        cmdbagi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdbagiActionPerformed(evt);
            }
        });

        cmd4.setFont(new java.awt.Font("Tahoma", 1, 11));
        cmd4.setText("4");
        cmd4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmd4ActionPerformed(evt);
            }
        });

        cmdkoma.setFont(new java.awt.Font("Tahoma", 1, 11));
        cmdkoma.setText(".");
        cmdkoma.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdkomaActionPerformed(evt);
            }
        });

        cmd5.setFont(new java.awt.Font("Tahoma", 1, 11));
        cmd5.setText("5");
        cmd5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmd5ActionPerformed(evt);
            }
        });

        cmd1.setFont(new java.awt.Font("Tahoma", 1, 11));
        cmd1.setText("1");
        cmd1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmd1ActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel1.setText("KALKULATOR MINI ADIC KOMALASARI");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 278, Short.MAX_VALUE)
                    .addComponent(cmdtampil, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 278, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(cmd4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 51, Short.MAX_VALUE)
                            .addComponent(cmdpersen, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 51, Short.MAX_VALUE)
                            .addComponent(cmd1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 51, Short.MAX_VALUE)
                            .addComponent(cmd7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cmd2, javax.swing.GroupLayout.DEFAULT_SIZE, 56, Short.MAX_VALUE)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(cmd8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(cmd5, javax.swing.GroupLayout.DEFAULT_SIZE, 56, Short.MAX_VALUE))
                            .addComponent(cmd0, javax.swing.GroupLayout.DEFAULT_SIZE, 56, Short.MAX_VALUE))
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(cmd6, javax.swing.GroupLayout.DEFAULT_SIZE, 50, Short.MAX_VALUE)
                                    .addComponent(cmd9, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(cmdkurang, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cmdminplus, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(cmdclear, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cmdkali, javax.swing.GroupLayout.DEFAULT_SIZE, 48, Short.MAX_VALUE)))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 6, Short.MAX_VALUE)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(cmdkoma, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(cmd3, javax.swing.GroupLayout.DEFAULT_SIZE, 51, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(cmdtambah, javax.swing.GroupLayout.DEFAULT_SIZE, 48, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(cmdbagi, javax.swing.GroupLayout.DEFAULT_SIZE, 48, Short.MAX_VALUE))
                                    .addComponent(cmdsamadengan, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE))))))
                .addGap(20, 20, 20))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(9, 9, 9)
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cmdtampil, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cmd7)
                    .addComponent(cmd8)
                    .addComponent(cmd9)
                    .addComponent(cmdminplus)
                    .addComponent(cmdclear))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(cmdkurang)
                        .addComponent(cmdkali))
                    .addComponent(cmd4)
                    .addComponent(cmd6)
                    .addComponent(cmd5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(cmdtambah)
                        .addComponent(cmdbagi))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(cmd1)
                        .addComponent(cmd2)
                        .addComponent(cmd3)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cmdpersen)
                    .addComponent(cmdsamadengan)
                    .addComponent(cmd0)
                    .addComponent(cmdkoma))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>                      

private void cmdtampilActionPerformed(java.awt.event.ActionEvent evt) {                                        
// TODO add your handling code here:
}                                        

private void cmd0ActionPerformed(java.awt.event.ActionEvent evt) {                                    
// TODO add your handling code here:
    //angka+="0";
    //cmdtampil.setText("0");
    cmdtampil.setText(angka +="0");
}                                  

private void cmdpersenActionPerformed(java.awt.event.ActionEvent evt) {                                        
    angka2 = Double.parseDouble(angka);
    total = angka2 / 100;
    angka = Double.toString(total);
    cmdtampil.setText(angka);
}                                        

private void cmd8ActionPerformed(java.awt.event.ActionEvent evt) {                                    
cmdtampil.setText(angka +="8");
}                                  

private void cmd1ActionPerformed(java.awt.event.ActionEvent evt) {                                    
cmdtampil.setText(angka +="1");
}                                  

private void cmd2ActionPerformed(java.awt.event.ActionEvent evt) {                                    
cmdtampil.setText(angka +="2");  
}                                  

private void cmd3ActionPerformed(java.awt.event.ActionEvent evt) {                                    
cmdtampil.setText(angka +="3");
}                                  

private void cmd4ActionPerformed(java.awt.event.ActionEvent evt) {                                    
cmdtampil.setText(angka +="4");
}                                  

private void cmd5ActionPerformed(java.awt.event.ActionEvent evt) {                                    
cmdtampil.setText(angka +="5");
}                                  

private void cmd6ActionPerformed(java.awt.event.ActionEvent evt) {                                    
cmdtampil.setText(angka +="6");
}                                  

private void cmd7ActionPerformed(java.awt.event.ActionEvent evt) {                                    
cmdtampil.setText(angka +="7");
}                                  

private void cmd9ActionPerformed(java.awt.event.ActionEvent evt) {                                    
cmdtampil.setText(angka +="9");
}                                  

private void cmdtambahActionPerformed(java.awt.event.ActionEvent evt) {                                        
    angka1=Double.parseDouble(angka);
    cmdtampil.setText("+");
    angka="";
    pilih=1;
}                                        

private void cmdsamadenganActionPerformed(java.awt.event.ActionEvent evt) {                                            
    switch(pilih)
    {case 1:
        angka2=Double.parseDouble(angka);
        total = angka1 + angka2;
        angka = Double.toString(total);
        cmdtampil.setText(angka);
        break;
    case 2:
        angka2=Double.parseDouble(angka);
        total = angka1 - angka2;
        angka= Double.toString(total);
        cmdtampil.setText(angka);
        break;
    case 3:
        angka2=Double.parseDouble(angka);
        total = angka1 * angka2;
        angka= Double.toString(total);
        cmdtampil.setText(angka);
        break;
    case 4:
        angka2=Double.parseDouble(angka);
        total = angka1 / angka2;
        angka= Double.toString(total);
        cmdtampil.setText(angka);
        break;
    default:
        break;
    }
}                                            

private void cmdclearActionPerformed(java.awt.event.ActionEvent evt) {                                        
    angka1 = 0.0;
    angka2 = 0.0;
    total = 0.0;
    angka ="";
    cmdtampil.setText("");
}                                      

private void cmdkurangActionPerformed(java.awt.event.ActionEvent evt) {                                        
    angka1=Double.parseDouble(angka);
    cmdtampil.setText("-");
    angka="";
    pilih=2;
}                                        

private void cmdkaliActionPerformed(java.awt.event.ActionEvent evt) {                                      
    angka1=Double.parseDouble(angka);
    cmdtampil.setText("*");
    angka="";
    pilih=3;
   
}                                      

private void cmdbagiActionPerformed(java.awt.event.ActionEvent evt) {                                      
    angka1=Double.parseDouble(angka);
    cmdtampil.setText("/");
    angka="";
    pilih=4;
}                                      

private void cmdminplusActionPerformed(java.awt.event.ActionEvent evt) {                                          
    angka2 = Double.parseDouble(angka);
    total = 0 - angka2;
    angka = Double.toString(total);
    cmdtampil.setText(angka);  
}                                        

private void cmdkomaActionPerformed(java.awt.event.ActionEvent evt) {                                      
cmdtampil.setText(angka +=".");
}                                      

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(kalku.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(kalku.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(kalku.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(kalku.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new kalku().setVisible(true);
            }
        });
    }
    private double temp;
    // Variables declaration - do not modify                    
    private javax.swing.JButton cmd0;
    private javax.swing.JButton cmd1;
    private javax.swing.JButton cmd2;
    private javax.swing.JButton cmd3;
    private javax.swing.JButton cmd4;
    private javax.swing.JButton cmd5;
    private javax.swing.JButton cmd6;
    private javax.swing.JButton cmd7;
    private javax.swing.JButton cmd8;
    private javax.swing.JButton cmd9;
    private javax.swing.JButton cmdbagi;
    private javax.swing.JButton cmdclear;
    private javax.swing.JButton cmdkali;
    private javax.swing.JButton cmdkoma;
    private javax.swing.JButton cmdkurang;
    private javax.swing.JButton cmdminplus;
    private javax.swing.JButton cmdpersen;
    private javax.swing.JButton cmdsamadengan;
    private javax.swing.JButton cmdtambah;
    private javax.swing.JTextField cmdtampil;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration                  
}

Minggu, 29 April 2012

Program C++ dengan GUI

Pada kesempatan kali ini, saya akan menampilkan program yang saya buat yaitu Permainan Game Suit dengan Menggunakan Microsoft Visual Studio C++ 2010 berbasis GUI (Graphical User Interface).
Inilah coding pada pembuatan programnya.

#pragma once
#include <time.h>
//#include <string>
#include "AboutGame.h"
#include "copyright.h"
namespace GameSuitAdic {

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

/// <summary>
/// Summary for MulaiGame
/// </summary>

public ref class MulaiGame : public System::Windows::Forms::Form
{

static int pointanda=0;
static int pointcomp=0;
static int Second = 0;
static int Minute = 0;
String^ Sec;
String^ nama;


private: System::Windows::Forms::Label^  label5;
private: System::Windows::Forms::Label^  lblNilaiAnda;
private: System::Windows::Forms::Label^  lblNilaiComp;
private: System::Windows::Forms::Label^  label6;
private: System::Windows::Forms::DateTimePicker^  dateTimePicker1;
private: System::Windows::Forms::Button^  button3;
private: System::Windows::Forms::LinkLabel^  linkLabel1;
private: System::Windows::Forms::LinkLabel^  linkLabel2;
private: AxWMPLib::AxWindowsMediaPlayer^  axWindowsMediaPlayer1;
private: System::Windows::Forms::Timer^  timer1;
String^ Min;
public:
MulaiGame(String^ x)
{
nama=x;
InitializeComponent();
//
//TODO: Add the constructor code here
//

}

protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MulaiGame()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::PictureBox^  pictureBox1;
protected:
private: System::Windows::Forms::PictureBox^  pictureBox2;
private: System::Windows::Forms::PictureBox^  pictureBox3;
private: System::Windows::Forms::PictureBox^  pictureBox4;
private: System::Windows::Forms::PictureBox^  pictureBox5;
private: System::Windows::Forms::PictureBox^  pictureBox6;
private: System::Windows::Forms::Label^  label1;


private: System::Windows::Forms::Label^  label2;
private: System::Windows::Forms::Label^  label3;
private: System::Windows::Forms::Label^  label4;
private: System::Windows::Forms::Button^  button1;

private: System::Windows::Forms::Timer^  Timer;
private: System::Windows::Forms::Label^  Time;

private: System::ComponentModel::IContainer^  components;


protected:

private:
/// <summary>
/// Required designer variable.
/// </summary>


#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->components = (gcnew System::ComponentModel::Container());
System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(MulaiGame::typeid));
this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
this->pictureBox2 = (gcnew System::Windows::Forms::PictureBox());
this->pictureBox3 = (gcnew System::Windows::Forms::PictureBox());
this->pictureBox4 = (gcnew System::Windows::Forms::PictureBox());
this->pictureBox5 = (gcnew System::Windows::Forms::PictureBox());
this->pictureBox6 = (gcnew System::Windows::Forms::PictureBox());
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label4 = (gcnew System::Windows::Forms::Label());
this->button1 = (gcnew System::Windows::Forms::Button());
this->Timer = (gcnew System::Windows::Forms::Timer(this->components));
this->Time = (gcnew System::Windows::Forms::Label());
this->label5 = (gcnew System::Windows::Forms::Label());
this->lblNilaiAnda = (gcnew System::Windows::Forms::Label());
this->lblNilaiComp = (gcnew System::Windows::Forms::Label());
this->label6 = (gcnew System::Windows::Forms::Label());
this->dateTimePicker1 = (gcnew System::Windows::Forms::DateTimePicker());
this->button3 = (gcnew System::Windows::Forms::Button());
this->linkLabel1 = (gcnew System::Windows::Forms::LinkLabel());
this->linkLabel2 = (gcnew System::Windows::Forms::LinkLabel());
this->axWindowsMediaPlayer1 = (gcnew AxWMPLib::AxWindowsMediaPlayer());
this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox2))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox3))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox4))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox5))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox6))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->axWindowsMediaPlayer1))->BeginInit();
this->SuspendLayout();
//
// pictureBox1
//
this->pictureBox1->BackColor = System::Drawing::Color::Transparent;
this->pictureBox1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"pictureBox1.Image")));
this->pictureBox1->Location = System::Drawing::Point(28, 51);
this->pictureBox1->Name = L"pictureBox1";
this->pictureBox1->Size = System::Drawing::Size(100, 103);
this->pictureBox1->TabIndex = 0;
this->pictureBox1->TabStop = false;
this->pictureBox1->Click += gcnew System::EventHandler(this, &MulaiGame::pictureBox1_Click);
this->pictureBox1->MouseClick += gcnew System::Windows::Forms::MouseEventHandler(this, &MulaiGame::pictureBox1_MouseClick);
//
// pictureBox2
//
this->pictureBox2->BackColor = System::Drawing::Color::Transparent;
this->pictureBox2->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"pictureBox2.Image")));
this->pictureBox2->Location = System::Drawing::Point(28, 151);
this->pictureBox2->Name = L"pictureBox2";
this->pictureBox2->Size = System::Drawing::Size(100, 101);
this->pictureBox2->TabIndex = 1;
this->pictureBox2->TabStop = false;
this->pictureBox2->Click += gcnew System::EventHandler(this, &MulaiGame::pictureBox2_Click);
this->pictureBox2->MouseClick += gcnew System::Windows::Forms::MouseEventHandler(this, &MulaiGame::pictureBox2_MouseClick);
//
// pictureBox3
//
this->pictureBox3->BackColor = System::Drawing::Color::Transparent;
this->pictureBox3->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"pictureBox3.Image")));
this->pictureBox3->Location = System::Drawing::Point(28, 248);
this->pictureBox3->Name = L"pictureBox3";
this->pictureBox3->Size = System::Drawing::Size(100, 97);
this->pictureBox3->TabIndex = 2;
this->pictureBox3->TabStop = false;
this->pictureBox3->Click += gcnew System::EventHandler(this, &MulaiGame::pictureBox3_Click);
//
// pictureBox4
//
this->pictureBox4->BackColor = System::Drawing::Color::Transparent;
this->pictureBox4->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"pictureBox4.Image")));
this->pictureBox4->Location = System::Drawing::Point(461, 51);
this->pictureBox4->Name = L"pictureBox4";
this->pictureBox4->Size = System::Drawing::Size(100, 103);
this->pictureBox4->TabIndex = 3;
this->pictureBox4->TabStop = false;
this->pictureBox4->Click += gcnew System::EventHandler(this, &MulaiGame::pictureBox4_Click);
this->pictureBox4->MouseClick += gcnew System::Windows::Forms::MouseEventHandler(this, &MulaiGame::pictureBox4_MouseClick);
//
// pictureBox5
//
this->pictureBox5->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"pictureBox5.Image")));
this->pictureBox5->Location = System::Drawing::Point(461, 151);
this->pictureBox5->Name = L"pictureBox5";
this->pictureBox5->Size = System::Drawing::Size(100, 101);
this->pictureBox5->TabIndex = 4;
this->pictureBox5->TabStop = false;
this->pictureBox5->Click += gcnew System::EventHandler(this, &MulaiGame::pictureBox5_Click);
//
// pictureBox6
//
this->pictureBox6->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
this->pictureBox6->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"pictureBox6.Image")));
this->pictureBox6->Location = System::Drawing::Point(461, 248);
this->pictureBox6->Name = L"pictureBox6";
this->pictureBox6->Size = System::Drawing::Size(100, 96);
this->pictureBox6->TabIndex = 5;
this->pictureBox6->TabStop = false;
this->pictureBox6->Click += gcnew System::EventHandler(this, &MulaiGame::pictureBox6_Click);
//
// label1
//
this->label1->AutoSize = true;
this->label1->Font = (gcnew System::Drawing::Font(L"Courier New", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label1->Location = System::Drawing::Point(179, 27);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(0, 22);
this->label1->TabIndex = 6;
this->label1->Text =nama;
this->label1->Click += gcnew System::EventHandler(this, &MulaiGame::label1_Click);
//
// label2
//
this->label2->AutoSize = true;
this->label2->Font = (gcnew System::Drawing::Font(L"Courier New", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label2->Location = System::Drawing::Point(273, 27);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(32, 22);
this->label2->TabIndex = 7;
this->label2->Text = L"VS";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Font = (gcnew System::Drawing::Font(L"Courier New", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label3->Location = System::Drawing::Point(362, 27);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(54, 22);
this->label3->TabIndex = 8;
this->label3->Text = L"COMP";
//
// label4
//
this->label4->AutoSize = true;
this->label4->Font = (gcnew System::Drawing::Font(L"Courier New", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label4->Location = System::Drawing::Point(251, 286);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(65, 22);
this->label4->TabIndex = 9;
this->label4->Text = L"HASIL";
this->label4->Click += gcnew System::EventHandler(this, &MulaiGame::label4_Click);
//
// button1
//
this->button1->Font = (gcnew System::Drawing::Font(L"Courier New", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->button1->Location = System::Drawing::Point(177, 310);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(97, 35);
this->button1->TabIndex = 10;
this->button1->Text = L"LANJUT";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &MulaiGame::button1_Click);
//
// Timer
//
this->Timer->Enabled = true;
this->Timer->Interval = 1000;
this->Timer->Tick += gcnew System::EventHandler(this, &MulaiGame::timer1_Tick);
//
// Time
//
this->Time->AutoSize = true;
this->Time->Font = (gcnew System::Drawing::Font(L"Courier New", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->Time->Location = System::Drawing::Point(461, 13);
this->Time->Name = L"Time";
this->Time->Size = System::Drawing::Size(65, 22);
this->Time->TabIndex = 12;
this->Time->Text = L"0 : 0";
this->Time->TextAlign = System::Drawing::ContentAlignment::TopCenter;
this->Time->Click += gcnew System::EventHandler(this, &MulaiGame::Time_Click);
//
// label5
//
this->label5->AutoSize = true;
this->label5->Location = System::Drawing::Point(274, 248);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(0, 13);
this->label5->TabIndex = 13;
//
// lblNilaiAnda
//
this->lblNilaiAnda->AutoSize = true;
this->lblNilaiAnda->Font = (gcnew System::Drawing::Font(L"Courier New", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->lblNilaiAnda->Location = System::Drawing::Point(189, 66);
this->lblNilaiAnda->Name = L"lblNilaiAnda";
this->lblNilaiAnda->Size = System::Drawing::Size(21, 22);
this->lblNilaiAnda->TabIndex = 14;
this->lblNilaiAnda->Text = L"0";
this->lblNilaiAnda->Click += gcnew System::EventHandler(this, &MulaiGame::lblNilaiAnda_Click);
//
// lblNilaiComp
//
this->lblNilaiComp->AutoSize = true;
this->lblNilaiComp->Font = (gcnew System::Drawing::Font(L"Courier New", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->lblNilaiComp->Location = System::Drawing::Point(366, 66);
this->lblNilaiComp->Name = L"lblNilaiComp";
this->lblNilaiComp->Size = System::Drawing::Size(21, 22);
this->lblNilaiComp->TabIndex = 15;
this->lblNilaiComp->Text = L"0";
//
// label6
//
this->label6->AutoSize = true;
this->label6->Font = (gcnew System::Drawing::Font(L"Courier New", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label6->Location = System::Drawing::Point(24, 5);
this->label6->Name = L"label6";
this->label6->Size = System::Drawing::Size(76, 22);
this->label6->TabIndex = 16;
this->label6->Text = L"label6";
this->label6->Click += gcnew System::EventHandler(this, &MulaiGame::label6_Click);
//
// dateTimePicker1
//
this->dateTimePicker1->CalendarFont = (gcnew System::Drawing::Font(L"Courier New", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->dateTimePicker1->Location = System::Drawing::Point(225, 5);
this->dateTimePicker1->Name = L"dateTimePicker1";
this->dateTimePicker1->Size = System::Drawing::Size(200, 20);
this->dateTimePicker1->TabIndex = 17;
//
// button3
//
this->button3->Font = (gcnew System::Drawing::Font(L"Courier New", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->button3->Location = System::Drawing::Point(309, 310);
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(87, 34);
this->button3->TabIndex = 18;
this->button3->Text = L"EXIT";
this->button3->UseVisualStyleBackColor = true;
this->button3->Click += gcnew System::EventHandler(this, &MulaiGame::button3_Click);
//
// linkLabel1
//
this->linkLabel1->AutoSize = true;
this->linkLabel1->Location = System::Drawing::Point(522, 352);
this->linkLabel1->Name = L"linkLabel1";
this->linkLabel1->Size = System::Drawing::Size(63, 13);
this->linkLabel1->TabIndex = 19;
this->linkLabel1->TabStop = true;
this->linkLabel1->Text = L"AboutGame";
this->linkLabel1->LinkClicked += gcnew System::Windows::Forms::LinkLabelLinkClickedEventHandler(this, &MulaiGame::linkLabel1_LinkClicked);
//
// linkLabel2
//
this->linkLabel2->AutoSize = true;
this->linkLabel2->Location = System::Drawing::Point(28, 352);
this->linkLabel2->Name = L"linkLabel2";
this->linkLabel2->Size = System::Drawing::Size(151, 13);
this->linkLabel2->TabIndex = 20;
this->linkLabel2->TabStop = true;
this->linkLabel2->Text = L"©copyright by Adic Komalasari";
this->linkLabel2->LinkClicked += gcnew System::Windows::Forms::LinkLabelLinkClickedEventHandler(this, &MulaiGame::linkLabel2_LinkClicked);
//
// axWindowsMediaPlayer1
//
this->axWindowsMediaPlayer1->Enabled = true;
this->axWindowsMediaPlayer1->Location = System::Drawing::Point(402, 299);
this->axWindowsMediaPlayer1->Name = L"axWindowsMediaPlayer1";
this->axWindowsMediaPlayer1->OcxState = (cli::safe_cast<System::Windows::Forms::AxHost::State^  >(resources->GetObject(L"axWindowsMediaPlayer1.OcxState")));
this->axWindowsMediaPlayer1->Size = System::Drawing::Size(75, 66);
this->axWindowsMediaPlayer1->TabIndex = 21;
this->axWindowsMediaPlayer1->Visible = false;
this->axWindowsMediaPlayer1->Enter += gcnew System::EventHandler(this, &MulaiGame::axWindowsMediaPlayer1_Enter);
//
// timer1
//
this->timer1->Enabled = true;
this->timer1->Interval = 1000;
this->timer1->Tick += gcnew System::EventHandler(this, &MulaiGame::timer1_Tick_1);
//
// MulaiGame
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor = System::Drawing::Color::White;
this->BackgroundImage = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"$this.BackgroundImage")));
this->ClientSize = System::Drawing::Size(602, 376);
this->Controls->Add(this->axWindowsMediaPlayer1);
this->Controls->Add(this->linkLabel2);
this->Controls->Add(this->linkLabel1);
this->Controls->Add(this->button3);
this->Controls->Add(this->dateTimePicker1);
this->Controls->Add(this->label6);
this->Controls->Add(this->lblNilaiComp);
this->Controls->Add(this->lblNilaiAnda);
this->Controls->Add(this->label5);
this->Controls->Add(this->Time);
this->Controls->Add(this->button1);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->pictureBox6);
this->Controls->Add(this->pictureBox5);
this->Controls->Add(this->pictureBox4);
this->Controls->Add(this->pictureBox3);
this->Controls->Add(this->pictureBox2);
this->Controls->Add(this->pictureBox1);
this->Name = L"MulaiGame";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
this->Text = L"MulaiGame";
this->Load += gcnew System::EventHandler(this, &MulaiGame::MulaiGame_Load);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox2))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox3))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox4))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox5))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox6))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->axWindowsMediaPlayer1))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();

}

#pragma endregion

// static System::Windows::Forms::timer1^ myTimer = gcnew System::Windows::Forms::timer1;
private: System::Void pictureBox6_Click(System::Object^  sender, System::EventArgs^  e) {


}
private: System::Void pictureBox1_Click(System::Object^  sender, System::EventArgs^  e) {
this->pictureBox1->Location = System::Drawing::Point(189, 138);
int i=0;
Random^ r = gcnew Random();
i=r->Next(3);
if(i==0){
this->pictureBox4->Location = System::Drawing::Point(295, 138);
label4->Text="SERI";
}
else if (i==1){
this->pictureBox5->Location = System::Drawing::Point(295, 140);
label4->Text="MENANG";
pointanda+=10;
}
else if (i==2){
this->pictureBox6->Location = System::Drawing::Point(295, 138);
label4->Text="KALAH";
pointcomp+=10;
}
lblNilaiAnda->Text=System::Convert::ToString(pointanda);
lblNilaiComp->Text=System::Convert::ToString(pointcomp);
if(pointanda == 50){
MessageBox::Show("SELAMAT ANDA MENANG !");

}
if(pointcomp == 50){
MessageBox::Show("MAAF ANDA KALAH !");
}

}
private: System::Void MulaiGame_Load(System::Object^  sender, System::EventArgs^  e) {

}
private: System::Void pictureBox2_Click(System::Object^  sender, System::EventArgs^  e) {
this->pictureBox2->Location = System::Drawing::Point(194, 141);
int i=0;
Random^ r = gcnew Random();
i=r->Next(3);
if(i==0){
this->pictureBox4->Location = System::Drawing::Point(295, 138);
label4->Text="KALAH";
pointcomp+=10;
}
else if (i==1){
this->pictureBox5->Location = System::Drawing::Point(295, 140);
label4->Text="SERI";

}
else if (i==2){
this->pictureBox6->Location = System::Drawing::Point(295, 138);
label4->Text="MENANG";
pointanda+=10;
}
lblNilaiAnda->Text=System::Convert::ToString(pointanda);
lblNilaiComp->Text=System::Convert::ToString(pointcomp);
if(pointanda == 50){
MessageBox::Show("SELAMAT, ANDA MENANG");

}
if(pointcomp == 50){
MessageBox::Show("MAAF, ANDA KALAH !");
}
}
private: System::Void pictureBox3_Click(System::Object^  sender, System::EventArgs^  e) {
this->pictureBox3->Location = System::Drawing::Point(194, 138);
int i=0;
Random^ r = gcnew Random();
i=r->Next(3);
if(i==0){
this->pictureBox4->Location = System::Drawing::Point(295, 138);
label4->Text="MENANG";
pointanda+=10;
}
else if (i==1){
this->pictureBox5->Location = System::Drawing::Point(295, 140);
label4->Text="KALAH";
pointcomp+=10;

}
else if (i==2){
this->pictureBox6->Location = System::Drawing::Point(295, 138);
label4->Text="SERI";

}
lblNilaiAnda->Text=System::Convert::ToString(pointanda);
lblNilaiComp->Text=System::Convert::ToString(pointcomp);
if(pointanda == 50){
MessageBox::Show("SELAMAT, ANDA MENANG");

}
if(pointcomp == 50){
MessageBox::Show("MAAF, ANDA KALAH !");
}
}
private: System::Void pictureBox4_Click(System::Object^  sender, System::EventArgs^  e) {
}
private: System::Void pictureBox5_Click(System::Object^  sender, System::EventArgs^  e) {

}
private: System::Void pictureBox1_MouseClick(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) {

}
private: System::Void pictureBox4_MouseClick(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) {
}
private: System::Void pictureBox2_MouseClick(System::Object^  sender, System::Windows::Forms::MouseEventArgs^  e) {
}
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
this->pictureBox1->Location = System::Drawing::Point(28, 51);
this->pictureBox2->Location = System::Drawing::Point(28, 151);
this->pictureBox3->Location = System::Drawing::Point(28, 248);
this->pictureBox4->Location = System::Drawing::Point(461, 51);
this->pictureBox5->Location = System::Drawing::Point(461, 151);
this->pictureBox6->Location = System::Drawing::Point(461, 248);
label4->Text="";
}
private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {

 time_t rawtime;
struct tm * timeinfo;

char j,m,d;
time(&rawtime);
timeinfo=localtime(&rawtime);
j=timeinfo->tm_hour;
m=timeinfo->tm_min;
d=timeinfo->tm_sec;

label6->Text=j.ToString() + " : "+m.ToString() + " : "+d.ToString();

}
private: System::Void Time_Click(System::Object^  sender, System::EventArgs^  e) {

}
private: System::Void label1_Click(System::Object^  sender, System::EventArgs^  e) {
}
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
}
private: System::Void lblNilaiAnda_Click(System::Object^  sender, System::EventArgs^  e) {

}
private: System::Void label6_Click(System::Object^  sender, System::EventArgs^  e) {
}
private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) {
Application::Exit();
}
private: System::Void linkLabel1_LinkClicked(System::Object^  sender, System::Windows::Forms::LinkLabelLinkClickedEventArgs^  e) {
AboutGame ^ form = gcnew AboutGame;
form->Show();
}
private: System::Void linkLabel2_LinkClicked(System::Object^  sender, System::Windows::Forms::LinkLabelLinkClickedEventArgs^  e) {
copyright ^ form = gcnew copyright;
form->Show();

}
private: System::Void axWindowsMediaPlayer1_Enter(System::Object^  sender, System::EventArgs^  e) {

}
private: System::Void label4_Click(System::Object^  sender, System::EventArgs^  e) {
}

private: System::Void timer1_Tick_1(System::Object^  sender, System::EventArgs^  e) {
Second++;
if(Second == 60)
{
Second = 0;
Minute++;
}

if (Second==20){
timer1->Enabled=false;
MessageBox::Show("GAME OVER.....!!!!!!!!!");

}

Sec = Convert::ToString(Second);
Min = Convert::ToString(Minute);
Time->Text = Min + ":" + Sec;

}
};
}
 dan Hasil Programnya