Newer
Older
moobreeder / MooBreeder.java
/**
 * Moobreeder is a simple cow breeding game to illustrate the principles of
 * selective breeding to KS3 pupils.
 *
 * (c) Daniel Vedder 2018,
 * Amano Christian School
 */

/*
 * This is the main class with the GUI.
 */

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.ArrayList;

public class MooBreeder extends JFrame
{
	private JMenuBar menubar;
	private JMenu fileMenu, helpMenu;
	private JMenuItem reset, quit, help, about;
	private Box herdBox, parentBox, offspringBox;
	private Box motherBox, fatherBox, child1Box, child2Box;
	private JButton add, breed, keep, remove;

	private ArrayList<Cow> herd;
	private Cow[] parents;
	private Cow[] offspring;

	public static void main(String[] args)
	{
		MooBreeder mb = new MooBreeder();
	}
	
	public MooBreeder()
	{
		this.setTitle("MooBreeder");
		this.setSize(800, 400);
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		this.createMenu();
		this.createLayout();
		//TODO
		this.setVisible(true);
	}

	private void createMenu()
	{
		menubar = new JMenuBar();
		fileMenu = new JMenu("File");
		helpMenu = new JMenu("Help");
		reset = new JMenuItem("Reset");
		quit = new JMenuItem("Exit");
		help = new JMenuItem("Help");
		about = new JMenuItem("About");
		//TODO
		quit.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		about.addActionListener(new ActionListener() {
		   public void actionPerformed(ActionEvent e) {
				JOptionPane.showMessageDialog(null, "MooBreeder - an educational breeding game"+
											  "\n(c) 2018 Daniel Vedder"+
											  "\nAmano Christian School", "About",
											  JOptionPane.INFORMATION_MESSAGE);
			}
		});
		fileMenu.add(reset);
		fileMenu.add(quit);
		helpMenu.add(help);
		helpMenu.add(about);
		menubar.add(fileMenu);
		menubar.add(helpMenu);
		this.setJMenuBar(menubar);
	}

	private void createLayout()
	{
		//TODO
		herdBox = new Box(BoxLayout.Y_AXIS);
		Box breedBox = new Box(BoxLayout.Y_AXIS);
		parentBox = new Box(BoxLayout.Y_AXIS);
		offspringBox = new Box(BoxLayout.Y_AXIS);
		this.add(herdBox, BorderLayout.WEST);
		this.add(breedBox, BorderLayout.EAST);
		breedBox.add(parentBox);
		breedBox.add(offspringBox);
		updateHerdBox();
		updateParentBox();
		updateOffspringBox();
	}

	private void updateHerdBox()
	{
		//TODO
		JLabel label = new JLabel("Your current herd:");
		herdBox.add(label);
	}

	private void updateParentBox()
	{
		//TODO
		JLabel label = new JLabel("Parents");
		parentBox.add(label);
	}


	private void updateOffspringBox()
	{
		//TODO
		JLabel label = new JLabel("Offspring");
		offspringBox.add(label);
	}

}