Skip to content

a new form for program a game across desing patterns #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions MathHero/.gitignore

This file was deleted.

22 changes: 0 additions & 22 deletions MathHero/Makefile

This file was deleted.

15 changes: 0 additions & 15 deletions MathHero/README.md

This file was deleted.

139 changes: 0 additions & 139 deletions MathHero/src/World.java

This file was deleted.

13 changes: 13 additions & 0 deletions MathHero2/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.espol</groupId>
<artifactId>MathHero2</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
</project>
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package com.espol.mathhero2;
public class Addition extends Enemy
{
protected String problem;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.espol.mathhero2;

public class AdditionEnemyFactory implements EnemyFactory {
@Override
public Enemy createSmallEnemy() {
return new Addition();
}

@Override
public Enemy createBigEnemy() {
return new BigAddition();
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package com.espol.mathhero2;
public class BigAddition extends Enemy
{
protected String problem;
Expand Down
35 changes: 35 additions & 0 deletions MathHero2/src/main/java/com/espol/mathhero2/BigDivision.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.espol.mathhero2;

/**
*
* @author DELL
*/
public class BigDivision extends Enemy {
protected String problem;
protected int solution;

public BigDivision()
{
super(.9);
int n1 = (int)(Math.random()*9)+1;
int n2 = (int)(Math.random()*9)+1;
solution = n1;
problem = ""+(n1*n2)+"/"+n2;
radius = 8;
color = java.awt.Color.RED;
}

public String getProblem()
{
return problem;
}

public int getSolution()
{
return solution;
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package com.espol.mathhero2;
public class BigMultiplication extends Enemy
{
protected String problem;
Expand Down
35 changes: 35 additions & 0 deletions MathHero2/src/main/java/com/espol/mathhero2/BigSubtraction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.espol.mathhero2;

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/

/**
*
* @author DELL
*/
public class BigSubtraction extends Enemy {
protected String problem;
protected int solution;

public BigSubtraction()
{
super(.8);
int n1 = (int)(Math.random()*9)+1;
int n2 = (int)(Math.random()*9)+1;
solution = n1;
problem = ""+(n1+n2)+"-"+n2;
color = java.awt.Color.RED;
}

public String getProblem()
{
return problem;
}

public int getSolution()
{
return solution;
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package com.espol.mathhero2;
public class Division extends Enemy
{
protected String problem;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.espol.mathhero2;

public class DivisionEnemyFactory implements EnemyFactory {

public DivisionEnemyFactory() {
}

@Override
public Enemy createSmallEnemy() {
return new Division();
}

@Override
public Enemy createBigEnemy() {

return new BigDivision();

}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package com.espol.mathhero2;
import java.awt.*;

public abstract class Enemy
Expand Down
14 changes: 14 additions & 0 deletions MathHero2/src/main/java/com/espol/mathhero2/EnemyFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template
*/
package com.espol.mathhero2;

/**
*
* @author DELL
*/
public interface EnemyFactory {
Enemy createSmallEnemy();
Enemy createBigEnemy();
}
7 changes: 7 additions & 0 deletions MathHero2/src/main/java/com/espol/mathhero2/Game.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.espol.mathhero2;
public class Game {
public static void main(String[] args) {
GameFacade gameFacade = new GameFacade();
gameFacade.startGame();
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package com.espol.mathhero2;
import java.util.*;
import java.awt.*;
import java.awt.image.*;
Expand Down
13 changes: 13 additions & 0 deletions MathHero2/src/main/java/com/espol/mathhero2/GameFacade.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.espol.mathhero2;
public class GameFacade {

private MathHero mathHero;

public GameFacade() {
this.mathHero = new MathHero();
}

public void startGame() {
this.mathHero.makeTestWindow();
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package com.espol.mathhero2;
import java.util.*;

import java.awt.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package com.espol.mathhero2;
import java.util.*;
import java.awt.*;
import java.awt.image.*;
Expand Down
Loading