Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What Will Be Assessed: Develop, test, and execute a graphic application for simulations using Java. Create a Java application. Given a set of events, choose

What Will Be Assessed:

Develop, test, and execute a graphic application for simulations using Java.

Create a Java application.

Given a set of events, choose the resulting programming actions.

Understand the principles behind Java.

Understand the basic principles of object-oriented programming including classes and inheritance.

Deliverables

.java files as requested below.

Contents

Make sure all the options are working.

Requirements:

Have the many campus panels with some action in it. Even if each campus game is not completely functional, it has at least a sketch of what the game will be.

The application has a working timer.

Campus panels have some graphics or other pertinent information in them.

All 3 options (with 3 choices each) are working and have some influence on how the game is played.

trivia game

to start making the campus games, even if they don't work fully, and make sure that the"theme" the player selected affects the game. We also have to implement a timer for the game. For the theme transfer, I think we can just add a string to each campus in the constructor that we can feed with the theme that the map panel already has from the theme selection panel. Then we just use 3 "if" statements in each panel, we can have the game play differently for each chosen theme.So the code for each campus game will be within the individual campus panels then it will just auto-play when the campus is chosen on the map. And when the game is over it can auto click the "return" button with .doClick(), or we can have it show an end game type screen by rearranging the panel components and having it show something like you scored whatever in this game, and then add the return button so that they player can go back.So need to make 3 sets of questions right? One for each potential theme that's chosen on the menu? Maybe could do like psu football player names, math formulas, and programming definitions? For the trivia game.

6 valid, 6 invalid of each

public class app {

public static void main(String args[]) {

group6JFrame gjf = new group6JFrame();

}

}

import java.awt.*;

import javax.swing.*;

public class group6JFrame extends JFrame {

JPanelControl jpc;

public group6JFrame() {

super("Group 06: First Final Project Deliverable");

jpc = new JPanelControl();

getContentPane().setLayout(new BorderLayout());

getContentPane().add(jpc, "Center");

setDefaultCloseOperation(EXIT_ON_CLOSE);

setSize(640, 480);

setVisible(true);

}

}

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

public class JPanelControl extends JPanel implements ActionListener {

JPanelIntro jpIntro;

JPanelInstructions jpInstructions;

JPanelDevelopers jpDevelopers;

JPanelThemeSelection jpTS;

JPanelCampus jpCampus;

public JPanelControl() {

super();

setBackground(Color.LIGHT_GRAY);

setLayout(new GridLayout(1, 1));

jpIntro = new JPanelIntro();

jpIntro.jbStart.addActionListener(this);

jpIntro.jbInstructions.addActionListener(this);

jpIntro.jbDevelopers.addActionListener(this);

jpTS = new JPanelThemeSelection();

jpTS.jbTS1.addActionListener(this);

jpTS.jbTS2.addActionListener(this);

jpTS.jbTS3.addActionListener(this);

jpInstructions = new JPanelInstructions();

jpInstructions.jbInstructs5.addActionListener(this);

jpDevelopers = new JPanelDevelopers();

jpDevelopers.jbDev5.addActionListener(this);

add(jpIntro);

}

@Override

public void actionPerformed(ActionEvent event) {

Object obj = event.getSource();

if (obj == jpIntro.jbStart) {

remove(jpIntro);

add(jpTS);

validate();

repaint();

}

if (obj == jpIntro.jbInstructions) {

remove(jpIntro);

add(jpInstructions);

validate();

repaint();

}

if (obj == jpInstructions.jbInstructs5) {

remove(jpInstructions);

add(jpIntro);

validate();

repaint();

}

if (obj == jpIntro.jbDevelopers) {

remove(jpIntro);

add(jpDevelopers);

validate();

repaint();

}

if (obj == jpDevelopers.jbDev5) {

remove(jpDevelopers);

add(jpIntro);

validate();

repaint();

}

if (obj == jpTS.jbTS1) {

jpCampus = new JPanelCampus("programming");

remove(jpTS);

add(jpCampus);

validate();

repaint();

}

if (obj == jpTS.jbTS2) {

jpCampus = new JPanelCampus("football");

remove(jpTS);

add(jpCampus);

validate();

repaint();

}

if (obj == jpTS.jbTS3) {

jpCampus = new JPanelCampus("math");

remove(jpTS);

add(jpCampus);

validate();

repaint();

}

}

}

import java.awt.*;

import javax.swing.*;

public class JPanelIntro extends JPanel {

JButton jbStart, jbInstructions, jbDevelopers;

JLabel jlTitle1, jlTitle2;

public JPanelIntro() {

super();

setLayout(null);

jlTitle1 = new JLabel("Welcome To The Penn State Game!");

jlTitle1.setBounds(new Rectangle(220, 10, 200, 40));

add(jlTitle1);

jlTitle2 = new JLabel("Select an Option:");

jlTitle2.setBounds(new Rectangle(270, 40, 200, 40));

add(jlTitle2);

jbStart = new JButton("Start Game");

jbStart.setBounds(new Rectangle(230, 90, 180, 80));

add(jbStart);

jbInstructions = new JButton("Instructions");

jbInstructions.setBounds(new Rectangle(230, 200, 180, 80));

add(jbInstructions);

jbDevelopers = new JButton("Game Developers");

jbDevelopers.setBounds(new Rectangle(230, 310, 180, 80));

add(jbDevelopers);

}

@Override

public void paintComponent(Graphics g) {

super.paintComponent(g);

Image myImage = Toolkit.getDefaultToolkit().getImage("images/background.jpg");

g.drawImage(myImage, 0, 0, this);

}

}

import java.awt.*;

import javax.swing.*;

public class JPanelInstructions extends JPanel {

JButton jbInstructs1, jbInstructs2, jbInstructs3, jbInstructs4, jbInstructs5;

public JPanelInstructions() {

super();

setLayout(null);

jbInstructs1 = new JButton("1. Move your player to the campus of your choice.");

jbInstructs1.setBounds(new Rectangle(50, 120, 500, 40));

jbInstructs1.setRolloverEnabled(false);

jbInstructs1.setFocusPainted(false);

add(jbInstructs1);

jbInstructs2 = new JButton("2. Each campus will contain a quiz or puzzle.");

jbInstructs2.setBounds(new Rectangle(50, 170, 500, 40));

jbInstructs2.setRolloverEnabled(false);

jbInstructs2.setFocusPainted(false);

add(jbInstructs2);

jbInstructs3 = new JButton("3. Solve the puzzle to conquer the campus.");

jbInstructs3.setBounds(new Rectangle(50, 220, 500, 40));

jbInstructs3.setRolloverEnabled(false);

jbInstructs3.setFocusPainted(false);

add(jbInstructs3);

jbInstructs4 = new JButton("4. Continue to the next campus until all have been completed!");

jbInstructs4.setBounds(new Rectangle(50, 270, 500, 40));

jbInstructs4.setRolloverEnabled(false);

jbInstructs4.setFocusPainted(false);

add(jbInstructs4);

jbInstructs5 = new JButton("Return to Menu");

jbInstructs5.setBounds(new Rectangle(50, 340, 150, 40));

add(jbInstructs5);

}

@Override

public void paintComponent(Graphics g) {

super.paintComponent(g);

Image myImage = Toolkit.getDefaultToolkit().getImage("images/background.jpg");

g.drawImage(myImage, 0, 0, this);

}

}

import java.awt.*;

import javax.swing.*;

public class JPanelDevelopers extends JPanel {

JButton jbDev1, jbDev2, jbDev3, jbDev4, jbDev5;

public JPanelDevelopers() {

super();

setLayout(null);

jbDev1 = new JButton("Allison Morrow");

jbDev1.setBounds(new Rectangle(220, 90, 200, 40));

jbDev1.setRolloverEnabled(false);

jbDev1.setFocusPainted(false);

add(jbDev1);

jbDev2 = new JButton("Thomas O'Mara");

jbDev2.setBounds(new Rectangle(220, 150, 200, 40));

jbDev2.setRolloverEnabled(false);

jbDev2.setFocusPainted(false);

add(jbDev2);

jbDev3 = new JButton("Kaija Rose");

jbDev3.setBounds(new Rectangle(220, 210, 200, 40));

jbDev3.setRolloverEnabled(false);

jbDev3.setFocusPainted(false);

add(jbDev3);

jbDev4 = new JButton("Saima Sultana");

jbDev4.setBounds(new Rectangle(220, 270, 200, 40));

jbDev4.setRolloverEnabled(false);

jbDev4.setFocusPainted(false);

add(jbDev4);

jbDev5 = new JButton("Return to Menu");

jbDev5.setBounds(new Rectangle(50, 340, 150, 40));

add(jbDev5);

}

@Override

public void paintComponent(Graphics g) {

super.paintComponent(g);

Image myImage = Toolkit.getDefaultToolkit().getImage("images/background.jpg");

g.drawImage(myImage, 0, 0, this);

}

}

import java.awt.*;

import javax.swing.*;

public class JPanelThemeSelection extends JPanel {

JButton jbTS1, jbTS2, jbTS3;

JLabel jlTheme;

ImageIcon imageProgramming, imageFootball, imageMath;

public JPanelThemeSelection() {

super();

setLayout(null);

jlTheme = new JLabel("Select your Theme:");

jlTheme.setBounds(new Rectangle(265, 15, 220, 20));

add(jlTheme);

imageProgramming = new ImageIcon("images/programming.png");

jbTS1 = new JButton(" Programming");

jbTS1.setBounds(new Rectangle(210, 50, 220, 100));

jbTS1.setIcon(imageProgramming);

add(jbTS1);

imageFootball = new ImageIcon("images/football.png");

jbTS2 = new JButton(" Football ");

jbTS2.setBounds(new Rectangle(210, 180, 220, 100));

jbTS2.setIcon(imageFootball);

add(jbTS2);

imageMath = new ImageIcon("images/pi.png");

jbTS3 = new JButton(" Math ");

jbTS3.setBounds(new Rectangle(210, 310, 220, 100));

jbTS3.setIcon(imageMath);

add(jbTS3);

}

@Override

public void paintComponent(Graphics g) {

super.paintComponent(g);

Image myImage = Toolkit.getDefaultToolkit().getImage("images/background.jpg");

g.drawImage(myImage, 0, 0, this);

}

}

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

public class JPanelCampus extends JPanel implements KeyListener {

JButton jbUniversityPark, jbWorldCampus, jbBrandywine, jbFayett, jbErie, jbWorthingtonScranton, jbPlayer;

JLabel jlUniversityPark, jlWorldCampus, jlBrandywine, jlFayett, jlErie, jlWorthingtonScranton;

ImageIcon imageCampusIcon, imageWorldCampus, imagePlayerProgramming, imagePlayerFootball, imagePlayerMath;

int playerX, playerY;

String theme;

public JPanelCampus(String infTheme) {

super();

setLayout(null);

setFocusable(true);

addKeyListener(this);

theme = infTheme;

imageCampusIcon = new ImageIcon("images/campusIcon.png");

imageWorldCampus = new ImageIcon("images/worldCampus.png");

jbUniversityPark = new JButton();

jbUniversityPark.setBounds(new Rectangle(270, 200, 75, 50));

jbUniversityPark.setBorderPainted(false);

jbUniversityPark.setContentAreaFilled(false);

jbUniversityPark.setIcon(imageCampusIcon);

jlUniversityPark = new JLabel("University Park");

jlUniversityPark.setBounds(new Rectangle(265, 250, 100, 20));

add(jbUniversityPark);

add(jlUniversityPark);

jbWorldCampus = new JButton();

jbWorldCampus.setBounds(new Rectangle(290, 40, 75, 50));

jbWorldCampus.setBorderPainted(false);

jbWorldCampus.setContentAreaFilled(false);

jbWorldCampus.setIcon(imageWorldCampus);

jlWorldCampus = new JLabel("World Campus");

jlWorldCampus.setBounds(new Rectangle(285, 90, 100, 20));

add(jbWorldCampus);

add(jlWorldCampus);

jbBrandywine = new JButton();

jbBrandywine.setBounds(new Rectangle(500, 360, 75, 50));

jbBrandywine.setBorderPainted(false);

jbBrandywine.setContentAreaFilled(false);

jbBrandywine.setIcon(imageCampusIcon);

jlBrandywine = new JLabel("Brandywine");

jlBrandywine.setBounds(new Rectangle(430, 375, 100, 20));

add(jbBrandywine);

add(jlBrandywine);

jbFayett = new JButton();

jbFayett.setBounds(new Rectangle(50, 350, 75, 50));

jbFayett.setBorderPainted(false);

jbFayett.setContentAreaFilled(false);

jbFayett.setIcon(imageCampusIcon);

jlFayett = new JLabel("Fayett");

jlFayett.setBounds(new Rectangle(125, 365, 100, 20));

add(jbFayett);

add(jlFayett);

jbErie = new JButton();

jbErie.setBounds(new Rectangle(20, 30, 75, 50));

jbErie.setBorderPainted(false);

jbErie.setContentAreaFilled(false);

jbErie.setIcon(imageCampusIcon);

jlErie = new JLabel("Erie");

jlErie.setBounds(new Rectangle(45, 80, 100, 20));

add(jbErie);

add(jlErie);

jbWorthingtonScranton = new JButton();

jbWorthingtonScranton.setBounds(new Rectangle(490, 135, 75, 50));

jbWorthingtonScranton.setBorderPainted(false);

jbWorthingtonScranton.setContentAreaFilled(false);

jbWorthingtonScranton.setIcon(imageCampusIcon);

jlWorthingtonScranton = new JLabel("Worthington Scranton");

jlWorthingtonScranton.setBounds(new Rectangle(465, 185, 150, 20));

add(jbWorthingtonScranton);

add(jlWorthingtonScranton);

playerX = 280;

playerY = 320;

imagePlayerProgramming = new ImageIcon("images/playerProgramming.png");

imagePlayerFootball = new ImageIcon("images/playerFootball.png");

imagePlayerMath = new ImageIcon("images/playerMath.png");

jbPlayer = new JButton();

jbPlayer.setBorderPainted(false);

jbPlayer.setContentAreaFilled(false);

jbPlayer.setRolloverEnabled(false);

jbPlayer.setBounds(new Rectangle(playerX, playerY, 50, 50));

if (theme.equals("programming")) {

jbPlayer.setIcon(imagePlayerProgramming);

add(jbPlayer);

validate();

repaint();

}

if (theme.equals("football")) {

jbPlayer.setIcon(imagePlayerFootball);

add(jbPlayer);

validate();

repaint();

}

if (theme.equals("math")) {

jbPlayer.setIcon(imagePlayerMath);

add(jbPlayer);

validate();

repaint();

}

}

@Override

public void keyPressed(KeyEvent e) {

int key = e.getKeyCode();

if (key == KeyEvent.VK_LEFT) {

if (playerX > 0) {

playerX = playerX - 2;

jbPlayer.setBounds(new Rectangle(playerX, playerY, 50, 50));

}

}

if (key == KeyEvent.VK_RIGHT) {

if (playerX < 574) {

playerX = playerX + 2;

jbPlayer.setBounds(new Rectangle(playerX, playerY, 50, 50));

}

}

if (key == KeyEvent.VK_UP) {

if (playerY > 0) {

playerY = playerY - 2;

jbPlayer.setBounds(new Rectangle(playerX, playerY, 50, 50));

}

}

if (key == KeyEvent.VK_DOWN) {

if (playerY < 395) {

playerY = playerY + 2;

jbPlayer.setBounds(new Rectangle(playerX, playerY, 50, 50));

}

}

}

public void keyReleased(KeyEvent e) {

}

public void keyTyped(KeyEvent e) {

}

@Override

public void paintComponent(Graphics g) {

super.paintComponent(g);

requestFocusInWindow();

Image myImage = Toolkit.getDefaultToolkit().getImage("images/campusMap.png");

g.drawImage(myImage, 0, 0, this);

}

}

import java.awt.*;

import javax.swing.*;

public class JPanelUniversityPark extends JPanel {

JLabel jlUniversityPark;

JButton jbBack;

public JPanelUniversityPark() {

super();

setLayout(null);

jlUniversityPark = new JLabel("UNIVERSITY PARK");

jlUniversityPark.setBounds(new Rectangle(300, 20, 220, 20));

add(jlUniversityPark);

jbBack = new JButton("Back");

jbBack.setBounds(new Rectangle(270, 270, 100, 40));

add(jbBack);

}

@Override

public void paintComponent(Graphics g) {

super.paintComponent(g);

Image myImage = Toolkit.getDefaultToolkit().getImage("images/background.jpg");

g.drawImage(myImage, 0, 0, this);

}

}

import java.awt.*;

import javax.swing.*;

public class JPanelWorldCampus extends JPanel {

JLabel jlWorldCampus;

JButton jbBack;

public JPanelWorldCampus() {

super();

setLayout(null);

jlWorldCampus = new JLabel("WORLD CAMPUS");

jlWorldCampus.setBounds(new Rectangle(300, 20, 220, 20));

add(jlWorldCampus);

jbBack = new JButton("Back");

jbBack.setBounds(new Rectangle(270, 270, 100, 40));

add(jbBack);

}

@Override

public void paintComponent(Graphics g) {

super.paintComponent(g);

Image myImage = Toolkit.getDefaultToolkit().getImage("images/background.jpg");

g.drawImage(myImage, 0, 0, this);

}

}

import java.awt.*;

import javax.swing.*;

public class JPanelBrandywine extends JPanel {

JLabel jlBrandywine;

JButton jbBack;

public JPanelBrandywine() {

super();

setLayout(null);

jlBrandywine = new JLabel("BRANDYWINE");

jlBrandywine.setBounds(new Rectangle(300, 20, 220, 20));

add(jlBrandywine);

jbBack = new JButton("Back");

jbBack.setBounds(new Rectangle(270, 270, 100, 40));

add(jbBack);

}

@Override

public void paintComponent(Graphics g) {

super.paintComponent(g);

Image myImage = Toolkit.getDefaultToolkit().getImage("images/background.jpg");

g.drawImage(myImage, 0, 0, this);

}

}

import java.awt.*;

import javax.swing.*;

public class JPanelFayette extends JPanel {

JLabel jlFayette;

JButton jbBack;

public JPanelFayette() {

super();

setLayout(null);

jlFayette = new JLabel("FAYETTE");

jlFayette.setBounds(new Rectangle(300, 20, 220, 20));

add(jlFayette);

jbBack = new JButton("Back");

jbBack.setBounds(new Rectangle(270, 270, 100, 40));

add(jbBack);

}

@Override

public void paintComponent(Graphics g) {

super.paintComponent(g);

Image myImage = Toolkit.getDefaultToolkit().getImage("images/background.jpg");

g.drawImage(myImage, 0, 0, this);

}

}

import java.awt.*;

import javax.swing.*;

public class JPanelErie extends JPanel {

JLabel jlErie;

JButton jbBack;

public JPanelErie() {

super();

setLayout(null);

jlErie = new JLabel("ERIE");

jlErie.setBounds(new Rectangle(300, 20, 220, 20));

add(jlErie);

jbBack = new JButton("Back");

jbBack.setBounds(new Rectangle(270, 270, 100, 40));

add(jbBack);

}

@Override

public void paintComponent(Graphics g) {

super.paintComponent(g);

Image myImage = Toolkit.getDefaultToolkit().getImage("images/background.jpg");

g.drawImage(myImage, 0, 0, this);

}

}

import java.awt.*;

import javax.swing.*;

public class JPanelWorthingtonScranton extends JPanel {

JLabel jlWorthingtonScranton;

JButton jbBack;

public JPanelWorthingtonScranton() {

super();

setLayout(null);

jlWorthingtonScranton = new JLabel("WORTHINGTON SCRANTON");

jlWorthingtonScranton.setBounds(new Rectangle(300, 20, 220, 20));

add(jlWorthingtonScranton);

jbBack = new JButton("Back");

jbBack.setBounds(new Rectangle(270, 270, 100, 40));

add(jbBack);

}

@Override

public void paintComponent(Graphics g) {

super.paintComponent(g);

Image myImage = Toolkit.getDefaultToolkit().getImage("images/background.jpg");

g.drawImage(myImage, 0, 0, this);

}

}

import java.awt.*;

import javax.swing.*;

public class JPanelEnd extends JPanel {

JLabel jlEnd1, jlEnd2;

JButton jbReset;

public JPanelEnd() {

super();

setLayout(null);

jlEnd1 = new JLabel("Congratulations!");

jlEnd1.setBounds(new Rectangle(270, 160, 100, 25));

jlEnd2 = new JLabel("You Have Successfully Visited Five Penn State Campuses");

jlEnd2.setBounds(new Rectangle(160, 200, 400, 25));

add(jlEnd1);

add(jlEnd2);

jbReset = new JButton("Play Again!");

jbReset.setBounds(new Rectangle(270, 270, 100, 40));

add(jbReset);

}

@Override

public void paintComponent(Graphics g) {

super.paintComponent(g);

Image myImage = Toolkit.getDefaultToolkit().getImage("images/background.jpg");

g.drawImage(myImage, 0, 0, this);

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And SQL

Authors: Lucy Scott

3rd Edition

1087899699, 978-1087899695

More Books

Students also viewed these Databases questions

Question

2. Describe how technology can impact intercultural interaction.

Answered: 1 week ago

Question

7. Define cultural space.

Answered: 1 week ago