Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**Virtual Pet GUI
- * T.J. Durkin
- * 1st Period
- */
- import java.awt.*;
- import BreezySwing.*;
- import javax.swing.*;
- class VirtualPetGUI extends GBFrame{
- Mouse Mickey=new Mouse("Mouse",2,2,2,2,2); //initialize mouse
- JTextField Stats=addTextField("",1,1,4,4);//stats text field
- JButton Read=addButton("Read your mouse a book",5,1,1,1);//add intelligence
- JButton Wheel=addButton("Put your mouse on mouse wheel(increases stamina but uses energy)",5,2,1,1);//add stamina take energy
- JButton Feed=addButton("Feed your mouse straw(increases health and energy)",5,3,1,1);//add health and energy
- JButton Play=addButton("Play with your mouse(increases strength and stamina but uses energy)",5,4,1,1);//add strength take stamina
- JButton Workout=addButton("Work out your mouse(increases strength but uses energy)",5,5,1,1);//add strength take energy
- boolean actionperformed=false;//create actionperformed boolean
- JLabel label=addLabel("",1,1,3,3);//label for pictures
- JLabel mouse=addLabel("",1,5,3,3);//add a label for the picture of your cat
- ImageIcon book=new ImageIcon("Book.jpg");//bookimage
- ImageIcon wheel=new ImageIcon("wheel.jpg");//wheel image
- ImageIcon weights=new ImageIcon("weights.jpg");//weights image
- ImageIcon playing=new ImageIcon("playing.jpg");//playing image
- ImageIcon Mouse=new ImageIcon("Mouse.png");//mouse image
- ImageIcon Straw=new ImageIcon("Straw.png");//straw image
- ImageIcon deadmouse=new ImageIcon("deadmouse.jpg");//deadmouse image
- JMenuItem author=addMenuItem("File","Author");//author menu item
- JMenuItem instructions=addMenuItem("File","Instructions");//instrucitions menu item
- public VirtualPetGUI(){
- Stats.setText(Mickey.toString()); //sets stats text feild to read the stats of the mouse
- mouse.setIcon(Mouse);
- }
- public void buttonClicked(JButton button){
- if(button==Read&&actionperformed==false){//add intelligence
- Mickey.setIntelligence(Mickey.getIntelligence()+2);//increases intelligence of mouse
- actionperformed=true;//set actionperformed to true
- label.setIcon(book);//set icon to book
- Stats.setText(Mickey.toString()+"");//return stats
- }
- if(button==Wheel&&actionperformed==false){//add stamina take energy
- Mickey.setStamina(Mickey.getStamina()+3);//increases the stamina of the mouse
- Mickey.setEnergy(Mickey.getEnergy()-5);//decreases the energy of the mouse
- actionperformed=true;//set actionperformed to true
- label.setIcon(wheel);//set icon to wheel
- Stats.setText(Mickey.toString()+"");//return stats
- }
- if(button==Feed&&actionperformed==false){//add health take energy
- Mickey.setHealth(Mickey.getHealth()+5);//increases the health of the mouse
- Mickey.setEnergy(Mickey.getEnergy()+5);//increases the energy of the mouse
- actionperformed=true;//set actionperformed to true
- label.setIcon(Straw);//set icon to straw
- Stats.setText(Mickey.toString()+"");//return stats
- }
- if(button==Play&&actionperformed==false){//add strength and stamina take energy
- mouse.setStrength(mouse.getStrength()+1);//increases the strength of the mouse
- mouse.setStamina(mouse.getStamina()+1);//increases the stamina of the mouse
- mouse.setEnergy(mouse.getEnergy()-5);//decreases the energy of the mouse
- actionperformed=true;//set actionperformed to true
- label.setIcon(playing);//set icon to playing
- Stats.setText(Mickey.toString()+"");//return stats
- }
- if(button==Workout&&actionperformed==false){//add strength take energy
- mouse.setHealth(mouse.getStrength()+3);//increases the strength of the mouse
- mouse.setEnergy(mouse.getEnergy()-5);//decreases the energy of the mouse
- actionperformed=true;//set actionperformed to true
- label.setIcon(weights);//set icon to weights
- Stats.setText(Mickey.toString()+"");//return stats
- }
- }
- public void menuItemSelected(JMenuItem menuItem){
- if(menuItem==author){
- messageBox("By:T.J. Durkin");
- }
- if(menuItem==instructions){
- messageBox("Click one of the buttons to change the conditons of your mouse. Take into consideration the positve\n and negative effects of your choices. The goal is to not kill your mouse.");
- }
- }
- public static void main( String[] args ){
- VirtualPetGUI intro=new VirtualPetGUI();//create the frame
- intro.setTitle("Mouse");
- intro.setSize(1500,900);
- intro.setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement