Platypus - Cos 240 Object Oriented Languages Professor...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Cos 240 – Object Oriented Languages Professor: Svetla Boycheva Extra Assignment: Platypus 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
I hereby declare that the submitted answers are all my own work; that I did not copy them from someone else; and that no one but me answered the questions. Signature April 16, 2010 I have successfully completed the assignment. Code 2
Background image of page 2
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Garden extends JFrame { private int score; // Total score of the player private Platypus[] array; // Array that will store the platypuses private JLabel totalScore; // The label will contain the score public Garden() { array = new Platypus[15]; for (int i = 0; i < 15; i+=3) { // create the platypus objects array[i] = new Platypus(); array[i+1] = new StonePlatypus(); array[i+2] = new RapidPlatypus(); } setLayout(new FlowLayout()); totalScore = new JLabel(); totalScore.setText("Total score: " + new Integer(score).toString()); add(totalScore); for (int i = 0; i < 15; i++) { add(array[i].label()); // add the platypuses } Container cont = this.getContentPane(); cont.setBackground(Color.GREEN); setTitle("Platypus"); setSize(600, 500); // The GUI dimensions setLocation(new Point(50, 50)); //The GUI position setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setVisible(true); } public class Platypus implements MouseListener
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

Platypus - Cos 240 Object Oriented Languages Professor...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online