Java代写 | COMP2100/6442 Lab 2 – Design Patterns

本次澳洲代写主要是Java设计模式的一个Lab

COMP2100/6442 Lab 2 – Design Patterns

Introduction

In this lab we will be using software design patterns to solve 3 different problems.

Design patterns can be thought of as ‘template solutions’ to recurring problems in software
design. However, a design pattern is not a bit of code you can copy and paste. It is a description
which provides you with an approach to solving a given problem.

You may find the website, ‘Refactoring Guru’, useful in the lab as it goes over each design
pattern. Use it, alongside your lecture slides, to refresh your memory if need be.
https://refactoring.guru/design-patterns

Introduction and Agenda

Task 1: Factory (1 mark)
Use a factory design pattern to create enemy (Vandral as we will call them)
battalions to fight against in a game!

Task 2: Observer (non-assessable but mandatory submission)
Use the observer design pattern to implement part of a COVID tracing
application.

Task 3: Singleton (1 mark)
Use the singleton design pattern to implement a printer queue.

Task 1: Factory – Description

In our video game, <insert name here>, the main character fights against the evil
Vandrals. A faction who wants to use Vandal magic to conquer the world and form
their own vision of a utopia.

There are different types of Vandrals that form battalions, even those with no
magical ability at all (who are looked down upon by their own faction). They are:

– Muggle: Lack magic. These make up most of their fighting force.
– Healer: Focuses on healing and strengthens the battalions as whole.
– Low-Archon: Somewhat adept at magic and trained to fight with it.
– High-Archon: Most adept at magic and the strongest of their fighters.

The difficulty of the game is set by the user and is either easy or hard.
Magic = Cool

Task 1: Factory – Your Job and Schema 1

You will need to create a factory to provide the number of each type of Vandral in a
battalion according to a given schema. That is, ‘spawning’ the correct numbers of each
type for the player to fight against.

Schema (easy difficulty):
For every even level, an additional muggle is spawned.
– So at level 2: 1 Muggle, level 4: 2 Muggles.

For every 20 Muggles, 3 Low-Archons or 1 High-Archon, an additional healer is spawned.
– So 20 Muggles, 6 Low-Archons: 3 Healers

For every 5 levels up until level 75, a Low-Archon is spawned.
Beyond 75, every 5 levels a High-Archon is spawned.
– So that at level 85: 15 Low-Archons and 2 High-Archons