The equals() method tests to see if the "this" object is the same as the "other" object,
22 | * returning true if they are the same, or false if they are not. For this method, assume two
23 | * Items are the same if they have the same "name" String.
24 | *
25 | * @param other the other item to compare
26 | * @return true if the item is equal to the other item, false otherwise
27 | */
28 | @Override
29 | boolean equals(Object other);
30 |
31 | /**
32 | * Every class in Java is a descendant of a built-in superclass, called "Object". The Object
33 | * superclass defines a few useful methods for every Java object, like equals() and toString().
34 | * Since Object is the superclass to every class, that means every Java object has these methods.
35 | * Programmers can override them, if necessary, to supply a subclass-specific version of the
36 | * method. Every Item class should override both equals() and toString().
37 | *
38 | *
The toString() method generates a human-readable, String representation of the object,
39 | * suitable for printing to the console either for debugging or for the eventual user to read. For
40 | * this method, assume the "string representation" of an Item is simply the item's name String.
41 | *
42 | * @return a string representation of the Item object
43 | */
44 | @Override
45 | String toString();
46 | }
47 |
--------------------------------------------------------------------------------
/Adventure-Game/src/main/java/com/comp301/a02adventure/ItemImpl.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a02adventure;
2 |
3 | /**
4 | * An Item object represents an item that can be collected by a player in the game. An Item object
5 | * has a name that can be used to identify the item.
6 | */
7 | public class ItemImpl implements Item {
8 |
9 | // Field to store the name of the item
10 | private final String name;
11 |
12 | /**
13 | * Constructs a new Item object with the specified name.
14 | *
15 | * @param name the name of the item
16 | */
17 | public ItemImpl(String name) {
18 | if (name == null) {
19 | throw new IllegalArgumentException("Item's name cannot be null");
20 | }
21 |
22 | this.name = name;
23 | }
24 |
25 | /**
26 | * A method that returns the name of the item.
27 | *
28 | * @return the name of the item
29 | */
30 | @Override
31 | public String getName() {
32 | return this.name;
33 | }
34 |
35 | /**
36 | * A method that returns a string representation of the Item object.
37 | *
38 | * @return a string representation of the Item object
39 | */
40 | @Override
41 | public String toString() {
42 | return this.name;
43 | }
44 |
45 | /**
46 | * A method that returns true if the item is equal to another item, false otherwise. Two items are
47 | * considered equal if their names are equal.
48 | *
49 | * @param other the other item to compare
50 | * @return true if the item is equal to the other item, false otherwise
51 | */
52 | @Override
53 | public boolean equals(Object other) {
54 | boolean isEqual = false;
55 |
56 | // Check if the other object is null - if so, they are not equal
57 | if (other == null) {
58 | return false;
59 | }
60 |
61 | // Check if the other object is exactly the same object as the current one - if so, they are
62 | // equal
63 | if (this == other) {
64 | return true;
65 | }
66 |
67 | // Check if the other object is an instance of Item - if so, compare the names
68 | if (other instanceof Item) {
69 | Item otherItem = (Item) other;
70 | // If the names are equal, the items are equal
71 | isEqual = this.name.equals(otherItem.getName());
72 | return isEqual;
73 | }
74 |
75 | return isEqual;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/Adventure-Game/src/main/java/com/comp301/a02adventure/Map.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a02adventure;
2 |
3 | /** The Map interface represents a 2D grid of cells. The map is defined by its width and height */
4 | public interface Map {
5 | /**
6 | * Getter method for the width of the map
7 | *
8 | * @return the width of the map
9 | */
10 | int getWidth();
11 |
12 | /**
13 | * Getter method for the height of the map
14 | *
15 | * @return the height of the map
16 | */
17 | int getHeight();
18 |
19 | /**
20 | * Getter method for a specific cell on the map. Throws an IndexOutOfBoundsException for
21 | * coordinate parameters that are not on the map
22 | *
23 | * @param x the x-coordinate of the cell
24 | * @param y the y-coordinate of the cell
25 | * @return the cell at the specified coordinates
26 | */
27 | Cell getCell(int x, int y);
28 |
29 | /**
30 | * Overloaded getter method for a specific cell on the map. Throws an IndexOutOfBoundsException
31 | * for coordinate parameters that are not on the map
32 | *
33 | * @param position the position of the cell
34 | * @return the cell at the specified position
35 | */
36 | Cell getCell(Position position);
37 |
38 | /**
39 | * Initializes a new CellImpl object at the specified location on the map, overwriting any
40 | * existing Cell at that location. Throws an IndexOutOfBoundsException for coordinate parameters
41 | * that are not on the map
42 | *
43 | * @param x the x-coordinate of the cell
44 | * @param y the y-coordinate of the cell
45 | */
46 | void initCell(int x, int y);
47 |
48 | /**
49 | * Getter method for the total number of items that need to be collected in order for the player
50 | * to win. This field is immutable.
51 | *
52 | * @return the total number of items that need to be collected
53 | */
54 | int getNumItems();
55 | }
56 |
--------------------------------------------------------------------------------
/Adventure-Game/src/main/java/com/comp301/a02adventure/Player.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a02adventure;
2 |
3 | /**
4 | * The Player interface represents a player in the game. The player has a position, an inventory,
5 | * and a name.
6 | */
7 | public interface Player {
8 | /**
9 | * Getter method for the player's current position
10 | *
11 | * @return the player's current position
12 | */
13 | Position getPosition();
14 |
15 | /**
16 | * Getter method for the player's inventory
17 | *
18 | * @return the player's inventory
19 | */
20 | Inventory getInventory();
21 |
22 | /**
23 | * Getter method for the player's name
24 | *
25 | * @return the player's name
26 | */
27 | String getName();
28 |
29 | /**
30 | * Blindly moves the player's position one unit in the indicated direction, without checking
31 | * whether the new location is valid
32 | *
33 | * @param direction the direction in which to move the player
34 | */
35 | void move(Direction direction);
36 | }
37 |
--------------------------------------------------------------------------------
/Adventure-Game/src/main/java/com/comp301/a02adventure/PlayerImpl.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a02adventure;
2 |
3 | /** The PlayerImpl class implements the Player interface and represents a player in the game. */
4 | public class PlayerImpl implements Player {
5 |
6 | // Field to store the player's name
7 | private String name;
8 | // Field to store the player's inventory
9 | private Inventory inventory;
10 | // Field to store the player's position
11 | private Position position;
12 |
13 | /**
14 | * Constructs a new Player object with the specified name and starting position.
15 | *
16 | * @param name the name of the player
17 | * @param startX the x-coordinate of the player's starting position
18 | * @param startY the y-coordinate of the player's starting position
19 | */
20 | public PlayerImpl(String name, int startX, int startY) {
21 | if (name == null) {
22 | throw new IllegalArgumentException("Name string cannot be null");
23 | }
24 |
25 | // Initialize the player's name, inventory, and position
26 | this.name = name;
27 | this.inventory = new InventoryImpl();
28 | this.position = new PositionImpl(startX, startY);
29 | }
30 |
31 | /**
32 | * A method that returns the name of the player.
33 | *
34 | * @return the name of the player
35 | */
36 | @Override
37 | public String getName() {
38 | return this.name;
39 | }
40 |
41 | /**
42 | * A method that returns the player's inventory.
43 | *
44 | * @return the player's inventory
45 | */
46 | @Override
47 | public Inventory getInventory() {
48 | return this.inventory;
49 | }
50 |
51 | /**
52 | * A method that returns the player's current position.
53 | *
54 | * @return the player's current position
55 | */
56 | @Override
57 | public Position getPosition() {
58 | return this.position;
59 | }
60 |
61 | /**
62 | * A method that moves the player in the specified direction.
63 | *
64 | * @param direction the direction in which to move the player
65 | */
66 | @Override
67 | public void move(Direction direction) {
68 | if (direction == null) {
69 | throw new IllegalArgumentException("Direction cannot be null");
70 | }
71 |
72 | // Get the new position by moving in the given direction
73 | Position newPosition = this.position.getNeighbor(direction);
74 |
75 | // Move the player to the new position
76 | this.position = newPosition;
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/Adventure-Game/src/main/java/com/comp301/a02adventure/Position.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a02adventure;
2 |
3 | /**
4 | * The Position interface represents a position on a 2D grid. The position is defined by its x and y
5 | * coordinates. The Position interface provides methods to get the x and y coordinates of the
6 | * position and to get a neighbor position in a specified direction.
7 | */
8 | public interface Position {
9 | /**
10 | * Getter method for the x-coordinate of the position
11 | *
12 | * @return the x-coordinate of the position
13 | */
14 | int getX();
15 |
16 | /**
17 | * Getter method for the y-coordinate of the position
18 | *
19 | * @return the y-coordinate of the position
20 | */
21 | int getY();
22 |
23 | /**
24 | * Constructs and returns a new Position object located one unit in the indicted direction from
25 | * the "this" object
26 | *
27 | * @param direction the direction in which to find the neighbor
28 | * @return a new Position object located one unit in the indicted direction from the "this" object
29 | */
30 | Position getNeighbor(Direction direction);
31 | }
32 |
--------------------------------------------------------------------------------
/Adventure-Game/src/test/java/com/comp301/a02adventure/ItemImplTest.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a02adventure;
2 |
3 | import org.junit.Test;
4 | import static org.junit.Assert.*;
5 |
6 | /**
7 | * This class contains a set of test cases that can be used to test the implementation of the Item
8 | * interface - the ItemImpl class.
9 | */
10 | public class ItemImplTest {
11 |
12 | /**
13 | * Default constructor for the ItemImplTest class.
14 | * This constructor is intentionally left empty since no specific initialization is needed for the tests.
15 | */
16 | public ItemImplTest() {
17 | // No initialization required for this test class.
18 | }
19 |
20 | /** This test case tests the constructor and getName method of the Item interface. */
21 | @Test
22 | public void testItemConstructorAndGetName() {
23 | Item item = new ItemImpl("Sword");
24 | assertEquals("Sword", item.getName());
25 | }
26 |
27 | /** This test case tests the constructor of the Item interface with a null name. */
28 | @Test(expected = IllegalArgumentException.class)
29 | public void testItemConstructorNullName() {
30 | new ItemImpl(null);
31 | }
32 |
33 | /** This test case tests the equals method of the Item interface. */
34 | @Test
35 | public void testItemEquals() {
36 | Item item1 = new ItemImpl("Shield");
37 | Item item2 = new ItemImpl("Shield");
38 | Item item3 = new ItemImpl("Potion");
39 |
40 | // Case 1: Two items with the same name are the same
41 | assertTrue(item1.equals(item2));
42 | // Case 2: Two items with different names are not the same
43 | assertFalse(item1.equals(item3));
44 | // Case 3: An item is not the same as null or a non-item object
45 | assertFalse(item1.equals(null));
46 | // Case 4: An item is not the same as an object with a different type
47 | assertFalse(item1.equals("Not an item"));
48 | }
49 |
50 | /** This test case tests the toString method of the Item interface. */
51 | @Test
52 | public void testItemToString() {
53 | Item item = new ItemImpl("Bow");
54 | assertEquals("Bow", item.toString());
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/Adventure-Game/src/test/java/com/comp301/a02adventure/PositionImplTest.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a02adventure;
2 |
3 | import org.junit.Test;
4 | import static org.junit.Assert.*;
5 |
6 | /**
7 | * This class contains a set of test cases that can be used to test the implementation of the
8 | * Position interface - the PositionImpl class.
9 | */
10 | public class PositionImplTest {
11 |
12 | /**
13 | * Default constructor for the PositionImplTest class.
14 | * This constructor is intentionally left empty since no specific initialization is needed for the tests.
15 | */
16 | public PositionImplTest() {
17 | // No initialization required for this test class.
18 | }
19 |
20 | /** This test case tests the constructor and getter methods of the Position interface. */
21 | @Test
22 | public void testPositionConstructorAndGetters() {
23 | Position position = new PositionImpl(2, 3);
24 | assertEquals(2, position.getX());
25 | assertEquals(3, position.getY());
26 | }
27 |
28 | /** This test case tests the equals method of the Position interface. */
29 | @Test
30 | public void testPositionEquals() {
31 | Position position1 = new PositionImpl(1, 2);
32 | Position position2 = new PositionImpl(1, 2);
33 | Position position3 = new PositionImpl(2, 1);
34 |
35 | // Case 1: Two positions with the same x and y coordinates are the same
36 | assertTrue(position1.equals(position2));
37 | // Case 2: Two positions with different x and y coordinates are not the same
38 | assertFalse(position1.equals(position3));
39 | // Case 3: A position is not the same as null or a non-position object
40 | assertFalse(position1.equals(null));
41 | // Case 4: A position is not the same as an object with a different type
42 | assertFalse(position1.equals("Not a position"));
43 | }
44 |
45 | /** This test case tests the toString method of the Position interface. */
46 | @Test
47 | public void testPositionToString() {
48 | Position position = new PositionImpl(4, 5);
49 | assertEquals("(4, 5)", position.toString());
50 | }
51 |
52 | /** This test case tests the getNeighbor method of the Position interface. */
53 | @Test
54 | public void testGetNeighbor() {
55 | Position position = new PositionImpl(3, 3);
56 |
57 | Position northNeighbor = position.getNeighbor(Direction.NORTH);
58 | assertEquals(new PositionImpl(3, 4), northNeighbor);
59 |
60 | Position southNeighbor = position.getNeighbor(Direction.SOUTH);
61 | assertEquals(new PositionImpl(3, 2), southNeighbor);
62 |
63 | Position eastNeighbor = position.getNeighbor(Direction.EAST);
64 | assertEquals(new PositionImpl(4, 3), eastNeighbor);
65 |
66 | Position westNeighbor = position.getNeighbor(Direction.WEST);
67 | assertEquals(new PositionImpl(2, 3), westNeighbor);
68 | }
69 |
70 | /**
71 | * This test case tests the getNeighbor method of the Position interface with an invalid
72 | * direction.
73 | */
74 | @Test(expected = IllegalArgumentException.class)
75 | public void testInvalidDirection() {
76 | Position position = new PositionImpl(0, 0);
77 | position.getNeighbor(null); // Should throw an IllegalArgumentException
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/Adventure-Game/target/classes/com/comp301/a02adventure/Cell.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Adventure-Game/target/classes/com/comp301/a02adventure/Cell.class
--------------------------------------------------------------------------------
/Adventure-Game/target/classes/com/comp301/a02adventure/CellImpl.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Adventure-Game/target/classes/com/comp301/a02adventure/CellImpl.class
--------------------------------------------------------------------------------
/Adventure-Game/target/classes/com/comp301/a02adventure/Direction.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Adventure-Game/target/classes/com/comp301/a02adventure/Direction.class
--------------------------------------------------------------------------------
/Adventure-Game/target/classes/com/comp301/a02adventure/Game.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Adventure-Game/target/classes/com/comp301/a02adventure/Game.class
--------------------------------------------------------------------------------
/Adventure-Game/target/classes/com/comp301/a02adventure/GameImpl.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Adventure-Game/target/classes/com/comp301/a02adventure/GameImpl.class
--------------------------------------------------------------------------------
/Adventure-Game/target/classes/com/comp301/a02adventure/Inventory.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Adventure-Game/target/classes/com/comp301/a02adventure/Inventory.class
--------------------------------------------------------------------------------
/Adventure-Game/target/classes/com/comp301/a02adventure/InventoryImpl.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Adventure-Game/target/classes/com/comp301/a02adventure/InventoryImpl.class
--------------------------------------------------------------------------------
/Adventure-Game/target/classes/com/comp301/a02adventure/Item.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Adventure-Game/target/classes/com/comp301/a02adventure/Item.class
--------------------------------------------------------------------------------
/Adventure-Game/target/classes/com/comp301/a02adventure/ItemImpl.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Adventure-Game/target/classes/com/comp301/a02adventure/ItemImpl.class
--------------------------------------------------------------------------------
/Adventure-Game/target/classes/com/comp301/a02adventure/Main.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Adventure-Game/target/classes/com/comp301/a02adventure/Main.class
--------------------------------------------------------------------------------
/Adventure-Game/target/classes/com/comp301/a02adventure/Map.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Adventure-Game/target/classes/com/comp301/a02adventure/Map.class
--------------------------------------------------------------------------------
/Adventure-Game/target/classes/com/comp301/a02adventure/MapImpl.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Adventure-Game/target/classes/com/comp301/a02adventure/MapImpl.class
--------------------------------------------------------------------------------
/Adventure-Game/target/classes/com/comp301/a02adventure/MapUNC.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Adventure-Game/target/classes/com/comp301/a02adventure/MapUNC.class
--------------------------------------------------------------------------------
/Adventure-Game/target/classes/com/comp301/a02adventure/Player.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Adventure-Game/target/classes/com/comp301/a02adventure/Player.class
--------------------------------------------------------------------------------
/Adventure-Game/target/classes/com/comp301/a02adventure/PlayerImpl.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Adventure-Game/target/classes/com/comp301/a02adventure/PlayerImpl.class
--------------------------------------------------------------------------------
/Adventure-Game/target/classes/com/comp301/a02adventure/Position.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Adventure-Game/target/classes/com/comp301/a02adventure/Position.class
--------------------------------------------------------------------------------
/Adventure-Game/target/classes/com/comp301/a02adventure/PositionImpl$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Adventure-Game/target/classes/com/comp301/a02adventure/PositionImpl$1.class
--------------------------------------------------------------------------------
/Adventure-Game/target/classes/com/comp301/a02adventure/PositionImpl.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Adventure-Game/target/classes/com/comp301/a02adventure/PositionImpl.class
--------------------------------------------------------------------------------
/Adventure-Game/target/test-classes/com/comp301/a02adventure/CellImplTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Adventure-Game/target/test-classes/com/comp301/a02adventure/CellImplTest.class
--------------------------------------------------------------------------------
/Adventure-Game/target/test-classes/com/comp301/a02adventure/GameImplTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Adventure-Game/target/test-classes/com/comp301/a02adventure/GameImplTest.class
--------------------------------------------------------------------------------
/Adventure-Game/target/test-classes/com/comp301/a02adventure/InventoryImplTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Adventure-Game/target/test-classes/com/comp301/a02adventure/InventoryImplTest.class
--------------------------------------------------------------------------------
/Adventure-Game/target/test-classes/com/comp301/a02adventure/ItemImplTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Adventure-Game/target/test-classes/com/comp301/a02adventure/ItemImplTest.class
--------------------------------------------------------------------------------
/Adventure-Game/target/test-classes/com/comp301/a02adventure/MapImplTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Adventure-Game/target/test-classes/com/comp301/a02adventure/MapImplTest.class
--------------------------------------------------------------------------------
/Adventure-Game/target/test-classes/com/comp301/a02adventure/PlayerImplTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Adventure-Game/target/test-classes/com/comp301/a02adventure/PlayerImplTest.class
--------------------------------------------------------------------------------
/Adventure-Game/target/test-classes/com/comp301/a02adventure/PositionImplTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Adventure-Game/target/test-classes/com/comp301/a02adventure/PositionImplTest.class
--------------------------------------------------------------------------------
/Algorithms-Notes/algorithms.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Algorithms-Notes/algorithms.pdf
--------------------------------------------------------------------------------
/Decorators/src/main/java/com/comp301/a06image/Image.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a06image;
2 |
3 | import java.awt.Color;
4 |
5 | /**
6 | * The Image interface represents an image with a width, height, and color. The color of a pixel can
7 | * be retrieved by calling the getPixelColor method.
8 | */
9 | public interface Image {
10 | /**
11 | * Getter method to retrieve the color of a particular pixel in the image. Parameters x and y must
12 | * be non-negative, and must be less than the width and height of the image, respectively.
13 | *
14 | * @param x The x coordinate of the pixel
15 | * @param y The y coordinate of the pixel
16 | * @return The color of the pixel located at position (x, y)
17 | */
18 | Color getPixelColor(int x, int y);
19 |
20 | /**
21 | * Getter method for the number of pixels in the horizontal direction of the image
22 | *
23 | * @return The width of the image
24 | */
25 | int getWidth();
26 |
27 | /**
28 | * Getter method for the number of pixels in the vertical direction of the image
29 | *
30 | * @return The height of the image
31 | */
32 | int getHeight();
33 |
34 | /**
35 | * Getter method for the number of layers in the image
36 | *
37 | * @return The number of layers in the image
38 | */
39 | int getNumLayers();
40 | }
41 |
--------------------------------------------------------------------------------
/Decorators/src/main/java/com/comp301/a06image/ImageDisplay.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a06image;
2 |
3 | import java.io.IOException;
4 | import javafx.application.Application;
5 | import javafx.scene.Group;
6 | import javafx.scene.Scene;
7 | import javafx.scene.image.ImageView;
8 | import javafx.scene.image.PixelWriter;
9 | import javafx.scene.image.WritableImage;
10 | import javafx.stage.Stage;
11 |
12 | /**
13 | * This class contains code to display the decorated image on the screen when the Main class is
14 | * executed. You don't need to make any changes to this class for the assignment.
15 | */
16 | public class ImageDisplay extends Application {
17 |
18 | /** Default constructor for the ImageDisplay class. */
19 | public ImageDisplay() {
20 | // Default constructor
21 | }
22 |
23 | /**
24 | * The start method is called when the application is launched. It creates an image view and
25 | * displays the image on the screen.
26 | *
27 | * @param stage The primary stage for the application
28 | * @throws IOException If the image file cannot be loaded
29 | */
30 | @Override
31 | public void start(Stage stage) throws IOException {
32 | // Create the image to display
33 | WritableImage fxImage = render(Main.makeImage());
34 |
35 | // Set the image view
36 | ImageView imageView = new ImageView(fxImage);
37 |
38 | // Set the position of the image
39 | imageView.setX(0);
40 | imageView.setY(0);
41 |
42 | // Set the fit height and width of the image view
43 | imageView.setFitHeight(fxImage.getHeight());
44 | imageView.setFitWidth(fxImage.getWidth());
45 |
46 | // Set the preserve ratio of the image view
47 | imageView.setPreserveRatio(true);
48 |
49 | // Create a Group object
50 | Group root = new Group(imageView);
51 |
52 | // Create a scene object
53 | Scene scene = new Scene(root, fxImage.getWidth(), fxImage.getHeight());
54 |
55 | // Set title to the Stage
56 | stage.setTitle("Image display");
57 |
58 | // Add scene to the stage
59 | stage.setScene(scene);
60 |
61 | // Display the contents of the stage
62 | stage.show();
63 | }
64 |
65 | /**
66 | * The render method converts an Image object to a WritableImage object that can be displayed on
67 | * the screen.
68 | *
69 | * @param img The Image object to be converted
70 | * @return The WritableImage object that can be displayed on the screen
71 | */
72 | private WritableImage render(Image img) {
73 | WritableImage wi = new WritableImage(img.getWidth(), img.getHeight());
74 | PixelWriter pw = wi.getPixelWriter();
75 | for (int y = 0; y < img.getHeight(); y++) {
76 | for (int x = 0; x < img.getWidth(); x++) {
77 | pw.setArgb(x, y, (0xff << 24) | img.getPixelColor(x, y).getRGB());
78 | }
79 | }
80 | return wi;
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/Decorators/src/main/java/com/comp301/a06image/Main.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a06image;
2 |
3 | import java.awt.Color;
4 | import java.io.IOException;
5 | import javafx.application.Application;
6 |
7 | /**
8 | * This class is the entry point for the image decorator application. You can use this class to test
9 | * your image decorator implementations. The makeImage() method below creates an image object and
10 | * applies a series of decorators to it. You can modify this method to test different decorators.
11 | * When you run the main() method below, the image you create will be displayed on the screen.
12 | */
13 | public class Main {
14 | /**
15 | * Creates and returns an image object for testing. The image that this method produces will be
16 | * automatically displayed on the screen when main() is run below. Use this method to test
17 | * different decorators.
18 | *
19 | * @return The image object to be displayed
20 | * @throws IOException If the image file cannot be loaded
21 | */
22 | public static Image makeImage() throws IOException {
23 | // Load the base image
24 | Image baseImage = new PictureImage("img/headshot.jpg");
25 |
26 | // Apply a red border
27 | Image redBorderImage = new BorderDecorator(baseImage, 5, new Color(255, 0, 0));
28 |
29 | // Apply a blue border
30 | Image blueBorderImage = new BorderDecorator(redBorderImage, 50, new Color(0, 0, 255));
31 |
32 | // Apply a yellow circle
33 | Image yellowCircleImage =
34 | new CircleDecorator(blueBorderImage, 50, 50, 40, new Color(255, 255, 0));
35 |
36 | // Apply an orange square
37 | Image orangeSquareImage =
38 | new SquareDecorator(yellowCircleImage, 100, 100, 40, new Color(200, 80, 10));
39 |
40 | // Finally, apply a ZoomDecorator with a multiplier of 2
41 | Image finalImage = new ZoomDecorator(orangeSquareImage, 2);
42 |
43 | // Return the final image
44 | return finalImage;
45 | }
46 |
47 | /**
48 | * Use this method for testing your code. When main() runs, the image you created and decorated in
49 | * the makeImage() method above will be generated and displayed on the screen. You don't need to
50 | * make any changes to this main() method.
51 | *
52 | * @param args Command-line arguments
53 | */
54 | public static void main(String[] args) {
55 | Application.launch(ImageDisplay.class, args);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/Decorators/src/main/java/com/comp301/a06image/PictureImage.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a06image;
2 |
3 | import javax.imageio.ImageIO;
4 | import java.awt.Color;
5 | import java.awt.image.BufferedImage;
6 | import java.io.File;
7 | import java.io.IOException;
8 |
9 | /**
10 | * The PictureImage class is an Image implementation that represents an image loaded from a file on
11 | * disk. The image is represented as a BufferedImage object, and the color of a pixel can be
12 | * retrieved by calling the getPixelColor method.
13 | */
14 | public class PictureImage implements Image {
15 | // Instance variable
16 | private BufferedImage image;
17 |
18 | /**
19 | * Constructor for the PictureImage class. Initializes the PictureImage with the image loaded from
20 | * the file at the specified pathname.
21 | *
22 | * @param pathname The pathname of the image file
23 | * @throws IOException If the image file cannot be loaded
24 | */
25 | public PictureImage(String pathname) throws IOException {
26 | // Check for invalid arguments (null pathname)
27 | if (pathname == null) {
28 | throw new IllegalArgumentException("Pathname cannot be null.");
29 | }
30 |
31 | // Load the image from the file at the specified pathname
32 | // Initialize the PictureImage
33 | File file = new File(pathname);
34 | this.image = ImageIO.read(file);
35 | }
36 |
37 | /**
38 | * Returns the color of the pixel at the specified coordinates.
39 | *
40 | * @param x The x coordinate of the pixel
41 | * @param y The y coordinate of the pixel
42 | * @return The color of the pixel at the specified coordinates
43 | */
44 | @Override
45 | public Color getPixelColor(int x, int y) {
46 | // Check for invalid arguments (negative x or y, or out-of-bounds x or y)
47 | if (x < 0) {
48 | throw new IllegalArgumentException("Pixel x-coordinate must be non-negative.");
49 | }
50 |
51 | if (y < 0) {
52 | throw new IllegalArgumentException("Pixel y-coordinate must be non-negative.");
53 | }
54 |
55 | if (x >= this.getWidth()) {
56 | throw new IllegalArgumentException("Pixel x-coordinate must be less than the image width.");
57 | }
58 |
59 | if (y >= this.getHeight()) {
60 | throw new IllegalArgumentException("Pixel y-coordinate must be less than the image height.");
61 | }
62 |
63 | // Retrieve the color of the pixel at position (x, y)
64 | int rgb = this.image.getRGB(x, y);
65 | return new Color(rgb, true);
66 | }
67 |
68 | /**
69 | * Returns the width of the image.
70 | *
71 | * @return The width of the image
72 | */
73 | @Override
74 | public int getWidth() {
75 | return this.image.getWidth();
76 | }
77 |
78 | /**
79 | * Returns the height of the image.
80 | *
81 | * @return The height of the image
82 | */
83 | @Override
84 | public int getHeight() {
85 | return this.image.getHeight();
86 | }
87 |
88 | /**
89 | * Returns the number of layers in the image. A PictureImage is a base image that has no layers,
90 | * so the number of layers is 1.
91 | *
92 | * @return The number of layers in the image
93 | */
94 | @Override
95 | public int getNumLayers() {
96 | // A PictureImage is a base image that has no layers, so return 1
97 | return 1;
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/Decorators/src/main/java/com/comp301/a06image/SolidColorImage.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a06image;
2 |
3 | import java.awt.Color;
4 |
5 | /**
6 | * The SolidColorImage class is an Image implementation that represents an image with a solid color.
7 | * The image is defined by a width, a height, and a color. The color of a pixel can be retrieved by
8 | * calling the getPixelColor method.
9 | */
10 | public class SolidColorImage implements Image {
11 | private int width;
12 | private int height;
13 | private Color color;
14 |
15 | /**
16 | * Constructor for the SolidColorImage class. Initializes the SolidColorImage with the specified
17 | * width, height, and color.
18 | *
19 | * @param width The width of the image
20 | * @param height The height of the image
21 | * @param color The color of the image
22 | * @throws IllegalArgumentException If the width or height is negative
23 | */
24 | public SolidColorImage(int width, int height, Color color) {
25 | // Check for invalid arguments (negative width or height)
26 | if (width < 0 || height < 0) {
27 | throw new IllegalArgumentException("Width and height must be positive values.");
28 | }
29 |
30 | // Initialize the SolidColorImage
31 | this.width = width;
32 | this.height = height;
33 | this.color = color;
34 | }
35 |
36 | /**
37 | * Returns the color of the pixel at the specified coordinates.
38 | *
39 | * @param x The x coordinate of the pixel
40 | * @param y The y coordinate of the pixel
41 | * @return The color of the pixel at the specified coordinates
42 | */
43 | @Override
44 | public Color getPixelColor(int x, int y) {
45 | // Check for invalid arguments (negative x or y, or out-of-bounds x or y)
46 | if (x < 0) {
47 | throw new IllegalArgumentException("Pixel x-coordinate must be non-negative.");
48 | }
49 |
50 | if (y < 0) {
51 | throw new IllegalArgumentException("Pixel y-coordinate must be non-negative.");
52 | }
53 |
54 | if (x >= this.width) {
55 | throw new IllegalArgumentException("Pixel x-coordinate must be less than the image width.");
56 | }
57 |
58 | if (y >= this.height) {
59 | throw new IllegalArgumentException("Pixel y-coordinate must be less than the image height.");
60 | }
61 |
62 | // Return the solid color of the image
63 | return this.color;
64 | }
65 |
66 | /**
67 | * Returns the width of the image.
68 | *
69 | * @return The width of the image
70 | */
71 | @Override
72 | public int getWidth() {
73 | return this.width;
74 | }
75 |
76 | /**
77 | * Returns the height of the image.
78 | *
79 | * @return The height of the image
80 | */
81 | @Override
82 | public int getHeight() {
83 | return this.height;
84 | }
85 |
86 | /**
87 | * Returns the number of layers in the image. A SolidColorImage is a base image that has no
88 | * layers, so the number of layers is 1.
89 | *
90 | * @return The number of layers in the image
91 | */
92 | @Override
93 | public int getNumLayers() {
94 | // A SolidColorImage is a base image that has no layers, so return 1
95 | return 1;
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/Decorators/target/classes/com/comp301/a06image/BorderDecorator.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Decorators/target/classes/com/comp301/a06image/BorderDecorator.class
--------------------------------------------------------------------------------
/Decorators/target/classes/com/comp301/a06image/CircleDecorator.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Decorators/target/classes/com/comp301/a06image/CircleDecorator.class
--------------------------------------------------------------------------------
/Decorators/target/classes/com/comp301/a06image/Image.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Decorators/target/classes/com/comp301/a06image/Image.class
--------------------------------------------------------------------------------
/Decorators/target/classes/com/comp301/a06image/ImageDisplay.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Decorators/target/classes/com/comp301/a06image/ImageDisplay.class
--------------------------------------------------------------------------------
/Decorators/target/classes/com/comp301/a06image/Main.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Decorators/target/classes/com/comp301/a06image/Main.class
--------------------------------------------------------------------------------
/Decorators/target/classes/com/comp301/a06image/PictureImage.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Decorators/target/classes/com/comp301/a06image/PictureImage.class
--------------------------------------------------------------------------------
/Decorators/target/classes/com/comp301/a06image/SolidColorImage.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Decorators/target/classes/com/comp301/a06image/SolidColorImage.class
--------------------------------------------------------------------------------
/Decorators/target/classes/com/comp301/a06image/SquareDecorator.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Decorators/target/classes/com/comp301/a06image/SquareDecorator.class
--------------------------------------------------------------------------------
/Decorators/target/classes/com/comp301/a06image/ZoomDecorator.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Decorators/target/classes/com/comp301/a06image/ZoomDecorator.class
--------------------------------------------------------------------------------
/Decorators/target/test-classes/com/comp301/a06image/ImageDecoratorsTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Decorators/target/test-classes/com/comp301/a06image/ImageDecoratorsTest.class
--------------------------------------------------------------------------------
/Design-Patterns-Info/Abstraction, Composition & Aggregation.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Design-Patterns-Info/Abstraction, Composition & Aggregation.pdf
--------------------------------------------------------------------------------
/Design-Patterns-Info/Asynchronous Programming.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Design-Patterns-Info/Asynchronous Programming.pdf
--------------------------------------------------------------------------------
/Design-Patterns-Info/Decorators.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Design-Patterns-Info/Decorators.pdf
--------------------------------------------------------------------------------
/Design-Patterns-Info/Encapsulation & OOP.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Design-Patterns-Info/Encapsulation & OOP.pdf
--------------------------------------------------------------------------------
/Design-Patterns-Info/Exceptions & Error Handling.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Design-Patterns-Info/Exceptions & Error Handling.pdf
--------------------------------------------------------------------------------
/Design-Patterns-Info/Iterators & Iterable.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Design-Patterns-Info/Iterators & Iterable.pdf
--------------------------------------------------------------------------------
/Design-Patterns-Info/JavaFX.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Design-Patterns-Info/JavaFX.pdf
--------------------------------------------------------------------------------
/Design-Patterns-Info/Model-View-Controller.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Design-Patterns-Info/Model-View-Controller.pdf
--------------------------------------------------------------------------------
/Design-Patterns-Info/Observers.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Design-Patterns-Info/Observers.pdf
--------------------------------------------------------------------------------
/Design-Patterns-Info/Singleton, Multiton, Factory & Strategy.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Design-Patterns-Info/Singleton, Multiton, Factory & Strategy.pdf
--------------------------------------------------------------------------------
/Design-Patterns-Info/Unit Testing & JUnit.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Design-Patterns-Info/Unit Testing & JUnit.pdf
--------------------------------------------------------------------------------
/Design-Patterns-Info/Web Development (Bonus).pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Design-Patterns-Info/Web Development (Bonus).pdf
--------------------------------------------------------------------------------
/Design-Patterns.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Exceptions/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 | 4.0.0
6 |
7 | com.comp301.a03exceptions
8 | a03-exceptions
9 | 1.0-SNAPSHOT
10 |
11 | a03-exceptions
12 |
13 | http://www.example.com
14 |
15 |
16 | UTF-8
17 | 1.7
18 | 1.7
19 |
20 |
21 |
22 |
23 | junit
24 | junit
25 | 4.11
26 | test
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | maven-clean-plugin
36 | 3.1.0
37 |
38 |
39 |
40 | maven-resources-plugin
41 | 3.0.2
42 |
43 |
44 | maven-compiler-plugin
45 | 3.8.0
46 |
47 |
48 | maven-surefire-plugin
49 | 2.22.1
50 |
51 |
52 | maven-jar-plugin
53 | 3.0.2
54 |
55 |
56 | maven-install-plugin
57 | 2.5.2
58 |
59 |
60 | maven-deploy-plugin
61 | 2.8.2
62 |
63 |
64 |
65 | maven-site-plugin
66 | 3.7.1
67 |
68 |
69 | maven-project-info-reports-plugin
70 | 3.0.0
71 |
72 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/Exceptions/src/main/java/com/comp301/a03exceptions/NegativeValueException.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a03exceptions;
2 |
3 | /** This exception indicates that a negative value was encountered. */
4 | public class NegativeValueException extends RuntimeException {
5 |
6 | /** Constructor with a default message */
7 | public NegativeValueException() {
8 | super("A negative value was encountered");
9 | }
10 |
11 | /**
12 | * Constructor with a custom message
13 | *
14 | * @param message The message to display
15 | */
16 | public NegativeValueException(String message) {
17 | super(message);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Exceptions/src/main/java/com/comp301/a03exceptions/Printer.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a03exceptions;
2 |
3 | /**
4 | * You do not need to implement this interface for the assignment. This interface is used by the
5 | * autograder to interact with your code. Some of the problems in this assignment will ask you to
6 | * "print" information at specific parts in your code. Use the print() method below to accomplish
7 | * this.
8 | */
9 | public interface Printer {
10 |
11 | /**
12 | * Call this method to "print" a String. Unlike System.out.println, this method doesn't actually
13 | * print the string to the console. Instead, it just sends the string value straight to the
14 | * autograder.
15 | */
16 | void print(String value);
17 | }
18 |
--------------------------------------------------------------------------------
/Exceptions/src/test/java/com/comp301/a03exceptions/JediTest.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a03exceptions;
2 |
3 | import static org.junit.Assert.assertEquals;
4 | import static org.junit.Assert.fail;
5 |
6 | import org.junit.Test;
7 |
8 | /** Unit test for the Jedi class. */
9 | public class JediTest {
10 |
11 | /** Test for section7 method */
12 | @Test
13 | public void testSection7() {
14 | // Test case when n is negative, expecting a NegativeValueException
15 | try {
16 | Jedi.section7(-5);
17 | fail("Expected NegativeValueException was not thrown");
18 | } catch (NegativeValueException e) {
19 | // Expected outcome, test passes
20 | }
21 |
22 | // Test case when n is non-negative, expecting no exception
23 | try {
24 | Jedi.section7(5);
25 | // If we reach here, it means no exception was thrown, which is expected
26 | } catch (NegativeValueException e) {
27 | fail("NegativeValueException should not be thrown for non-negative n");
28 | }
29 | }
30 |
31 | /** Test for section8 method */
32 | @Test
33 | public void testSection8() {
34 | // Test case when n is negative, should return "A NegativeValueException occurred"
35 | assertEquals("A NegativeValueException occurred", Jedi.section8(-1));
36 |
37 | // Test case when n = 3 (which should throw IllegalArgumentException in section1),
38 | // resulting in "A RuntimeException occurred"
39 | assertEquals("A RuntimeException occurred", Jedi.section8(3));
40 |
41 | // Test case with n = 5 (which should throw NullPointerException in section1),
42 | // resulting in "A RuntimeException occurred"
43 | assertEquals("A RuntimeException occurred", Jedi.section8(5));
44 |
45 | // Test case with n = 6 (no exception should occur), expecting "No exception occurred"
46 | assertEquals("No exception occurred", Jedi.section8(6));
47 | }
48 |
49 | /** Test for section9 method */
50 | @Test
51 | public void testSection9() {
52 | // Test case where n = -1, should catch NegativeValueException and section1(-n) should throw a
53 | // RuntimeException, hence expecting "Two exceptions were caught"
54 | assertEquals("Two exceptions were caught", Jedi.section9(-1));
55 |
56 | // Test case where n = -7, should catch NegativeValueException but section1(7) will not throw,
57 | // hence expecting "One exception was caught"
58 | assertEquals("One exception was caught", Jedi.section9(-7));
59 |
60 | // Test case with n = 5 (section7 does not throw, but section1 throws NullPointerException),
61 | // expecting "No exceptions were caught"
62 | assertEquals("No exceptions were caught", Jedi.section9(5));
63 |
64 | // Test case where n = -5, expecting "Two exceptions were caught" because
65 | // section1(-n) should throw UnsupportedOperationException
66 | assertEquals("Two exceptions were caught", Jedi.section9(-5));
67 |
68 | // Test case with n = 3 (section7 does not throw, but section1 throws IllegalArgumentException),
69 | // should expect "No exceptions were caught"
70 | assertEquals("No exceptions were caught", Jedi.section9(3));
71 |
72 | // Test case with n = 6 (no exception is expected in both section7 and section1),
73 | // so it should return "No exceptions were caught"
74 | assertEquals("No exceptions were caught", Jedi.section9(6));
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/Exceptions/target/classes/com/comp301/a03exceptions/Adept.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Exceptions/target/classes/com/comp301/a03exceptions/Adept.class
--------------------------------------------------------------------------------
/Exceptions/target/classes/com/comp301/a03exceptions/Jedi.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Exceptions/target/classes/com/comp301/a03exceptions/Jedi.class
--------------------------------------------------------------------------------
/Exceptions/target/classes/com/comp301/a03exceptions/NegativeValueException.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Exceptions/target/classes/com/comp301/a03exceptions/NegativeValueException.class
--------------------------------------------------------------------------------
/Exceptions/target/classes/com/comp301/a03exceptions/Novice.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Exceptions/target/classes/com/comp301/a03exceptions/Novice.class
--------------------------------------------------------------------------------
/Exceptions/target/classes/com/comp301/a03exceptions/Printer.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Exceptions/target/classes/com/comp301/a03exceptions/Printer.class
--------------------------------------------------------------------------------
/Exceptions/target/test-classes/com/comp301/a03exceptions/AdeptTest$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Exceptions/target/test-classes/com/comp301/a03exceptions/AdeptTest$1.class
--------------------------------------------------------------------------------
/Exceptions/target/test-classes/com/comp301/a03exceptions/AdeptTest$TestPrinter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Exceptions/target/test-classes/com/comp301/a03exceptions/AdeptTest$TestPrinter.class
--------------------------------------------------------------------------------
/Exceptions/target/test-classes/com/comp301/a03exceptions/AdeptTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Exceptions/target/test-classes/com/comp301/a03exceptions/AdeptTest.class
--------------------------------------------------------------------------------
/Exceptions/target/test-classes/com/comp301/a03exceptions/JediTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Exceptions/target/test-classes/com/comp301/a03exceptions/JediTest.class
--------------------------------------------------------------------------------
/Exceptions/target/test-classes/com/comp301/a03exceptions/NoviceTest$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Exceptions/target/test-classes/com/comp301/a03exceptions/NoviceTest$1.class
--------------------------------------------------------------------------------
/Exceptions/target/test-classes/com/comp301/a03exceptions/NoviceTest$TestPrinter.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Exceptions/target/test-classes/com/comp301/a03exceptions/NoviceTest$TestPrinter.class
--------------------------------------------------------------------------------
/Exceptions/target/test-classes/com/comp301/a03exceptions/NoviceTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Exceptions/target/test-classes/com/comp301/a03exceptions/NoviceTest.class
--------------------------------------------------------------------------------
/Inheritance/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 | 4.0.0
6 |
7 | com.comp301.a01sushi
8 | a01-sushi
9 | 1.0-SNAPSHOT
10 |
11 | a01-sushi
12 |
13 | http://www.example.com
14 |
15 |
16 | UTF-8
17 | 1.7
18 | 1.7
19 |
20 |
21 |
22 |
23 | junit
24 | junit
25 | 4.11
26 | test
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | maven-clean-plugin
36 | 3.1.0
37 |
38 |
39 |
40 | maven-resources-plugin
41 | 3.0.2
42 |
43 |
44 | maven-compiler-plugin
45 | 3.8.0
46 |
47 |
48 | maven-surefire-plugin
49 | 2.22.1
50 |
51 |
52 | maven-jar-plugin
53 | 3.0.2
54 |
55 |
56 | maven-install-plugin
57 | 2.5.2
58 |
59 |
60 | maven-deploy-plugin
61 | 2.8.2
62 |
63 |
64 |
65 | maven-site-plugin
66 | 3.7.1
67 |
68 |
69 | maven-project-info-reports-plugin
70 | 3.0.0
71 |
72 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/Inheritance/src/main/java/com/comp301/a01sushi/Avocado.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a01sushi;
2 |
3 | /**
4 | * This class represents an Avocado ingredient. Avocado is a type of IngredientGeneral with a name,
5 | * cost, calories, and whether it is vegetarian, rice, or shellfish.
6 | */
7 | public class Avocado extends IngredientGeneral {
8 |
9 | /**
10 | * This constructor initializes the Avocado ingredient with its name, cost, calories, and whether
11 | * it is vegetarian, rice, or shellfish.
12 | */
13 | public Avocado() {
14 | super("avocado", 0.24, 42, true, false, false);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Inheritance/src/main/java/com/comp301/a01sushi/AvocadoPortion.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a01sushi;
2 |
3 | /**
4 | * This class represents an Avocado ingredient portion. Avocado is a type of
5 | * IngredientPortionGeneral with a name, cost, calories, and whether it is vegetarian, rice, or
6 | * shellfish, etc.
7 | */
8 | public class AvocadoPortion extends IngredientPortionGeneral {
9 |
10 | /**
11 | * This constructor initializes the Avocado ingredient portion with its amount.
12 | *
13 | * @param amount The amount of Avocado in ounces
14 | */
15 | public AvocadoPortion(double amount) {
16 | super(new Avocado(), amount);
17 | }
18 |
19 | /**
20 | * This method combines two Avocado ingredient portions into one.
21 | *
22 | * @param other The other Avocado ingredient portion to be combined
23 | * @return The combined Avocado ingredient portion
24 | */
25 | @Override
26 | public IngredientPortion combine(IngredientPortion other) {
27 | if (other == null) {
28 | return this;
29 | }
30 |
31 | boolean isSameIngredient = this.getIngredient().equals(other.getIngredient());
32 |
33 | if (!isSameIngredient) {
34 | throw new IllegalArgumentException("Cannot combine ingredients of different types");
35 | }
36 |
37 | double newAmount = this.getAmount() + other.getAmount();
38 |
39 | return new AvocadoPortion(newAmount);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Inheritance/src/main/java/com/comp301/a01sushi/Crab.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a01sushi;
2 |
3 | /**
4 | * This class represents a Crab ingredient. Crab is a type of IngredientGeneral with a name, cost,
5 | * calories, and whether it is vegetarian, rice, or shellfish.
6 | */
7 | public class Crab extends IngredientGeneral {
8 |
9 | /**
10 | * This constructor initializes the Crab ingredient with its name, cost, calories, and whether it
11 | * is vegetarian, rice, or shellfish.
12 | */
13 | public Crab() {
14 | super("crab", 0.72, 37, false, false, true);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Inheritance/src/main/java/com/comp301/a01sushi/CrabPortion.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a01sushi;
2 |
3 | /**
4 | * This class represents a Crab ingredient portion. Crab is a type of IngredientPortionGeneral with
5 | * a name, cost, calories, and whether it is vegetarian, rice, or shellfish, etc.
6 | */
7 | public class CrabPortion extends IngredientPortionGeneral {
8 |
9 | /**
10 | * This constructor initializes the Crab ingredient portion with its amount.
11 | *
12 | * @param amount The amount of Crab in ounces
13 | */
14 | public CrabPortion(double amount) {
15 | super(new Crab(), amount);
16 | }
17 |
18 | /**
19 | * This method combines two Crab ingredient portions into one.
20 | *
21 | * @param other The other Crab ingredient portion to be combined
22 | * @return The combined Crab ingredient portion
23 | */
24 | @Override
25 | public IngredientPortion combine(IngredientPortion other) {
26 | if (other == null) {
27 | return this;
28 | }
29 |
30 | boolean isSameIngredient = this.getIngredient().equals(other.getIngredient());
31 |
32 | if (!isSameIngredient) {
33 | throw new IllegalArgumentException("Cannot combine ingredients of different types");
34 | }
35 |
36 | double newAmount = this.getAmount() + other.getAmount();
37 |
38 | return new CrabPortion(newAmount);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Inheritance/src/main/java/com/comp301/a01sushi/Eel.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a01sushi;
2 |
3 | /**
4 | * This class represents an Eel ingredient. Eel is a type of IngredientGeneral with a name, cost,
5 | * calories, and whether it is vegetarian, rice, or shellfish.
6 | */
7 | public class Eel extends IngredientGeneral {
8 |
9 | /**
10 | * This constructor initializes the Eel ingredient with its name, cost, calories, and whether it
11 | * is vegetarian, rice, or shellfish.
12 | */
13 | public Eel() {
14 | super("eel", 2.15, 82, false, false, false);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Inheritance/src/main/java/com/comp301/a01sushi/EelPortion.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a01sushi;
2 |
3 | /**
4 | * This class represents an Eel ingredient portion. Eel is a type of IngredientPortionGeneral with a
5 | * name, cost, calories, and whether it is vegetarian, rice, or shellfish, etc.
6 | */
7 | public class EelPortion extends IngredientPortionGeneral {
8 |
9 | /**
10 | * This constructor initializes the Eel ingredient portion with its amount.
11 | *
12 | * @param amount The amount of Eel in ounces
13 | */
14 | public EelPortion(double amount) {
15 | super(new Eel(), amount);
16 | }
17 |
18 | /**
19 | * This method combines two Eel ingredient portions into one.
20 | *
21 | * @param other The other Eel ingredient portion to be combined
22 | * @return The combined Eel ingredient portion
23 | */
24 | @Override
25 | public IngredientPortion combine(IngredientPortion other) {
26 | if (other == null) {
27 | return this;
28 | }
29 |
30 | boolean isSameIngredient = this.getIngredient().equals(other.getIngredient());
31 |
32 | if (!isSameIngredient) {
33 | throw new IllegalArgumentException("Cannot combine ingredients of different types");
34 | }
35 |
36 | double newAmount = this.getAmount() + other.getAmount();
37 |
38 | return new EelPortion(newAmount);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Inheritance/src/main/java/com/comp301/a01sushi/Ingredient.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a01sushi;
2 |
3 | /**
4 | * This interface represents an ingredient in a sushi restaurant. Ingredients have a name, cost,
5 | * calories, and whether they are vegetarian, rice, or shellfish.
6 | */
7 | public interface Ingredient {
8 | /**
9 | * Getter method for the name of the ingredient
10 | *
11 | * @return the name of the ingredient as a String
12 | */
13 | String getName();
14 |
15 | /**
16 | * Getter method for the number of calories in one dollar's worth of the ingredient
17 | *
18 | * @return the number of calories per dollar's worth of the ingredient
19 | */
20 | double getCaloriesPerDollar();
21 |
22 | /**
23 | * Getter method for the number of calories in one ounce of the ingredient
24 | *
25 | * @return the number of calories per ounce of the ingredient
26 | */
27 | int getCaloriesPerOunce();
28 |
29 | /**
30 | * Getter method for the price of one ounce of the ingredient
31 | *
32 | * @return the price per ounce of the ingredient, in dollars
33 | */
34 | double getPricePerOunce();
35 |
36 | /**
37 | * Getter method which returns true if the ingredient is vegetarian
38 | *
39 | * @return true if the ingredient is vegetarian; false otherwise
40 | */
41 | boolean getIsVegetarian();
42 |
43 | /**
44 | * Getter method which returns true if the ingredient is rice
45 | *
46 | * @return true if the ingredient is rice; false otherwise
47 | */
48 | boolean getIsRice();
49 |
50 | /**
51 | * Getter method which returns true if the ingredient is shellfish
52 | *
53 | * @return true if the ingredient is shellfish; false otherwise
54 | */
55 | boolean getIsShellfish();
56 |
57 | /**
58 | * Determines whether the ingredient is the same as another ingredient
59 | *
60 | * @return If other is null, returns false; otherwise, compares the name, calories, price (within
61 | * 1 cent), vegetarian, rice, and shellfish properties of the two ingredients. If all of them
62 | * are the same, returns true. If any are different, returns false.
63 | */
64 | boolean equals(Ingredient other);
65 | }
66 |
--------------------------------------------------------------------------------
/Inheritance/src/main/java/com/comp301/a01sushi/IngredientPortion.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a01sushi;
2 |
3 | /**
4 | * This interface represents an ingredient portion. An ingredient portion has an ingredient, an
5 | * amount (in ounces), and methods to get the name, amount, calories, cost, and whether the
6 | * ingredient is vegetarian, rice, or shellfish.
7 | */
8 | public interface IngredientPortion {
9 | /**
10 | * Getter method for the underlying ingredient instance
11 | *
12 | * @return the underlying ingredient that this is a portion of
13 | */
14 | Ingredient getIngredient();
15 |
16 | /**
17 | * Getter method for the number of ounces of the underlying ingredient that this IngredientPortion
18 | * represents
19 | *
20 | * @return the weight, in ounces, of the underlying ingredient
21 | */
22 | double getAmount();
23 |
24 | /**
25 | * Getter method for the name of the ingredient
26 | *
27 | * @return the name of the underlying ingredient as a String
28 | */
29 | String getName();
30 |
31 | /**
32 | * Getter method for whether the ingredient is vegetarian
33 | *
34 | * @return true if the underlying ingredient is vegitarian; false otherwise
35 | */
36 | boolean getIsVegetarian();
37 |
38 | /**
39 | * Getter method which returns true if the ingredient is rice
40 | *
41 | * @return true if the underlying ingredient is rice; false otherwise
42 | */
43 | boolean getIsRice();
44 |
45 | /**
46 | * Getter method which returns true if the ingredient is shellfish
47 | *
48 | * @return true if the underlying ingredient is shellfish; false otherwise
49 | */
50 | boolean getIsShellfish();
51 |
52 | /**
53 | * Getter method for the number of calories in the portion
54 | *
55 | * @return the unrounded number of calories in the portion
56 | */
57 | double getCalories();
58 |
59 | /**
60 | * Getter method for the price of the portion
61 | *
62 | * @return the unrounded price of the portion
63 | */
64 | double getCost();
65 |
66 | /**
67 | * Combines the ingredient portion with another portion of the same ingredient, creating a
68 | * combined portion of the ingredient.
69 | *
70 | * @return If other is null, returns this ingredient portion. If the other ingredient portion is
71 | * not the same as this ingredient portion, throws an IllegalArgumentException. Otherwise,
72 | * returns a new ingredient portion, representing the combined amounts of this ingredient
73 | * portion and the other ingredient portion. HINT: Use the equals() method to test equality.
74 | */
75 | IngredientPortion combine(IngredientPortion other);
76 | }
77 |
--------------------------------------------------------------------------------
/Inheritance/src/main/java/com/comp301/a01sushi/IngredientPortionGeneral.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a01sushi;
2 |
3 | /**
4 | * This class represents an ingredient portion. An ingredient portion is a specific amount of an
5 | * ingredient. Ingredient portions are used to represent the ingredients in a sushi roll.
6 | */
7 | public abstract class IngredientPortionGeneral implements IngredientPortion {
8 | private Ingredient ingredient;
9 | private double amount;
10 |
11 | /**
12 | * This constructor initializes the ingredient portion with its ingredient and amount.
13 | *
14 | * @param ingredient The ingredient of the portion
15 | * @param amount The amount of the ingredient in ounces
16 | */
17 | public IngredientPortionGeneral(Ingredient ingredient, double amount) {
18 | if (ingredient == null) {
19 | throw new IllegalArgumentException("Ingredient cannot be null");
20 | }
21 |
22 | if (amount < 0) {
23 | throw new IllegalArgumentException("Amount cannot be negative");
24 | }
25 |
26 | this.ingredient = ingredient;
27 | this.amount = amount;
28 | }
29 |
30 | /**
31 | * This method returns the ingredient of the portion.
32 | *
33 | * @return The ingredient of the portion
34 | */
35 | @Override
36 | public Ingredient getIngredient() {
37 | return this.ingredient;
38 | }
39 |
40 | /**
41 | * This method returns the amount of the ingredient portion.
42 | *
43 | * @return The amount of the ingredient in the portion
44 | */
45 | @Override
46 | public double getAmount() {
47 | return this.amount;
48 | }
49 |
50 | /**
51 | * This method returns the name of the ingredient portion.
52 | *
53 | * @return The name of the ingredient portion
54 | */
55 | @Override
56 | public String getName() {
57 | return this.ingredient.getName();
58 | }
59 |
60 | /**
61 | * This method returns whether the ingredient portion is vegetarian.
62 | *
63 | * @return Whether the ingredient portion is vegetarian
64 | */
65 | @Override
66 | public boolean getIsVegetarian() {
67 | return this.ingredient.getIsVegetarian();
68 | }
69 |
70 | /**
71 | * This method returns whether the ingredient portion is rice.
72 | *
73 | * @return Whether the ingredient portion is rice
74 | */
75 | @Override
76 | public boolean getIsRice() {
77 | return this.ingredient.getIsRice();
78 | }
79 |
80 | /**
81 | * This method returns whether the ingredient portion is shellfish.
82 | *
83 | * @return Whether the ingredient portion is shellfish
84 | */
85 | @Override
86 | public boolean getIsShellfish() {
87 | return this.ingredient.getIsShellfish();
88 | }
89 |
90 | /**
91 | * This method returns the number of calories in the ingredient portion.
92 | *
93 | * @return The number of calories in the ingredient portion
94 | */
95 | @Override
96 | public double getCalories() {
97 | return this.ingredient.getCaloriesPerOunce() * amount;
98 | }
99 |
100 | /**
101 | * This method returns the cost of the ingredient portion.
102 | *
103 | * @return The cost of the ingredient portion
104 | */
105 | @Override
106 | public double getCost() {
107 | return this.ingredient.getPricePerOunce() * amount;
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/Inheritance/src/main/java/com/comp301/a01sushi/Rice.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a01sushi;
2 |
3 | /**
4 | * This class represents a Rice ingredient. Rice is a type of IngredientGeneral with a name, cost,
5 | * calories, and whether it is vegetarian, rice, or shellfish.
6 | */
7 | public class Rice extends IngredientGeneral {
8 |
9 | /**
10 | * This constructor initializes the Rice ingredient with its name, cost, calories, and whether it
11 | * is vegetarian, rice, or shellfish.
12 | */
13 | public Rice() {
14 | super("rice", 0.13, 34, true, true, false);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Inheritance/src/main/java/com/comp301/a01sushi/RicePortion.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a01sushi;
2 |
3 | /**
4 | * This class represents a Rice ingredient portion. Rice is a type of IngredientPortionGeneral with
5 | * a name, cost, calories, and whether it is vegetarian, rice, or shellfish, etc.
6 | */
7 | public class RicePortion extends IngredientPortionGeneral {
8 |
9 | /**
10 | * This constructor initializes the Rice ingredient portion with its amount.
11 | *
12 | * @param amount The amount of Rice in ounces
13 | */
14 | public RicePortion(double amount) {
15 | super(new Rice(), amount);
16 | }
17 |
18 | /**
19 | * This method combines two Rice ingredient portions into one.
20 | *
21 | * @param other The other Rice ingredient portion to be combined
22 | * @return The combined Rice ingredient portion
23 | */
24 | @Override
25 | public IngredientPortion combine(IngredientPortion other) {
26 | if (other == null) {
27 | return this;
28 | }
29 |
30 | boolean isSameIngredient = this.getIngredient().equals(other.getIngredient());
31 |
32 | if (!isSameIngredient) {
33 | throw new IllegalArgumentException("Cannot combine ingredients of different types");
34 | }
35 |
36 | double newAmount = this.getAmount() + other.getAmount();
37 |
38 | return new RicePortion(newAmount);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Inheritance/src/main/java/com/comp301/a01sushi/Seaweed.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a01sushi;
2 |
3 | /**
4 | * This class represents a Seaweed ingredient. Seaweed is a type of IngredientGeneral with a name,
5 | * cost, calories, and whether it is vegetarian, rice, or shellfish.
6 | */
7 | public class Seaweed extends IngredientGeneral {
8 |
9 | /**
10 | * This constructor initializes the Seaweed ingredient with its name, cost, calories, and whether
11 | * it is vegetarian, rice, or shellfish.
12 | */
13 | public Seaweed() {
14 | super("seaweed", 2.85, 105, true, false, false);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Inheritance/src/main/java/com/comp301/a01sushi/SeaweedPortion.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a01sushi;
2 |
3 | /**
4 | * This class represents a Seaweed ingredient portion. Seaweed is a type of IngredientPortionGeneral
5 | * with a name, cost, calories, and whether it is vegetarian, rice, or shellfish, etc.
6 | */
7 | public class SeaweedPortion extends IngredientPortionGeneral {
8 |
9 | /**
10 | * This constructor initializes the Seaweed ingredient portion with its amount.
11 | *
12 | * @param amount The amount of Seaweed in ounces
13 | */
14 | public SeaweedPortion(double amount) {
15 | super(new Seaweed(), amount);
16 | }
17 |
18 | /**
19 | * This method combines two Seaweed ingredient portions into one.
20 | *
21 | * @param other The other Seaweed ingredient portion to be combined
22 | * @return The combined Seaweed ingredient portion
23 | */
24 | @Override
25 | public IngredientPortion combine(IngredientPortion other) {
26 | if (other == null) {
27 | return this;
28 | }
29 |
30 | boolean isSameIngredient = this.getIngredient().equals(other.getIngredient());
31 |
32 | if (!isSameIngredient) {
33 | throw new IllegalArgumentException("Cannot combine ingredients of different types");
34 | }
35 |
36 | double newAmount = this.getAmount() + other.getAmount();
37 |
38 | return new SeaweedPortion(newAmount);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Inheritance/src/main/java/com/comp301/a01sushi/Shrimp.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a01sushi;
2 |
3 | /**
4 | * This class represents a Shrimp ingredient. Shrimp is a type of IngredientGeneral with a name,
5 | * cost, calories, and whether it is vegetarian, rice, or shellfish.
6 | */
7 | public class Shrimp extends IngredientGeneral {
8 |
9 | /**
10 | * This constructor initializes the Shrimp ingredient with its name, cost, calories, and whether
11 | * it is vegetarian, rice, or shellfish.
12 | */
13 | public Shrimp() {
14 | super("shrimp", 0.65, 32, false, false, true);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Inheritance/src/main/java/com/comp301/a01sushi/ShrimpPortion.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a01sushi;
2 |
3 | /**
4 | * This class represents a Shrimp ingredient portion. Shrimp is a type of IngredientPortionGeneral
5 | * with a name, cost, calories, and whether it is vegetarian, rice, or shellfish.
6 | */
7 | public class ShrimpPortion extends IngredientPortionGeneral {
8 |
9 | /**
10 | * This constructor initializes the Shrimp ingredient portion with its amount.
11 | *
12 | * @param amount The amount of Shrimp in the portion
13 | */
14 | public ShrimpPortion(double amount) {
15 | super(new Shrimp(), amount);
16 | }
17 |
18 | /**
19 | * This method combines two Shrimp ingredient portions into one portion.
20 | *
21 | * @param other The other Shrimp ingredient portion to be combined
22 | * @return The combined Shrimp ingredient portion
23 | */
24 | @Override
25 | public IngredientPortion combine(IngredientPortion other) {
26 | if (other == null) {
27 | return this;
28 | }
29 |
30 | boolean isSameIngredient = this.getIngredient().equals(other.getIngredient());
31 |
32 | if (!isSameIngredient) {
33 | throw new IllegalArgumentException("Cannot combine ingredients of different types");
34 | }
35 |
36 | double newAmount = this.getAmount() + other.getAmount();
37 |
38 | return new ShrimpPortion(newAmount);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Inheritance/src/main/java/com/comp301/a01sushi/Sushi.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a01sushi;
2 |
3 | /**
4 | * This interface represents a plate of sushi. A plate of sushi has a name, a list of ingredients, a
5 | * number of calories, a cost, and whether it has rice, shellfish, and is vegetarian.
6 | */
7 | public interface Sushi {
8 | /**
9 | * Getter method for the name of the sushi
10 | *
11 | * @return the name of the sushi as a String
12 | */
13 | String getName();
14 |
15 | /**
16 | * Getter method for the list of ingredients in the plate of sushi
17 | *
18 | * @return the list of ingredients in the plate of sushi
19 | */
20 | IngredientPortion[] getIngredients();
21 |
22 | /**
23 | * Getter method for the overall number of calories in the plate of sushi
24 | *
25 | * @return the number of calories in the plate of sushi, rounded to the nearest integer
26 | */
27 | int getCalories();
28 |
29 | /**
30 | * Getter method for the cost of the ingredients in the plate of sushi
31 | *
32 | * @return the cost of the ingredients in the plate of sushi, rounded to the nearest cent
33 | */
34 | double getCost();
35 |
36 | /**
37 | * Getter method which returns true if the plate of sushi has rice as an ingredient
38 | *
39 | * @return true if the sushi has rice as an ingredient; false otherwise
40 | */
41 | boolean getHasRice();
42 |
43 | /**
44 | * Getter method which returns true if the plate of sushi has shellfish as an ingredient
45 | *
46 | * @return true if the sushi has shellfish as an ingredient; false otherwise
47 | */
48 | boolean getHasShellfish();
49 |
50 | /**
51 | * Getter method which returns true if the plate of sushi is vegetarian
52 | *
53 | * @return true if all the ingredients in the sushi are vegetarian; false otherwise
54 | */
55 | boolean getIsVegetarian();
56 | }
57 |
--------------------------------------------------------------------------------
/Inheritance/src/main/java/com/comp301/a01sushi/Tuna.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a01sushi;
2 |
3 | /**
4 | * This class represents a Tuna ingredient. Tuna is a type of IngredientGeneral with a name, cost,
5 | * calories, and whether it is vegetarian, rice, or shellfish.
6 | */
7 | public class Tuna extends IngredientGeneral {
8 |
9 | /**
10 | * This constructor initializes the Tuna ingredient with its name, cost, calories, and whether it
11 | * is vegetarian, rice, or shellfish.
12 | */
13 | public Tuna() {
14 | super("tuna", 1.67, 42, false, false, false);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Inheritance/src/main/java/com/comp301/a01sushi/TunaPortion.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a01sushi;
2 |
3 | /**
4 | * This class represents a Tuna ingredient portion. Tuna is a type of IngredientPortionGeneral with
5 | * a name, cost, calories, and whether it is vegetarian, rice, or shellfish, etc.
6 | */
7 | public class TunaPortion extends IngredientPortionGeneral {
8 |
9 | /**
10 | * This constructor initializes the Tuna ingredient portion with its amount.
11 | *
12 | * @param amount The amount of Tuna in ounces
13 | */
14 | public TunaPortion(double amount) {
15 | super(new Tuna(), amount);
16 | }
17 |
18 | /**
19 | * This method combines two Tuna ingredient portions into one.
20 | *
21 | * @param other The other Tuna ingredient portion to be combined
22 | * @return The combined Tuna ingredient portion
23 | */
24 | @Override
25 | public IngredientPortion combine(IngredientPortion other) {
26 | if (other == null) {
27 | return this;
28 | }
29 |
30 | boolean isSameIngredient = this.getIngredient().equals(other.getIngredient());
31 |
32 | if (!isSameIngredient) {
33 | throw new IllegalArgumentException("Cannot combine ingredients of different types");
34 | }
35 |
36 | double newAmount = this.getAmount() + other.getAmount();
37 |
38 | return new TunaPortion(newAmount);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Inheritance/src/main/java/com/comp301/a01sushi/Yellowtail.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a01sushi;
2 |
3 | /**
4 | * This class represents a Yellowtail ingredient. Yellowtail is a type of IngredientGeneral with a
5 | * name, cost, calories, and whether it is vegetarian, rice, or shellfish.
6 | */
7 | public class Yellowtail extends IngredientGeneral {
8 |
9 | /**
10 | * This constructor initializes the Yellowtail ingredient with its name, cost, calories, and
11 | * whether it is vegetarian, rice, or shellfish.
12 | */
13 | public Yellowtail() {
14 | super("yellowtail", 0.74, 57, false, false, false);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Inheritance/src/main/java/com/comp301/a01sushi/YellowtailPortion.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a01sushi;
2 |
3 | /**
4 | * This class represents a Yellowtail ingredient portion. Yellowtail is a type of
5 | * IngredientPortionGeneral with a name, cost, calories, and whether it is vegetarian, rice, or
6 | * shellfish, etc.
7 | */
8 | public class YellowtailPortion extends IngredientPortionGeneral {
9 |
10 | /** This constructor initializes the Yellowtail ingredient portion with its amount. */
11 | public YellowtailPortion(double amount) {
12 | super(new Yellowtail(), amount);
13 | }
14 |
15 | /**
16 | * This method combines two Yellowtail ingredient portions into one portion.
17 | *
18 | * @param other The other Yellowtail ingredient portion to be combined
19 | * @return The combined Yellowtail ingredient portion
20 | */
21 | @Override
22 | public IngredientPortion combine(IngredientPortion other) {
23 | if (other == null) {
24 | return this;
25 | }
26 |
27 | boolean isSameIngredient = this.getIngredient().equals(other.getIngredient());
28 |
29 | if (!isSameIngredient) {
30 | throw new IllegalArgumentException("Cannot combine ingredients of different types");
31 | }
32 |
33 | double newAmount = this.getAmount() + other.getAmount();
34 |
35 | return new YellowtailPortion(newAmount);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Inheritance/src/test/java/com/comp301/a01sushi/NigiriTest.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a01sushi;
2 |
3 | import static org.junit.Assert.*;
4 | import org.junit.Test;
5 |
6 | /** This class tests the Nigiri class and its subclasses: Tuna, Yellowtail, Crab, and Shrimp. */
7 | public class NigiriTest {
8 |
9 | /** This test method tests the creation of Nigiri objects and their respective methods. */
10 | @Test
11 | public void testNigiriCreation() {
12 | // Case 1: Tuna
13 | Nigiri tunaNigiri = new Nigiri(Nigiri.NigiriType.TUNA);
14 | assertEquals("tuna nigiri", tunaNigiri.getName());
15 | assertEquals(2, tunaNigiri.getIngredients().length);
16 | assertEquals("tuna", tunaNigiri.getIngredients()[0].getName());
17 | assertEquals("rice", tunaNigiri.getIngredients()[1].getName());
18 | assertEquals(49, tunaNigiri.getCalories());
19 | assertEquals(1.3175, tunaNigiri.getCost(), 0.001);
20 |
21 | // Case 2: Yellowtail
22 | Nigiri yellowtailNigiri = new Nigiri(Nigiri.NigiriType.YELLOWTAIL);
23 | assertEquals("yellowtail nigiri", yellowtailNigiri.getName());
24 | assertEquals(2, yellowtailNigiri.getIngredients().length);
25 | assertEquals("yellowtail", yellowtailNigiri.getIngredients()[0].getName());
26 | assertEquals("rice", yellowtailNigiri.getIngredients()[1].getName());
27 | assertEquals(60, yellowtailNigiri.getCalories());
28 | assertEquals(0.62, yellowtailNigiri.getCost(), 0.001);
29 | }
30 |
31 | /** This test method tests the getIsVegetarian method in the Nigiri class. */
32 | @Test
33 | public void testVegetarianCheck() {
34 | // Test case 1: shrimp
35 | Nigiri shrimpNigiri = new Nigiri(Nigiri.NigiriType.SHRIMP);
36 | assertFalse(shrimpNigiri.getIsVegetarian());
37 |
38 | // Test case 2: yellowtail
39 | Nigiri yellowtailNigiri = new Nigiri(Nigiri.NigiriType.YELLOWTAIL);
40 | assertFalse(yellowtailNigiri.getIsVegetarian());
41 | }
42 |
43 | /** This test method tests the getHasRice method in the Nigiri class. */
44 | @Test
45 | public void testHasRice() {
46 | Nigiri yellowtailNigiri = new Nigiri(Nigiri.NigiriType.YELLOWTAIL);
47 | assertTrue(yellowtailNigiri.getHasRice());
48 | }
49 |
50 | /** This test method tests the getHasShellfish method in the Nigiri class. */
51 | @Test
52 | public void testHasShellfish() {
53 | // Test case 1: crab
54 | Nigiri crabNigiri = new Nigiri(Nigiri.NigiriType.CRAB);
55 | assertTrue(crabNigiri.getHasShellfish());
56 |
57 | // Test case 2: eel
58 | Nigiri eelNigiri = new Nigiri(Nigiri.NigiriType.EEL);
59 | assertFalse(eelNigiri.getHasShellfish());
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/Inheritance/src/test/java/com/comp301/a01sushi/SashimiTest.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a01sushi;
2 |
3 | import static org.junit.Assert.*;
4 | import org.junit.Test;
5 |
6 | /** This class tests the Sashimi class's methods and constructors. */
7 | public class SashimiTest {
8 |
9 | /** This test method tests the creation of Sashimi objects and their respective methods. */
10 | @Test
11 | public void testSashimiCreation() {
12 | // Case 1: Tuna
13 | Sashimi tunaSashimi = new Sashimi(Sashimi.SashimiType.TUNA);
14 | assertEquals("tuna sashimi", tunaSashimi.getName());
15 | assertEquals(1, tunaSashimi.getIngredients().length);
16 | assertEquals("tuna", tunaSashimi.getIngredients()[0].getName());
17 | assertEquals(32, tunaSashimi.getCalories());
18 | assertEquals(1.2525, tunaSashimi.getCost(), 0.001);
19 |
20 | // Case 2: Eel
21 | Sashimi eelSashimi = new Sashimi(Sashimi.SashimiType.EEL);
22 | assertEquals("eel sashimi", eelSashimi.getName());
23 | assertEquals(1, eelSashimi.getIngredients().length);
24 | assertEquals("eel", eelSashimi.getIngredients()[0].getName());
25 | assertEquals(62, eelSashimi.getCalories());
26 | assertEquals(1.6125, eelSashimi.getCost(), 0.001);
27 | }
28 |
29 | /** This test method tests the getIsVegetarian method in the Sashimi class. */
30 | @Test
31 | public void testVegetarianCheck() {
32 | // Test case 1: shrimp
33 | Sashimi shrimpSashimi = new Sashimi(Sashimi.SashimiType.SHRIMP);
34 | assertFalse(shrimpSashimi.getIsVegetarian());
35 |
36 | // Test case 2: crab
37 | Sashimi crabSashimi = new Sashimi(Sashimi.SashimiType.CRAB);
38 | assertFalse(crabSashimi.getIsVegetarian());
39 | }
40 |
41 | /** This test method tests the getHasRice method in the Sashimi class. */
42 | @Test
43 | public void testHasRice() {
44 | Sashimi eelSashimi = new Sashimi(Sashimi.SashimiType.EEL);
45 | assertFalse(eelSashimi.getHasRice());
46 | }
47 |
48 | /** This test method tests the getHasShellfish method in the Sashimi class. */
49 | @Test
50 | public void testHasShellfish() {
51 | // Case 1: Crab
52 | Sashimi crabSashimi = new Sashimi(Sashimi.SashimiType.CRAB);
53 | assertTrue(crabSashimi.getHasShellfish());
54 |
55 | // Case 2: Tuna
56 | Sashimi tunaSashimi = new Sashimi(Sashimi.SashimiType.TUNA);
57 | assertFalse(tunaSashimi.getHasShellfish());
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/Avocado.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/Avocado.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/AvocadoPortion.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/AvocadoPortion.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/Crab.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/Crab.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/CrabPortion.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/CrabPortion.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/Eel.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/Eel.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/EelPortion.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/EelPortion.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/Ingredient.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/Ingredient.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/IngredientGeneral.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/IngredientGeneral.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/IngredientPortion.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/IngredientPortion.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/IngredientPortionGeneral.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/IngredientPortionGeneral.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/Nigiri$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/Nigiri$1.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/Nigiri$NigiriType.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/Nigiri$NigiriType.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/Nigiri.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/Nigiri.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/Rice.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/Rice.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/RicePortion.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/RicePortion.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/Roll.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/Roll.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/Sashimi$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/Sashimi$1.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/Sashimi$SashimiType.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/Sashimi$SashimiType.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/Sashimi.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/Sashimi.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/Seaweed.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/Seaweed.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/SeaweedPortion.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/SeaweedPortion.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/Shrimp.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/Shrimp.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/ShrimpPortion.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/ShrimpPortion.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/Sushi.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/Sushi.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/Tuna.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/Tuna.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/TunaPortion.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/TunaPortion.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/Yellowtail.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/Yellowtail.class
--------------------------------------------------------------------------------
/Inheritance/target/classes/com/comp301/a01sushi/YellowtailPortion.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/classes/com/comp301/a01sushi/YellowtailPortion.class
--------------------------------------------------------------------------------
/Inheritance/target/test-classes/com/comp301/a01sushi/IngredientPortionTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/test-classes/com/comp301/a01sushi/IngredientPortionTest.class
--------------------------------------------------------------------------------
/Inheritance/target/test-classes/com/comp301/a01sushi/IngredientTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/test-classes/com/comp301/a01sushi/IngredientTest.class
--------------------------------------------------------------------------------
/Inheritance/target/test-classes/com/comp301/a01sushi/NigiriTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/test-classes/com/comp301/a01sushi/NigiriTest.class
--------------------------------------------------------------------------------
/Inheritance/target/test-classes/com/comp301/a01sushi/RollTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/test-classes/com/comp301/a01sushi/RollTest.class
--------------------------------------------------------------------------------
/Inheritance/target/test-classes/com/comp301/a01sushi/SashimiTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Inheritance/target/test-classes/com/comp301/a01sushi/SashimiTest.class
--------------------------------------------------------------------------------
/Iterator/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 | 4.0.0
6 |
7 | com.comp301.a05driver
8 | a05-driver
9 | 1.0-SNAPSHOT
10 |
11 | a05-driver
12 |
13 | http://www.example.com
14 |
15 |
16 | UTF-8
17 | 1.7
18 | 1.7
19 |
20 |
21 |
22 |
23 | junit
24 | junit
25 | 4.11
26 | test
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | maven-clean-plugin
36 | 3.1.0
37 |
38 |
39 |
40 | maven-resources-plugin
41 | 3.0.2
42 |
43 |
44 | maven-compiler-plugin
45 | 3.8.0
46 |
47 |
48 | maven-surefire-plugin
49 | 2.22.1
50 |
51 |
52 | maven-jar-plugin
53 | 3.0.2
54 |
55 |
56 | maven-install-plugin
57 | 2.5.2
58 |
59 |
60 | maven-deploy-plugin
61 | 2.8.2
62 |
63 |
64 |
65 | maven-site-plugin
66 | 3.7.1
67 |
68 |
69 | maven-project-info-reports-plugin
70 | 3.0.0
71 |
72 |
73 |
74 |
75 |
76 | org.apache.maven.plugins
77 | maven-compiler-plugin
78 |
79 | 8
80 | 8
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/Iterator/src/main/java/com/comp301/a05driver/Driver.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a05driver;
2 |
3 | /*
4 | * Driver
5 | * Represents a driver associated with a vehicle.
6 | *
7 | * getFirstName()
8 | * Retrieves first name of driver.
9 | *
10 | * getLastName()
11 | * Retrieves last name of driver.
12 | *
13 | * getFullName()
14 | * Retrieves full name of driver. This should be the first name followed
15 | * a single space followed by the last name.
16 | *
17 | * getID()
18 | * Retrieves the ID number of the driver.
19 | *
20 | * getVehicle()
21 | * Retrieves the Vehicle object associated with the driver.
22 | *
23 | * setVehicle(Vehicle v)
24 | * Setter for the vehicle associated with the driver.
25 | */
26 |
27 | /** Represents a driver associated with a vehicle. */
28 | public interface Driver {
29 |
30 | /**
31 | * Retrieves first name of driver.
32 | *
33 | * @return first name of driver
34 | */
35 | String getFirstName();
36 |
37 | /**
38 | * Retrieves last name of driver.
39 | *
40 | * @return last name of driver
41 | */
42 | String getLastName();
43 |
44 | /**
45 | * Retrieves full name of driver. This should be the first name followed by a single space
46 | * followed by the last name.
47 | *
48 | * @return full name of driver
49 | */
50 | default String getFullName() {
51 | return getFirstName() + " " + getLastName();
52 | }
53 |
54 | /**
55 | * Retrieves the ID number of the driver.
56 | *
57 | * @return ID number of the driver
58 | */
59 | int getID();
60 |
61 | /**
62 | * Retrieves the Vehicle object associated with the driver.
63 | *
64 | * @return Vehicle object associated with the driver
65 | */
66 | Vehicle getVehicle();
67 |
68 | /**
69 | * Setter for the vehicle associated with the driver.
70 | *
71 | * @param v Vehicle object to associate with the driver
72 | */
73 | void setVehicle(Vehicle v);
74 | }
75 |
--------------------------------------------------------------------------------
/Iterator/src/main/java/com/comp301/a05driver/DriverImpl.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a05driver;
2 |
3 | /** Represents a driver associated with a vehicle. */
4 | public class DriverImpl implements Driver {
5 |
6 | private String _first;
7 | private String _last;
8 | private int _id;
9 | private Vehicle _vehicle;
10 |
11 | /**
12 | * Constructor for the DriverImpl class.
13 | *
14 | * @param first The first name of the driver
15 | * @param last The last name of the driver
16 | * @param id The ID number of the driver
17 | * @param vehicle The Vehicle object associated with the driver
18 | */
19 | public DriverImpl(String first, String last, int id, Vehicle vehicle) {
20 | if (first == null) {
21 | throw new RuntimeException("Null first name");
22 | }
23 | if (last == null) {
24 | throw new RuntimeException("Null last name");
25 | }
26 | if (vehicle == null) {
27 | throw new RuntimeException("Null vehicle");
28 | }
29 |
30 | _first = first;
31 | _last = last;
32 | _id = id;
33 | _vehicle = vehicle;
34 | }
35 |
36 | /**
37 | * Retrieves first name of driver.
38 | *
39 | * @return first name of driver
40 | */
41 | @Override
42 | public String getFirstName() {
43 | return _first;
44 | }
45 |
46 | /**
47 | * Retrieves last name of driver.
48 | *
49 | * @return last name of driver
50 | */
51 | @Override
52 | public String getLastName() {
53 | return _last;
54 | }
55 |
56 | /**
57 | * Retrieves the ID number of the driver.
58 | *
59 | * @return ID number of the driver
60 | */
61 | @Override
62 | public int getID() {
63 | return _id;
64 | }
65 |
66 | /**
67 | * Retrieves the Vehicle object associated with the driver.
68 | *
69 | * @return Vehicle object associated with the driver
70 | */
71 | @Override
72 | public Vehicle getVehicle() {
73 | return _vehicle;
74 | }
75 |
76 | /**
77 | * Setter for the vehicle associated with the driver.
78 | *
79 | * @param v Vehicle object to associate with the driver
80 | */
81 | @Override
82 | public void setVehicle(Vehicle v) {
83 | if (v == null) {
84 | throw new RuntimeException("Null vehicle");
85 | }
86 | _vehicle = v;
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/Iterator/src/main/java/com/comp301/a05driver/Position.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a05driver;
2 |
3 | /*
4 | * Position
5 | * Represents an integer (x,y) position on a grid.
6 | *
7 | * getX()
8 | * Retrieves x coordinate of the position
9 | *
10 | * getY()
11 | * Retrieves y coordinate of the position
12 | *
13 | * getManhattanDistanceTo(Position p)
14 | * Calculates the "Manhattan" distance between two positions.
15 | * The Manhattan distance is simply the absolute difference in x positions
16 | * summed with the absolute difference in y positions.
17 | */
18 |
19 | /** Represents an integer (x,y) position on a grid. */
20 | public interface Position {
21 |
22 | /**
23 | * Retrieves x coordinate of the position
24 | *
25 | * @return x coordinate of the position
26 | */
27 | int getX();
28 |
29 | /**
30 | * Retrieves y coordinate of the position
31 | *
32 | * @return y coordinate of the position
33 | */
34 | int getY();
35 |
36 | /**
37 | * Calculates the "Manhattan" distance between two positions. The Manhattan distance is simply the
38 | * absolute difference in x positions summed with the absolute difference in y positions.
39 | *
40 | * @param p The other position to calculate the distance to
41 | * @return The Manhattan distance between the two positions
42 | */
43 | default int getManhattanDistanceTo(Position p) {
44 | return Math.abs(getX() - p.getX()) + Math.abs(getY() - p.getY());
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Iterator/src/main/java/com/comp301/a05driver/PositionImpl.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a05driver;
2 |
3 | /** Represents an integer (x,y) position on a grid. */
4 | public class PositionImpl implements Position {
5 |
6 | private int _x;
7 | private int _y;
8 |
9 | /**
10 | * Constructor for the PositionImpl class.
11 | *
12 | * @param x The x coordinate of the position
13 | * @param y The y coordinate of the position
14 | */
15 | public PositionImpl(int x, int y) {
16 | _x = x;
17 | _y = y;
18 | }
19 |
20 | /**
21 | * Retrieves x coordinate of the position
22 | *
23 | * @return x coordinate of the position
24 | */
25 | @Override
26 | public int getX() {
27 | return _x;
28 | }
29 |
30 | /**
31 | * Retrieves y coordinate of the position
32 | *
33 | * @return y coordinate of the position
34 | */
35 | @Override
36 | public int getY() {
37 | return _y;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Iterator/src/main/java/com/comp301/a05driver/Vehicle.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a05driver;
2 |
3 | /*
4 | * Vehicle
5 | * Represents a vehicle in our system.
6 | *
7 | * getMake()
8 | * Retrieves the make of the vehicle.
9 | *
10 | * getModel()
11 | * Retrieves the model of the vehicle.
12 | *
13 | * getPlate()
14 | * Retrieves the license plate of the vehicle.
15 | *
16 | * getMileage()
17 | * Retrieves the total distance the vehicle has traveled
18 | * up to now. Think of this like its "odometer".
19 | *
20 | * getPosition()
21 | * Retrieves the current position of the vehicle.
22 | *
23 | * moveTo(Position p)
24 | * Updates the mileage of the vehicle by adding the Manhattan
25 | * distance between the vehicle's current position and the
26 | * position p passed in as a parameter. Then updates the
27 | * vehicle's current position to be p.
28 | */
29 |
30 | /** Represents a vehicle in our system. */
31 | public interface Vehicle {
32 |
33 | /**
34 | * Retrieves the make of the vehicle.
35 | *
36 | * @return The make of the vehicle
37 | */
38 | String getMake();
39 |
40 | /**
41 | * Retrieves the model of the vehicle.
42 | *
43 | * @return The model of the vehicle
44 | */
45 | String getModel();
46 |
47 | /**
48 | * Retrieves the license plate of the vehicle.
49 | *
50 | * @return The license plate of the vehicle
51 | */
52 | String getPlate();
53 |
54 | /**
55 | * Retrieves the total distance the vehicle has traveled up to now. Think of this like its
56 | * "odometer".
57 | *
58 | * @return The total distance the vehicle has traveled
59 | */
60 | int getMileage();
61 |
62 | /**
63 | * Retrieves the current position of the vehicle.
64 | *
65 | * @return The current position of the vehicle
66 | */
67 | Position getPosition();
68 |
69 | /**
70 | * Updates the mileage of the vehicle by adding the Manhattan distance between the vehicle's
71 | * current position and the position p passed in as a parameter. Then updates the vehicle's
72 | * current position to be p.
73 | *
74 | * @param p The position to move the vehicle to
75 | */
76 | void moveToPosition(Position p);
77 | }
78 |
--------------------------------------------------------------------------------
/Iterator/src/main/java/com/comp301/a05driver/VehicleImpl.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a05driver;
2 |
3 | /** Represents a vehicle that can be driven by a driver. */
4 | public class VehicleImpl implements Vehicle {
5 |
6 | private String _make;
7 | private String _model;
8 | private String _plate;
9 | private int _mileage;
10 | private Position _position;
11 |
12 | /**
13 | * Constructor for the VehicleImpl class.
14 | *
15 | * @param make The make of the vehicle
16 | * @param model The model of the vehicle
17 | * @param plate The license plate of the vehicle
18 | * @param position The current position of the vehicle
19 | */
20 | public VehicleImpl(String make, String model, String plate, Position position) {
21 | if (make == null) {
22 | throw new RuntimeException("make is null");
23 | }
24 | if (model == null) {
25 | throw new RuntimeException("model is null");
26 | }
27 | if (plate == null) {
28 | throw new RuntimeException("plate is null");
29 | }
30 | if (position == null) {
31 | throw new RuntimeException("position is null");
32 | }
33 |
34 | _make = make;
35 | _model = model;
36 | _plate = plate;
37 | _position = position;
38 |
39 | _mileage = 0;
40 | }
41 |
42 | /**
43 | * Retrieves the make of the vehicle.
44 | *
45 | * @return The make of the vehicle
46 | */
47 | @Override
48 | public String getMake() {
49 | return _make;
50 | }
51 |
52 | /**
53 | * Retrieves the model of the vehicle.
54 | *
55 | * @return The model of the vehicle
56 | */
57 | @Override
58 | public String getModel() {
59 | return _model;
60 | }
61 |
62 | /**
63 | * Retrieves the license plate of the vehicle.
64 | *
65 | * @return The license plate of the vehicle
66 | */
67 | @Override
68 | public String getPlate() {
69 | return _plate;
70 | }
71 |
72 | /**
73 | * Retrieves the total distance the vehicle has traveled up to now. Think of this like its
74 | * "odometer".
75 | *
76 | * @return The total distance the vehicle has traveled
77 | */
78 | @Override
79 | public int getMileage() {
80 | return _mileage;
81 | }
82 |
83 | /**
84 | * Retrieves the current position of the vehicle.
85 | *
86 | * @return The current position of the vehicle
87 | */
88 | @Override
89 | public Position getPosition() {
90 | return _position;
91 | }
92 |
93 | /**
94 | * Updates the mileage of the vehicle by adding the Manhattan distance between the vehicle's
95 | * current position and the position p passed in as a parameter. Then updates the vehicle's
96 | * current position to be p.
97 | *
98 | * @param p The new position of the vehicle
99 | */
100 | @Override
101 | public void moveToPosition(Position p) {
102 | if (p == null) {
103 | throw new RuntimeException("New vehicle position is null");
104 | }
105 |
106 | _mileage += _position.getManhattanDistanceTo(p);
107 | _position = p;
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/Iterator/target/classes/com/comp301/a05driver/Driver.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Iterator/target/classes/com/comp301/a05driver/Driver.class
--------------------------------------------------------------------------------
/Iterator/target/classes/com/comp301/a05driver/DriverImpl.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Iterator/target/classes/com/comp301/a05driver/DriverImpl.class
--------------------------------------------------------------------------------
/Iterator/target/classes/com/comp301/a05driver/ExpandingProximityIterator.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Iterator/target/classes/com/comp301/a05driver/ExpandingProximityIterator.class
--------------------------------------------------------------------------------
/Iterator/target/classes/com/comp301/a05driver/Position.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Iterator/target/classes/com/comp301/a05driver/Position.class
--------------------------------------------------------------------------------
/Iterator/target/classes/com/comp301/a05driver/PositionImpl.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Iterator/target/classes/com/comp301/a05driver/PositionImpl.class
--------------------------------------------------------------------------------
/Iterator/target/classes/com/comp301/a05driver/ProximityIterator.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Iterator/target/classes/com/comp301/a05driver/ProximityIterator.class
--------------------------------------------------------------------------------
/Iterator/target/classes/com/comp301/a05driver/SnakeOrderAcrossPoolsIterator.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Iterator/target/classes/com/comp301/a05driver/SnakeOrderAcrossPoolsIterator.class
--------------------------------------------------------------------------------
/Iterator/target/classes/com/comp301/a05driver/Vehicle.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Iterator/target/classes/com/comp301/a05driver/Vehicle.class
--------------------------------------------------------------------------------
/Iterator/target/classes/com/comp301/a05driver/VehicleImpl.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Iterator/target/classes/com/comp301/a05driver/VehicleImpl.class
--------------------------------------------------------------------------------
/Iterator/target/test-classes/com/comp301/a05driver/ExpandingProximityIteratorTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Iterator/target/test-classes/com/comp301/a05driver/ExpandingProximityIteratorTest.class
--------------------------------------------------------------------------------
/Iterator/target/test-classes/com/comp301/a05driver/ProximityIteratorTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Iterator/target/test-classes/com/comp301/a05driver/ProximityIteratorTest.class
--------------------------------------------------------------------------------
/Iterator/target/test-classes/com/comp301/a05driver/SnakeOrderAcrossPoolsIteratorTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Iterator/target/test-classes/com/comp301/a05driver/SnakeOrderAcrossPoolsIteratorTest.class
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 Son Nguyen
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 Son Nguyen
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/img/instructions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/img/instructions.png
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/img/ui.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/img/ui.png
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/img/welcome.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/img/welcome.png
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | org.example
8 | Game-2048-JavaFX
9 | 1.0-SNAPSHOT
10 | Game-2048-JavaFX
11 |
12 |
13 | UTF-8
14 | 5.10.2
15 |
16 |
17 |
18 |
19 | org.openjfx
20 | javafx-controls
21 | 22.0.1
22 |
23 |
24 | org.openjfx
25 | javafx-fxml
26 | 22.0.1
27 |
28 |
29 |
30 | org.junit.jupiter
31 | junit-jupiter-api
32 | ${junit.version}
33 | test
34 |
35 |
36 | junit
37 | junit
38 | 4.11
39 | test
40 |
41 |
42 | org.junit.jupiter
43 | junit-jupiter-engine
44 | ${junit.version}
45 | test
46 |
47 |
48 | org.mongodb
49 | mongodb-driver-sync
50 | 4.9.0
51 |
52 |
53 |
54 |
55 |
56 |
57 | org.apache.maven.plugins
58 | maven-compiler-plugin
59 | 3.13.0
60 |
61 | 22
62 | 22
63 |
64 |
65 |
66 | org.openjfx
67 | javafx-maven-plugin
68 | 0.0.8
69 |
70 |
71 |
72 | default-cli
73 |
74 | org.example.game2048javafx/org.example.game2048javafx.HelloApplication
75 | app
76 | app
77 | app
78 | true
79 | true
80 | true
81 |
82 |
83 |
84 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/src/main/java/module-info.java:
--------------------------------------------------------------------------------
1 | module org.example.game2048javafx {
2 | requires javafx.controls;
3 | requires javafx.fxml;
4 |
5 |
6 | opens org.example.game2048javafx to javafx.fxml;
7 | exports org.example.game2048javafx;
8 | }
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/src/main/java/org/example/game2048javafx/Controller.java:
--------------------------------------------------------------------------------
1 | package org.example.game2048javafx;
2 |
3 | /** The Controller class is responsible for handling user input and updating the model and view */
4 | public class Controller {
5 |
6 | /** The model of the game */
7 | private final Model model;
8 |
9 | /** The view of the game */
10 | private final View view;
11 |
12 | /**
13 | * Constructor for the Controller class
14 | *
15 | * @param model The model of the game
16 | * @param view The view of the game
17 | */
18 | public Controller(Model model, View view) {
19 | this.model = model;
20 | this.view = view;
21 | }
22 |
23 | /** Starts the game by resetting the board and adding two random tiles */
24 | public void startGame() {
25 | model.resetBoard();
26 | model.addRandomTile();
27 | model.addRandomTile();
28 | view.updateUI(model.getBoard(), model.getScore(), model.getBestScore());
29 | }
30 |
31 | /**
32 | * Handles the key press event by moving the tiles in the specified direction
33 | *
34 | * @param direction The direction to move the tiles
35 | */
36 | public void handleKeyPress(String direction) {
37 | if (model.move(direction)) {
38 | model.addRandomTile();
39 | view.updateUI(model.getBoard(), model.getScore(), model.getBestScore());
40 | if (model.checkGameOver()) {
41 | System.out.println("Game Over!");
42 | }
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/favicon.png
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-Black.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-Black.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-BlackItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-BlackItalic.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-Bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-Bold.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-BoldItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-BoldItalic.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-ExtraBold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-ExtraBold.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-ExtraBoldItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-ExtraBoldItalic.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-ExtraLight.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-ExtraLight.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-ExtraLightItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-ExtraLightItalic.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-Italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-Italic.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-Light.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-Light.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-LightItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-LightItalic.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-Medium.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-Medium.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-MediumItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-MediumItalic.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-Regular.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-SemiBold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-SemiBold.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-SemiBoldItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-SemiBoldItalic.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-Thin.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-Thin.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-ThinItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/fonts/Poppins-ThinItalic.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/hello-view.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/src/main/resources/org/example/game2048javafx/styles.css:
--------------------------------------------------------------------------------
1 | .root {
2 | -fx-font-family: "Arial";
3 | -fx-background-color: #faf8ef;
4 | }
5 |
6 | .label {
7 | -fx-font-weight: bold;
8 | -fx-text-alignment: center;
9 | }
10 |
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/classes/favicon.png
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/module-info.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/classes/module-info.class
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/Controller.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/Controller.class
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/Game2048$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/Game2048$1.class
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/Game2048.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/Game2048.class
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/Main.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/Main.class
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/Model.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/Model.class
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/View.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/View.class
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-Black.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-Black.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-BlackItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-BlackItalic.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-Bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-Bold.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-BoldItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-BoldItalic.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-ExtraBold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-ExtraBold.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-ExtraBoldItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-ExtraBoldItalic.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-ExtraLight.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-ExtraLight.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-ExtraLightItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-ExtraLightItalic.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-Italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-Italic.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-Light.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-Light.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-LightItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-LightItalic.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-Medium.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-Medium.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-MediumItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-MediumItalic.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-Regular.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-SemiBold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-SemiBold.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-SemiBoldItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-SemiBoldItalic.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-Thin.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-Thin.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-ThinItalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/fonts/Poppins-ThinItalic.ttf
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/hello-view.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/classes/org/example/game2048javafx/styles.css:
--------------------------------------------------------------------------------
1 | .root {
2 | -fx-font-family: "Arial";
3 | -fx-background-color: #faf8ef;
4 | }
5 |
6 | .label {
7 | -fx-font-weight: bold;
8 | -fx-text-alignment: center;
9 | }
10 |
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst:
--------------------------------------------------------------------------------
1 | /Users/davidnguyen/IdeaProjects/Game-2048-JavaFX/src/main/java/module-info.java
2 | /Users/davidnguyen/IdeaProjects/Game-2048-JavaFX/src/main/java/org/example/game2048javafx/Controller.java
3 | /Users/davidnguyen/IdeaProjects/Game-2048-JavaFX/src/main/java/org/example/game2048javafx/Game2048.java
4 | /Users/davidnguyen/IdeaProjects/Game-2048-JavaFX/src/main/java/org/example/game2048javafx/Main.java
5 | /Users/davidnguyen/IdeaProjects/Game-2048-JavaFX/src/main/java/org/example/game2048javafx/Model.java
6 | /Users/davidnguyen/IdeaProjects/Game-2048-JavaFX/src/main/java/org/example/game2048javafx/View.java
7 |
--------------------------------------------------------------------------------
/Model-View-Controllers/Game-2048-JavaFX/target/test-classes/org/example/game2048javafx/ModelTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Model-View-Controllers/Game-2048-JavaFX/target/test-classes/org/example/game2048javafx/ModelTest.class
--------------------------------------------------------------------------------
/Observers/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 | 4.0.0
6 |
7 | com.comp301.a08shopping
8 | a08-shopping
9 | 1.0-SNAPSHOT
10 |
11 | a08-shopping
12 |
13 | http://www.example.com
14 |
15 |
16 | UTF-8
17 | 1.7
18 | 1.7
19 |
20 |
21 |
22 |
23 | junit
24 | junit
25 | 4.11
26 | test
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | maven-clean-plugin
36 | 3.1.0
37 |
38 |
39 |
40 | maven-resources-plugin
41 | 3.0.2
42 |
43 |
44 | maven-compiler-plugin
45 | 3.8.0
46 |
47 |
48 | maven-surefire-plugin
49 | 2.22.1
50 |
51 |
52 | maven-jar-plugin
53 | 3.0.2
54 |
55 |
56 | maven-install-plugin
57 | 2.5.2
58 |
59 |
60 | maven-deploy-plugin
61 | 2.8.2
62 |
63 |
64 |
65 | maven-site-plugin
66 | 3.7.1
67 |
68 |
69 | maven-project-info-reports-plugin
70 | 3.0.0
71 |
72 |
73 |
74 |
75 |
76 | org.apache.maven.plugins
77 | maven-compiler-plugin
78 |
79 | 8
80 | 8
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/Observers/src/main/java/com/comp301/a08shopping/Customer.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a08shopping;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * This interface represents a customer that can purchase products from a store. The customer has a
7 | * name, a budget, and a purchase history. The customer can purchase products from a store and
8 | * receive a receipt item for each purchase. The customer is also a StoreObserver and will be
9 | * notified when a product is out of stock or when a product is purchased.
10 | */
11 | public interface Customer extends StoreObserver {
12 | /**
13 | * Gets the customer's name
14 | *
15 | * @return The customer's name
16 | */
17 | String getName();
18 |
19 | /**
20 | * Gets the amount of money that the customer currently has (in dollars)
21 | *
22 | * @return The amount of money that the customer currently has
23 | */
24 | double getBudget();
25 |
26 | /**
27 | * Purchases a particular product from a store by performing the following actions, in order:
28 | *
29 | *
1. If the sale price of the product costs more money then the customer has, throw an
30 | * IllegalStateException exception
31 | *
32 | *
2. Decrease the customer's money by the sale price of the product
33 | *
34 | *
3. Purchase the object from the store by calling store.purchaseProduct()
35 | *
36 | *
4. Add the returned ReceiptItem from the store to the customer's purchase history
37 | *
38 | * @param product The product to purchase
39 | * @param store The store from which to purchase the product
40 | */
41 | void purchaseProduct(Product product, Store store);
42 |
43 | /**
44 | * Gets a list of the products that the customer has purchased (Note: The returned value should be
45 | * a copy of the encapsulated field)
46 | *
47 | * @return A list of the products that the customer has purchased
48 | */
49 | List getPurchaseHistory();
50 | }
51 |
--------------------------------------------------------------------------------
/Observers/src/main/java/com/comp301/a08shopping/Product.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a08shopping;
2 |
3 | /** This interface represents a product that can be purchased */
4 | public interface Product {
5 | /**
6 | * Gets the product's name
7 | *
8 | * @return The product's name
9 | */
10 | String getName();
11 |
12 | /**
13 | * Gets the product's price
14 | *
15 | * @return The product's price
16 | */
17 | double getBasePrice();
18 | }
19 |
--------------------------------------------------------------------------------
/Observers/src/main/java/com/comp301/a08shopping/ProductImpl.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a08shopping;
2 |
3 | /** This class represents a product that can be purchased */
4 | public class ProductImpl implements Product {
5 | /** The name of the product */
6 | private final String name;
7 |
8 | /** The base price of the product */
9 | private final double basePrice;
10 |
11 | /**
12 | * Constructor for the ProductImpl
13 | *
14 | * @param name The name of the product
15 | * @param basePrice The base price of the product
16 | */
17 | public ProductImpl(String name, double basePrice) {
18 | if (name == null || name.trim().isEmpty()) {
19 | throw new IllegalArgumentException("Product name cannot be null or empty");
20 | }
21 |
22 | if (basePrice <= 0) {
23 | throw new IllegalArgumentException("Base price must be greater than zero");
24 | }
25 |
26 | this.name = name;
27 | this.basePrice = Math.round(basePrice * 100.0) / 100.0;
28 | }
29 |
30 | /**
31 | * Gets the product's name
32 | *
33 | * @return The product's name
34 | */
35 | @Override
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | /**
41 | * Gets the product's price
42 | *
43 | * @return The product's price
44 | */
45 | @Override
46 | public double getBasePrice() {
47 | return basePrice;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Observers/src/main/java/com/comp301/a08shopping/ReceiptItem.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a08shopping;
2 |
3 | /** This interface represents an item on a receipt */
4 | public interface ReceiptItem {
5 | /**
6 | * Gets the name of the product
7 | *
8 | * @return The name of the product
9 | */
10 | String getProductName();
11 |
12 | /**
13 | * Gets the price paid for the product
14 | *
15 | * @return The price paid for the product
16 | */
17 | double getPricePaid();
18 |
19 | /**
20 | * Gets the store name where the product was purchased
21 | *
22 | * @return The store name where the product was purchased
23 | */
24 | String getStoreName();
25 | }
26 |
--------------------------------------------------------------------------------
/Observers/src/main/java/com/comp301/a08shopping/ReceiptItemImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * No need to make changes to this file for a08-shopping. This file represents a receipt from a
3 | * store after an item is purchased. You'll need to use this class in the
4 | * StoreImpl.purchaseProduct() method
5 | */
6 |
7 | package com.comp301.a08shopping;
8 |
9 | /** This class represents an item on a receipt */
10 | public class ReceiptItemImpl implements ReceiptItem {
11 | /** The name of the product */
12 | private final String productName;
13 |
14 | /** The price paid for the product */
15 | private final double pricePaid;
16 |
17 | /** The store name where the product was purchased */
18 | private final String storeName;
19 |
20 | /**
21 | * Constructor for the ReceiptItemImpl
22 | *
23 | * @param productName The name of the product
24 | * @param pricePaid The price paid for the product
25 | * @param storeName The store name where the product was purchased
26 | */
27 | public ReceiptItemImpl(String productName, double pricePaid, String storeName) {
28 | this.productName = productName;
29 | this.pricePaid = pricePaid;
30 | this.storeName = storeName;
31 | }
32 |
33 | /**
34 | * Gets the name of the product
35 | *
36 | * @return The name of the product
37 | */
38 | @Override
39 | public String getProductName() {
40 | return productName;
41 | }
42 |
43 | /**
44 | * Gets the price paid for the product
45 | *
46 | * @return The price paid for the product
47 | */
48 | @Override
49 | public double getPricePaid() {
50 | return pricePaid;
51 | }
52 |
53 | /**
54 | * Gets the store name where the product was purchased
55 | *
56 | * @return The store name where the product was purchased
57 | */
58 | @Override
59 | public String getStoreName() {
60 | return storeName;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Observers/src/main/java/com/comp301/a08shopping/StoreObserver.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a08shopping;
2 |
3 | import com.comp301.a08shopping.events.StoreEvent;
4 |
5 | /** This interface represents an observer that listens for events that occur at a store. */
6 | public interface StoreObserver {
7 |
8 | /**
9 | * This method is called when an event occurs at a store. The observer should update its state
10 | * based on the event.
11 | *
12 | * @param event The event that occurred at the store
13 | */
14 | void update(StoreEvent event);
15 | }
16 |
--------------------------------------------------------------------------------
/Observers/src/main/java/com/comp301/a08shopping/events/BackInStockEvent.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a08shopping.events;
2 |
3 | import com.comp301.a08shopping.Product;
4 | import com.comp301.a08shopping.Store;
5 |
6 | /**
7 | * This event is fired when a product that was previously out of stock is back in stock at a store.
8 | */
9 | public class BackInStockEvent implements StoreEvent {
10 | /** The product that is back in stock */
11 | private final Product product;
12 |
13 | /** The store where the product is back in stock */
14 | private final Store store;
15 |
16 | /**
17 | * Constructor for the BackInStockEvent
18 | *
19 | * @param product The product that is back in stock
20 | * @param store The store where the product is back in stock
21 | */
22 | public BackInStockEvent(Product product, Store store) {
23 | if (product == null || store == null) {
24 | throw new IllegalArgumentException("Product and Store cannot be null");
25 | }
26 |
27 | this.product = product;
28 | this.store = store;
29 | }
30 |
31 | /**
32 | * Get the product that is back in stock
33 | *
34 | * @return The product that is back in stock
35 | */
36 | public Product getProduct() {
37 | return product;
38 | }
39 |
40 | /**
41 | * Get the store where the product is back in stock
42 | *
43 | * @return The store where the product is back in stock
44 | */
45 | public Store getStore() {
46 | return store;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/Observers/src/main/java/com/comp301/a08shopping/events/OutOfStockEvent.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a08shopping.events;
2 |
3 | import com.comp301.a08shopping.Product;
4 | import com.comp301.a08shopping.Store;
5 |
6 | /**
7 | * This event is fired when a product is out of stock at a store. The event contains the product
8 | * that is out of stock and the store where the product is out of stock.
9 | */
10 | public class OutOfStockEvent implements StoreEvent {
11 | /** The product that is out of stock */
12 | private final Product product;
13 |
14 | /** The store where the product is out of stock */
15 | private final Store store;
16 |
17 | /**
18 | * Constructor for the OutOfStockEvent
19 | *
20 | * @param product The product that is out of stock
21 | * @param store The store where the product is out of stock
22 | */
23 | public OutOfStockEvent(Product product, Store store) {
24 | if (product == null || store == null) {
25 | throw new IllegalArgumentException("Product and Store cannot be null");
26 | }
27 |
28 | this.product = product;
29 | this.store = store;
30 | }
31 |
32 | /**
33 | * Get the product that is out of stock
34 | *
35 | * @return The product that is out of stock
36 | */
37 | public Product getProduct() {
38 | return product;
39 | }
40 |
41 | /**
42 | * Get the store where the product is out of stock
43 | *
44 | * @return The store where the product is out of stock
45 | */
46 | public Store getStore() {
47 | return store;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Observers/src/main/java/com/comp301/a08shopping/events/PurchaseEvent.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a08shopping.events;
2 |
3 | import com.comp301.a08shopping.Product;
4 | import com.comp301.a08shopping.Store;
5 |
6 | /**
7 | * This event is fired when a product is purchased from a store. The event contains the product that
8 | * was purchased and the store where the product was purchased.
9 | */
10 | public class PurchaseEvent implements StoreEvent {
11 | /** The product that was purchased */
12 | private final Product product;
13 |
14 | /** The store where the product was purchased */
15 | private final Store store;
16 |
17 | /**
18 | * Constructor for the PurchaseEvent
19 | *
20 | * @param product The product that was purchased
21 | * @param store The store where the product was purchased
22 | */
23 | public PurchaseEvent(Product product, Store store) {
24 | if (product == null || store == null) {
25 | throw new IllegalArgumentException("Product and Store cannot be null");
26 | }
27 |
28 | this.product = product;
29 | this.store = store;
30 | }
31 |
32 | /**
33 | * Get the product that was purchased
34 | *
35 | * @return The product that was purchased
36 | */
37 | public Product getProduct() {
38 | return product;
39 | }
40 |
41 | /**
42 | * Get the store where the product was purchased
43 | *
44 | * @return The store where the product was purchased
45 | */
46 | public Store getStore() {
47 | return store;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Observers/src/main/java/com/comp301/a08shopping/events/SaleEndEvent.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a08shopping.events;
2 |
3 | import com.comp301.a08shopping.Product;
4 | import com.comp301.a08shopping.Store;
5 |
6 | /**
7 | * This event is fired when a sale ends for a product at a store. The event contains the product
8 | * that the sale ended for and the store where the sale ended.
9 | */
10 | public class SaleEndEvent implements StoreEvent {
11 | /** The product that the sale ended for */
12 | private final Product product;
13 |
14 | /** The store where the sale ended */
15 | private final Store store;
16 |
17 | /**
18 | * Constructor for the SaleEndEvent
19 | *
20 | * @param product The product that the sale ended for
21 | * @param store The store where the sale ended
22 | */
23 | public SaleEndEvent(Product product, Store store) {
24 | if (product == null || store == null) {
25 | throw new IllegalArgumentException("Product and Store cannot be null");
26 | }
27 |
28 | this.product = product;
29 | this.store = store;
30 | }
31 |
32 | /**
33 | * Get the product that the sale ended for
34 | *
35 | * @return The product that the sale ended for
36 | */
37 | public Product getProduct() {
38 | return product;
39 | }
40 |
41 | /**
42 | * Get the store where the sale ended
43 | *
44 | * @return The store where the sale ended
45 | */
46 | public Store getStore() {
47 | return store;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Observers/src/main/java/com/comp301/a08shopping/events/SaleStartEvent.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a08shopping.events;
2 |
3 | import com.comp301.a08shopping.Product;
4 | import com.comp301.a08shopping.Store;
5 |
6 | /**
7 | * This event is fired when a sale starts for a product at a store. The event contains the product
8 | * that is on sale and the store where the sale is happening.
9 | */
10 | public class SaleStartEvent implements StoreEvent {
11 | /** The product that is on sale */
12 | private final Product product;
13 |
14 | /** The store where the sale is happening */
15 | private final Store store;
16 |
17 | /**
18 | * Constructor for the SaleStartEvent
19 | *
20 | * @param product The product that is on sale
21 | * @param store The store where the sale is happening
22 | */
23 | public SaleStartEvent(Product product, Store store) {
24 | if (product == null || store == null) {
25 | throw new IllegalArgumentException("Product and Store cannot be null");
26 | }
27 |
28 | this.product = product;
29 | this.store = store;
30 | }
31 |
32 | /**
33 | * Get the product that is on sale
34 | *
35 | * @return The product that is on sale
36 | */
37 | public Product getProduct() {
38 | return product;
39 | }
40 |
41 | /**
42 | * Get the store where the sale is happening
43 | *
44 | * @return The store where the sale is happening
45 | */
46 | public Store getStore() {
47 | return store;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Observers/src/main/java/com/comp301/a08shopping/events/StoreEvent.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a08shopping.events;
2 |
3 | import com.comp301.a08shopping.Product;
4 | import com.comp301.a08shopping.Store;
5 |
6 | /**
7 | * This interface represents an event that occurs at a store. This interface is implemented by
8 | * events that are fired when a product is out of stock or when a product is purchased.
9 | */
10 | public interface StoreEvent {
11 | /**
12 | * Get the product that is involved with this event
13 | *
14 | * @return The product that is involved with this event
15 | */
16 | Product getProduct();
17 |
18 | /**
19 | * Get the store where this event occurred
20 | *
21 | * @return The store where this event occurred
22 | */
23 | Store getStore();
24 | }
25 |
--------------------------------------------------------------------------------
/Observers/src/main/java/com/comp301/a08shopping/exceptions/OutOfStockException.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a08shopping.exceptions;
2 |
3 | /** This exception is thrown when a product is out of stock */
4 | public class OutOfStockException extends RuntimeException {
5 | /** Constructs a new OutOfStockException with a default message */
6 | public OutOfStockException() {}
7 |
8 | /**
9 | * Constructs a new OutOfStockException with a custom message
10 | *
11 | * @param message The custom message to include in the exception
12 | */
13 | public OutOfStockException(String message) {
14 | super(message);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Observers/src/main/java/com/comp301/a08shopping/exceptions/ProductNotFoundException.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a08shopping.exceptions;
2 |
3 | /** This exception is thrown when a product is not found */
4 | public class ProductNotFoundException extends RuntimeException {
5 | /** Constructs a new ProductNotFoundException with a default message */
6 | public ProductNotFoundException() {}
7 |
8 | /**
9 | * Constructs a new ProductNotFoundException with a custom message
10 | *
11 | * @param message The custom message to include in the exception
12 | */
13 | public ProductNotFoundException(String message) {
14 | super(message);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Observers/target/classes/com/comp301/a08shopping/Customer.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Observers/target/classes/com/comp301/a08shopping/Customer.class
--------------------------------------------------------------------------------
/Observers/target/classes/com/comp301/a08shopping/CustomerImpl.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Observers/target/classes/com/comp301/a08shopping/CustomerImpl.class
--------------------------------------------------------------------------------
/Observers/target/classes/com/comp301/a08shopping/Main.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Observers/target/classes/com/comp301/a08shopping/Main.class
--------------------------------------------------------------------------------
/Observers/target/classes/com/comp301/a08shopping/Product.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Observers/target/classes/com/comp301/a08shopping/Product.class
--------------------------------------------------------------------------------
/Observers/target/classes/com/comp301/a08shopping/ProductImpl.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Observers/target/classes/com/comp301/a08shopping/ProductImpl.class
--------------------------------------------------------------------------------
/Observers/target/classes/com/comp301/a08shopping/ReceiptItem.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Observers/target/classes/com/comp301/a08shopping/ReceiptItem.class
--------------------------------------------------------------------------------
/Observers/target/classes/com/comp301/a08shopping/ReceiptItemImpl.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Observers/target/classes/com/comp301/a08shopping/ReceiptItemImpl.class
--------------------------------------------------------------------------------
/Observers/target/classes/com/comp301/a08shopping/SaleSpawner.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Observers/target/classes/com/comp301/a08shopping/SaleSpawner.class
--------------------------------------------------------------------------------
/Observers/target/classes/com/comp301/a08shopping/Store.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Observers/target/classes/com/comp301/a08shopping/Store.class
--------------------------------------------------------------------------------
/Observers/target/classes/com/comp301/a08shopping/StoreImpl.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Observers/target/classes/com/comp301/a08shopping/StoreImpl.class
--------------------------------------------------------------------------------
/Observers/target/classes/com/comp301/a08shopping/StoreObserver.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Observers/target/classes/com/comp301/a08shopping/StoreObserver.class
--------------------------------------------------------------------------------
/Observers/target/classes/com/comp301/a08shopping/events/BackInStockEvent.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Observers/target/classes/com/comp301/a08shopping/events/BackInStockEvent.class
--------------------------------------------------------------------------------
/Observers/target/classes/com/comp301/a08shopping/events/OutOfStockEvent.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Observers/target/classes/com/comp301/a08shopping/events/OutOfStockEvent.class
--------------------------------------------------------------------------------
/Observers/target/classes/com/comp301/a08shopping/events/PurchaseEvent.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Observers/target/classes/com/comp301/a08shopping/events/PurchaseEvent.class
--------------------------------------------------------------------------------
/Observers/target/classes/com/comp301/a08shopping/events/SaleEndEvent.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Observers/target/classes/com/comp301/a08shopping/events/SaleEndEvent.class
--------------------------------------------------------------------------------
/Observers/target/classes/com/comp301/a08shopping/events/SaleStartEvent.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Observers/target/classes/com/comp301/a08shopping/events/SaleStartEvent.class
--------------------------------------------------------------------------------
/Observers/target/classes/com/comp301/a08shopping/events/StoreEvent.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Observers/target/classes/com/comp301/a08shopping/events/StoreEvent.class
--------------------------------------------------------------------------------
/Observers/target/classes/com/comp301/a08shopping/exceptions/OutOfStockException.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Observers/target/classes/com/comp301/a08shopping/exceptions/OutOfStockException.class
--------------------------------------------------------------------------------
/Observers/target/classes/com/comp301/a08shopping/exceptions/ProductNotFoundException.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Observers/target/classes/com/comp301/a08shopping/exceptions/ProductNotFoundException.class
--------------------------------------------------------------------------------
/Observers/target/test-classes/com/comp301/a08shopping/AppTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Observers/target/test-classes/com/comp301/a08shopping/AppTest.class
--------------------------------------------------------------------------------
/Singleton-Multiton-Factory/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 | 4.0.0
6 |
7 | com.comp301.a07pizza
8 | a07-pizza
9 | 1.0-SNAPSHOT
10 |
11 | a07-pizza
12 |
13 | http://www.example.com
14 |
15 |
16 | UTF-8
17 | 1.7
18 | 1.7
19 |
20 |
21 |
22 |
23 | junit
24 | junit
25 | 4.11
26 | test
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | maven-clean-plugin
36 | 3.1.0
37 |
38 |
39 |
40 | maven-resources-plugin
41 | 3.0.2
42 |
43 |
44 | maven-compiler-plugin
45 | 3.8.0
46 |
47 |
48 | maven-surefire-plugin
49 | 2.22.1
50 |
51 |
52 | maven-jar-plugin
53 | 3.0.2
54 |
55 |
56 | maven-install-plugin
57 | 2.5.2
58 |
59 |
60 | maven-deploy-plugin
61 | 2.8.2
62 |
63 |
64 |
65 | maven-site-plugin
66 | 3.7.1
67 |
68 |
69 | maven-project-info-reports-plugin
70 | 3.0.0
71 |
72 |
73 |
74 |
75 |
76 | org.apache.maven.plugins
77 | maven-compiler-plugin
78 |
79 | 8
80 | 8
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/Singleton-Multiton-Factory/src/main/java/com/comp301/a07pizza/Cheese.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a07pizza;
2 |
3 | /**
4 | * This class represents a cheese ingredient that can be used in a pizza. It is a subclass of
5 | * IngredientImpl.
6 | */
7 | public class Cheese extends IngredientImpl {
8 | /** Mozzarella cheese ingredient */
9 | public static final Cheese MOZZARELLA = new Cheese("mozzarella", true, false);
10 |
11 | /** Cheddar cheese ingredient */
12 | public static final Cheese BLEND = new Cheese("blend", true, false);
13 |
14 | /** Vegan cheese ingredient */
15 | public static final Cheese VEGAN = new Cheese("vegan", true, true);
16 |
17 | /**
18 | * Constructor for Cheese class
19 | *
20 | * @param name The name of the cheese
21 | * @param isVegetarian Whether the cheese is vegetarian
22 | * @param isVegan Whether the cheese is vegan
23 | */
24 | private Cheese(String name, boolean isVegetarian, boolean isVegan) {
25 | super(name, isVegetarian, isVegan);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Singleton-Multiton-Factory/src/main/java/com/comp301/a07pizza/Crust.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a07pizza;
2 |
3 | /**
4 | * This class represents a crust ingredient that can be used in a pizza. It is a subclass of
5 | * IngredientImpl.
6 | */
7 | public class Crust extends IngredientImpl {
8 | /** Hand-tossed crust ingredient */
9 | public static final Crust HAND_TOSSED = new Crust("hand-tossed", true, true);
10 |
11 | /** Thin crust ingredient */
12 | public static final Crust THIN = new Crust("thin", true, true);
13 |
14 | /** Deep dish crust ingredient */
15 | public static final Crust DEEP_DISH = new Crust("deep dish", true, true);
16 |
17 | /**
18 | * Constructor for Crust class
19 | *
20 | * @param name The name of the crust
21 | * @param isVegetarian Whether the crust is vegetarian
22 | * @param isVegan Whether the crust is vegan
23 | */
24 | private Crust(String name, boolean isVegetarian, boolean isVegan) {
25 | super(name, isVegetarian, isVegan);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Singleton-Multiton-Factory/src/main/java/com/comp301/a07pizza/Ingredient.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a07pizza;
2 |
3 | /** This interface represents an ingredient that can be used in a pizza */
4 | public interface Ingredient {
5 | /**
6 | * Getter method to retrieve the name of the ingredient
7 | *
8 | * @return The name of the ingredient
9 | */
10 | String getName();
11 |
12 | /**
13 | * Returns true only if the ingredient is a vegetarian option
14 | *
15 | * @return Whether the ingredient is vegetarian
16 | */
17 | boolean isVegetarian();
18 |
19 | /**
20 | * Returns true only if the ingredient is a vegan option
21 | *
22 | * @return Whether the ingredient is vegan
23 | */
24 | boolean isVegan();
25 | }
26 |
--------------------------------------------------------------------------------
/Singleton-Multiton-Factory/src/main/java/com/comp301/a07pizza/IngredientImpl.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a07pizza;
2 |
3 | /**
4 | * This class represents an ingredient that can be used in a pizza. It is a superclass of Crust,
5 | * Sauce, and Cheese.
6 | */
7 | public class IngredientImpl implements Ingredient {
8 | /** The name of the ingredient */
9 | private final String name;
10 |
11 | /** Whether the ingredient is vegetarian */
12 | private final boolean isVegetarian;
13 |
14 | /** Whether the ingredient is vegan */
15 | private final boolean isVegan;
16 |
17 | /**
18 | * Constructor for IngredientImpl class
19 | *
20 | * @param name The name of the ingredient
21 | * @param isVegetarian Whether the ingredient is vegetarian
22 | * @param isVegan Whether the ingredient is vegan
23 | */
24 | public IngredientImpl(String name, boolean isVegetarian, boolean isVegan) {
25 | this.name = name;
26 | this.isVegetarian = isVegetarian;
27 | this.isVegan = isVegan;
28 | }
29 |
30 | /**
31 | * Getter method to retrieve the name of the ingredient
32 | *
33 | * @return The name of the ingredient
34 | */
35 | @Override
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | /**
41 | * Returns true only if the ingredient is a vegetarian option
42 | *
43 | * @return Whether the ingredient is vegetarian
44 | */
45 | @Override
46 | public boolean isVegetarian() {
47 | return isVegetarian;
48 | }
49 |
50 | /**
51 | * Returns true only if the ingredient is a vegan option
52 | *
53 | * @return Whether the ingredient is vegan
54 | */
55 | @Override
56 | public boolean isVegan() {
57 | return isVegan;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/Singleton-Multiton-Factory/src/main/java/com/comp301/a07pizza/Pizza.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a07pizza;
2 |
3 | /** This interface represents a pizza that can be ordered from a pizza restaurant */
4 | public interface Pizza {
5 |
6 | /**
7 | * Returns true if the pizza consists entirely of vegetarian ingredients
8 | *
9 | * @return Whether the pizza is vegetarian
10 | */
11 | boolean isVegetarian();
12 |
13 | /**
14 | * Returns true if the pizza consists entirely of vegan ingredients
15 | *
16 | * @return Whether the pizza is vegan
17 | */
18 | boolean isVegan();
19 |
20 | /**
21 | * Getter method to get the price of the pizza
22 | *
23 | * @return The price of the pizza
24 | */
25 | double getPrice();
26 |
27 | /**
28 | * Getter method to get the size of the pizza
29 | *
30 | * @return The size of the pizza
31 | */
32 | Size getSize();
33 |
34 | /**
35 | * Getter method to get the type of sauce in the pizza
36 | *
37 | * @return The type of sauce in the pizza
38 | */
39 | Ingredient getSauce();
40 |
41 | /**
42 | * Getter method to get the type of cheese in the pizza
43 | *
44 | * @return The type of cheese in the pizza
45 | */
46 | Ingredient getCheese();
47 |
48 | /**
49 | * Getter method to get the type of crust in the pizza
50 | *
51 | * @return The type of crust in the pizza
52 | */
53 | Ingredient getCrust();
54 |
55 | /**
56 | * Getter method to get the toppings in the pizza
57 | *
58 | * @return The toppings in the pizza
59 | */
60 | Ingredient[] getToppings();
61 |
62 | /**
63 | * Getter method for all the ingredients in the pizza including toppings, cheese, crust, and sauce
64 | *
65 | * @return All the ingredients in the pizza
66 | */
67 | Ingredient[] getIngredients();
68 |
69 | /** This enum represents the size of the pizza */
70 | enum Size {
71 | /** Small size pizza */
72 | SMALL,
73 | /** Medium size pizza */
74 | MEDIUM,
75 | /** Large size pizza */
76 | LARGE
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/Singleton-Multiton-Factory/src/main/java/com/comp301/a07pizza/PizzaFactory.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a07pizza;
2 |
3 | import com.comp301.a07pizza.Pizza.Size;
4 |
5 | /** This class is a factory class that can be used to create different types of pizzas */
6 | public class PizzaFactory {
7 |
8 | /** Default constructor for PizzaFactory class */
9 | public PizzaFactory() {}
10 |
11 | /**
12 | * This method creates a cheese pizza with the specified size
13 | *
14 | * @param size The size of the pizza
15 | * @return The cheese pizza
16 | */
17 | public static Pizza makeCheesePizza(Size size) {
18 | // Example choice: Medium pizza with hand-tossed crust, tomato sauce, a blend of cheeses, and no
19 | // toppings for now
20 | return new PizzaImpl(size, Crust.HAND_TOSSED, Sauce.TOMATO, Cheese.BLEND, new Topping[] {});
21 | }
22 |
23 | /**
24 | * This method creates a Hawaiian pizza with the specified size
25 | *
26 | * @param size The size of the pizza
27 | * @return The Hawaiian pizza
28 | */
29 | public static Pizza makeHawaiianPizza(Size size) {
30 | // Example choice: Small pizza with hand-tossed crust, tomato sauce, a blend of cheeses, ham,
31 | // and pineapple
32 | return new PizzaImpl(
33 | size,
34 | Crust.HAND_TOSSED,
35 | Sauce.TOMATO,
36 | Cheese.BLEND,
37 | new Topping[] {Topping.HAM, Topping.PINEAPPLE});
38 | }
39 |
40 | /**
41 | * This method creates a meat lovers pizza with the specified size
42 | *
43 | * @param size The size of the pizza
44 | * @return The meat lovers pizza
45 | */
46 | public static Pizza makeMeatLoversPizza(Size size) {
47 | // Example choice: Large pizza with deep dish crust, tomato sauce, a blend of cheeses, and a
48 | // variety of meats
49 | return new PizzaImpl(
50 | size,
51 | Crust.DEEP_DISH,
52 | Sauce.TOMATO,
53 | Cheese.BLEND,
54 | new Topping[] {Topping.PEPPERONI, Topping.SAUSAGE, Topping.BACON, Topping.GROUND_BEEF});
55 | }
56 |
57 | /**
58 | * This method creates a veggie supreme pizza with the specified size
59 | *
60 | * @param size The size of the pizza
61 | * @return The veggie supreme pizza
62 | */
63 | public static Pizza makeVeggieSupremePizza(Size size) {
64 | // Example choice: Medium pizza with thin crust, tomato sauce, a blend of cheeses, and a variety
65 | // of vegetarian toppings
66 | return new PizzaImpl(
67 | size,
68 | Crust.THIN,
69 | Sauce.TOMATO,
70 | Cheese.BLEND,
71 | new Topping[] {
72 | Topping.SUN_DRIED_TOMATO, Topping.GREEN_PEPPER, Topping.MUSHROOMS, Topping.OLIVES
73 | });
74 | }
75 |
76 | /**
77 | * This method creates a daily special pizza
78 | *
79 | * @return The daily special pizza
80 | */
81 | public static Pizza makeDailySpecialPizza() {
82 | // Example choice: Large pizza with thin crust, pesto sauce, vegan cheese, and a variety of
83 | // vegetarian toppings
84 | return new PizzaImpl(
85 | Size.LARGE,
86 | Crust.THIN,
87 | Sauce.PESTO,
88 | Cheese.VEGAN,
89 | new Topping[] {
90 | Topping.TOMATO, Topping.GARLIC, Topping.SPINACH, Topping.ONION, Topping.JALAPENO
91 | });
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/Singleton-Multiton-Factory/src/main/java/com/comp301/a07pizza/Sauce.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a07pizza;
2 |
3 | /**
4 | * This class represents a sauce ingredient that can be used in a pizza. It is a subclass of
5 | * IngredientImpl.
6 | */
7 | public class Sauce extends IngredientImpl {
8 | /** Tomato sauce ingredient */
9 | public static final Sauce TOMATO = new Sauce("tomato", true, true);
10 |
11 | /** Barbecue sauce ingredient */
12 | public static final Sauce BARBECUE = new Sauce("barbecue", true, true);
13 |
14 | /** Pesto sauce ingredient */
15 | public static final Sauce PESTO = new Sauce("pesto", true, true);
16 |
17 | /** Alfredo sauce ingredient */
18 | public static final Sauce ALFREDO = new Sauce("alfredo", true, false);
19 |
20 | /** Ranch sauce ingredient */
21 | public static final Sauce RANCH = new Sauce("ranch", true, false);
22 |
23 | /**
24 | * Constructor for Sauce class
25 | *
26 | * @param name The name of the sauce
27 | * @param isVegetarian Whether the sauce is vegetarian
28 | * @param isVegan Whether the sauce is vegan
29 | */
30 | private Sauce(String name, boolean isVegetarian, boolean isVegan) {
31 | super(name, isVegetarian, isVegan);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Singleton-Multiton-Factory/src/main/java/com/comp301/a07pizza/Topping.java:
--------------------------------------------------------------------------------
1 | package com.comp301.a07pizza;
2 |
3 | /**
4 | * This class represents a topping ingredient that can be used in a pizza. It is a subclass of
5 | * IngredientImpl.
6 | */
7 | public class Topping extends IngredientImpl {
8 | /** Tomato topping ingredient */
9 | public static final Topping TOMATO = new Topping("tomato", true, true);
10 |
11 | /** Garlic topping ingredient */
12 | public static final Topping GARLIC = new Topping("garlic", true, true);
13 |
14 | /** Mushrooms topping ingredient */
15 | public static final Topping MUSHROOMS = new Topping("mushrooms", true, true);
16 |
17 | /** Pineapple topping ingredient */
18 | public static final Topping PINEAPPLE = new Topping("pineapple", true, true);
19 |
20 | /** Olives topping ingredient */
21 | public static final Topping OLIVES = new Topping("olives", true, true);
22 |
23 | /** Green pepper topping ingredient */
24 | public static final Topping GREEN_PEPPER = new Topping("green pepper", true, true);
25 |
26 | /** Spinach topping ingredient */
27 | public static final Topping SPINACH = new Topping("spinach", true, true);
28 |
29 | /** Onion topping ingredient */
30 | public static final Topping ONION = new Topping("onion", true, true);
31 |
32 | /** Jalapeno topping ingredient */
33 | public static final Topping JALAPENO = new Topping("jalapeno", true, true);
34 |
35 | /** Sun dried tomato topping ingredient */
36 | public static final Topping SUN_DRIED_TOMATO = new Topping("sun-dried tomato", true, true);
37 |
38 | /** Pepperoni topping ingredient */
39 | public static final Topping PEPPERONI = new Topping("pepperoni", false, false);
40 |
41 | /** Ground beef topping ingredient */
42 | public static final Topping GROUND_BEEF = new Topping("ground beef", false, false);
43 |
44 | /** Sausage topping ingredient */
45 | public static final Topping SAUSAGE = new Topping("sausage", false, false);
46 |
47 | /** Bacon topping ingredient */
48 | public static final Topping BACON = new Topping("bacon", false, false);
49 |
50 | /** Buffalo chicken topping ingredient */
51 | public static final Topping BUFFALO_CHICKEN = new Topping("buffalo chicken", false, false);
52 |
53 | /** Ham topping ingredient */
54 | public static final Topping HAM = new Topping("ham", false, false);
55 |
56 | /** Anchovies topping ingredient */
57 | public static final Topping ANCHOVIES = new Topping("anchovies", false, false);
58 |
59 | /**
60 | * Constructor for Topping class
61 | *
62 | * @param name The name of the topping
63 | * @param isVegetarian Whether the topping is vegetarian
64 | * @param isVegan Whether the topping is vegan
65 | */
66 | private Topping(String name, boolean isVegetarian, boolean isVegan) {
67 | super(name, isVegetarian, isVegan);
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/Singleton-Multiton-Factory/target/classes/com/comp301/a07pizza/Cheese.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Singleton-Multiton-Factory/target/classes/com/comp301/a07pizza/Cheese.class
--------------------------------------------------------------------------------
/Singleton-Multiton-Factory/target/classes/com/comp301/a07pizza/Crust.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Singleton-Multiton-Factory/target/classes/com/comp301/a07pizza/Crust.class
--------------------------------------------------------------------------------
/Singleton-Multiton-Factory/target/classes/com/comp301/a07pizza/Ingredient.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Singleton-Multiton-Factory/target/classes/com/comp301/a07pizza/Ingredient.class
--------------------------------------------------------------------------------
/Singleton-Multiton-Factory/target/classes/com/comp301/a07pizza/IngredientImpl.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Singleton-Multiton-Factory/target/classes/com/comp301/a07pizza/IngredientImpl.class
--------------------------------------------------------------------------------
/Singleton-Multiton-Factory/target/classes/com/comp301/a07pizza/Pizza$Size.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Singleton-Multiton-Factory/target/classes/com/comp301/a07pizza/Pizza$Size.class
--------------------------------------------------------------------------------
/Singleton-Multiton-Factory/target/classes/com/comp301/a07pizza/Pizza.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Singleton-Multiton-Factory/target/classes/com/comp301/a07pizza/Pizza.class
--------------------------------------------------------------------------------
/Singleton-Multiton-Factory/target/classes/com/comp301/a07pizza/PizzaFactory.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Singleton-Multiton-Factory/target/classes/com/comp301/a07pizza/PizzaFactory.class
--------------------------------------------------------------------------------
/Singleton-Multiton-Factory/target/classes/com/comp301/a07pizza/PizzaImpl$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Singleton-Multiton-Factory/target/classes/com/comp301/a07pizza/PizzaImpl$1.class
--------------------------------------------------------------------------------
/Singleton-Multiton-Factory/target/classes/com/comp301/a07pizza/PizzaImpl.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Singleton-Multiton-Factory/target/classes/com/comp301/a07pizza/PizzaImpl.class
--------------------------------------------------------------------------------
/Singleton-Multiton-Factory/target/classes/com/comp301/a07pizza/Sauce.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Singleton-Multiton-Factory/target/classes/com/comp301/a07pizza/Sauce.class
--------------------------------------------------------------------------------
/Singleton-Multiton-Factory/target/classes/com/comp301/a07pizza/Topping.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Singleton-Multiton-Factory/target/classes/com/comp301/a07pizza/Topping.class
--------------------------------------------------------------------------------
/Singleton-Multiton-Factory/target/test-classes/com/comp301/a07pizza/PizzaFactoryTest.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/Singleton-Multiton-Factory/target/test-classes/com/comp301/a07pizza/PizzaFactoryTest.class
--------------------------------------------------------------------------------
/img/adventure.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hoangsonww/Software-Design-Patterns/6d0784d1108ce1a638a585b9126bfff7d3e12b56/img/adventure.png
--------------------------------------------------------------------------------