Share
Explore

Assignment: Earth

You will create a tactical simulation for the Earth-Romulan War, focusing on object-oriented design principles such as method overloading, method overriding, interfaces, and abstract classes.
The heuristics of High Cohesion and Low Coupling are always handy for designing communities of objects..
The assignment will provide a structural framework to create ship classes, implement a game engine, and model battles, resulting in a text-based representation of the space battle in the style of the classic 1980s Video Arcade Games.
image.png

megaphone

The Earth-Romulan War, also known as the Romulan War, was a significant conflict fought during the mid-22nd century between United Earth and the Romulan Star Empire.

This war shaped relations between the two worlds for centuries, leading to the establishment of a demilitarized Romulan Neutral Zone that persisted for a century after the treaty was signed.

Despite intense fighting and little knowledge gained about their elusive enemies, the war ultimately resulted in the formation of the Coalition of Planets in 2155.

The battles during this conflict were fierce, with Earth forces fighting alongside other planets against the resourceful Romulan Star Empire.

The war's outcomes had a lasting impact on interstellar politics and played a crucial role in the eventual founding of the United Federation of Planets.


Backstory:

It is the Earth Year 2154.

The fledging Unified Federation of Planets has had a disastrous first contact with a Warlike alien race called the Romulans, and a war broke out.
You had been tasked by the Federation High Command under the orders of Admiral Hiro Matsura with creating a war game simulation to provide tactical inputs to the War Planning Office on how to best deploy the Federation’s Resources.
Hiro Matsura was one of the first six captains within the , along with , , , Michael Hagedorn, and Connor Dane. Prior to that, he was a crucial fighter for  during the , where he helped end the .
image.png

Within the Federation Starfleet, he first commanded the Christopher-class ship, the , before being awarded captaincy of the first starship built for the new Starfleet: the . (
: )
megaphone

Here are the requirements for your Game:

Grading Rubric:

1. **Implementation of Inheritance (25 points):** - Correct implementation of inheritance by defining an abstract class `Starship` with appropriate properties and methods - 10 points - Creation of concrete subclasses `FederationStarship` and `RomulanStarship` that inherit from `Starship` and showcase inheritance in action - 15 points

2. **Utilization of Composition (20 points):** - Implementation of composition within the `main` function to create instances of the starships and orchestrate the battle simulation - 10 points - Proper utilization of composition to manage interactions and communication between different starship objects - 10 points

3. **Effective Use of Interfaces (20 points):** - Definition of interfaces, if applicable, to standardize behaviors and actions across different starship classes - 10 points - Implementation of interfaces in the classes to ensure adherence to shared behaviors and functionalities - 10 points

4. **Integration of Abstract Classes (15 points):** - Effective utilization of abstract classes to define common attributes and methods shared by all starships in the `Starship` class - 10 points - Clear demonstration of the advantages of using abstract classes in modeling the space warfare simulation - 5 points

5. **Code Quality and Documentation (20 points):** - Clean and organized code structure showcasing Kotlin best practices and conventions - 10 points - Adequate comments and documentation explaining the purpose, functionality, and interactions within the implemented classes and methods - 10 points

This assignment aims to reinforce students' understanding of object-oriented software design displaying high cohesion and low coupling by simulating a space battle game in Kotlin.

1. **Create Ship Classes:** - Define an abstract class `Starship` with properties such as name, shield strength, and phaser power. - Implement two concrete classes `FederationStarship` and `RomulanStarship` which inherit from the `Starship` class, with their custom attack methods.
2. **Implement Battle Mechanisms:** - Predetermine the victory conditions for the battle simulation, considering the depletion of shield strength as the crucial determinant of a ship's destruction.
3. **Develop the Game Engine:** - Design the main function to create instances of the Federation and Romulan starships and initiate the battle by calling their attack methods contiguously.
4. **Track Battle Outcomes:** - Determine the winning faction based on the remaining shield strength of the starships after the battle simulation.

megaphone
// Abstract class representing a starship abstract class Starship(val name: String, var shieldStrength: Int, val phaserPower: Int) { abstract fun attack(enemy: Starship) open fun takeDamage(damage: Int) { shieldStrength -= damage if (shieldStrength <= 0) { println("$name has been destroyed!") } } }
// Interface to represent defensive systems interface DefensiveSystem { val shieldStrength: Int fun reinforceShields() }
// Interface to represent communication protocols interface Communication { fun hail() }
// Class representing a Federation starship class FederationStarship(name: String, shieldStrength: Int, phaserPower: Int) : Starship(name, shieldStrength, phaserPower), DefensiveSystem, Communication { override fun attack(enemy: Starship) { println("$name fires phasers ($phaserPower) at ${enemy.name}.") enemy.takeDamage(phaserPower) } override fun reinforceShields() { // Code to reinforce shields println("$name is reinforcing shields.") } override fun hail() { // Code to initiate communication println("$name is initiating communication.") } }
// Class representing a Romulan starship class RomulanStarship(name: String, shieldStrength: Int, phaserPower: Int) : Starship(name, shieldStrength, phaserPower), DefensiveSystem { override fun attack(enemy: Starship) { println("$name fires phasers ($phaserPower) at ${enemy.name}.") enemy.takeDamage(phaserPower) } override fun takeDamage(damage: Int) { super.takeDamage(damage * 2) // Romulan ships have advanced shielding technology } override fun reinforceShields() { // Code to reinforce shields println("$name is reinforcing shields with advanced technology.") }
}

Task Guidelines:

1. **Ship Classes:** - Define the abstract class `Starship` with the properties `name`, `shieldStrength`, and `phaserPower`. Implement the `attack` method as an abstract function and `takeDamage` method to calculate the shield's depletion. - Create the `FederationStarship` and `RomulanStarship` classes that inherit from `Starship`. Implement the `attack` method for each class to simulate the phaser blasts on enemy ships.
2. **Battle Mechanisms:** - Decide the victory conditions for the battle simulation, considering depletion of shield strength as the elimination criterion for a ship.
3. **Game Engine:** - Develop the main function to create instances of the Federation and Romulan starships and initiate the battle by calling their attack methods in a sequence.
4. **Track Battle Outcomes:** - Determine the winning faction based on the remaining shield strength of the starships after the battle simulation.
**Submission Guidelines:** - Submit a file following standard naming conventions containing the implemented ship classes, battle simulations, and the outcome of the battle.
By following these guidelines, students will gain a hands-on understanding of using inheritance concepts to model complex scenarios such as a space battle, along with reinforcing their knowledge of Kotlin programming and object-oriented principles.
The resulting output is a text-based report on the battle results of the type that early combat officers would review on the primitive 22nd Century monochrome Starship CIS Combat information system control panels which were standard issue on early Star Fleet Line Ships.

This assignment provides students with a structured approach to implementing a space battle simulation while emphasizing the importance of inheritance and object-oriented principles.

Sample output:

In this space battle simulation, phaser power and shield energy is reported in measurements of Cochrane Quantum Flux units of space force energy.
The Cochrane Quantum Flux, named after the renowned physicist Zefram Cochrane, represents the quantum-mechanical flux of energy harnessed from the interaction of matter and antimatter in the Cochrane Time-Anti-Matter equation.
image.png
The Cochrane Quantum Flux embodies a measure of the energy released during the annihilation process of matter and antimatter particles, governed by the principles of quantum field theory. This process is orchestrated within the advanced reactors of space-faring vessels to generate immense power critical for interstellar propulsion, shield systems, and offensive armaments.
The unit is denoted symbolically as "CQF" and represents the amount of energy released when a single quantum-mechanical flux of matter comes into contact with its antimatter counterpart, obeying the equation: E = mc^2 - \frac {h}{t} where: - \(E\) is the energy release in Cochrane Quantum Flux - \(m\) is the mass of the matter or antimatter particle - \(c\) is the speed of light in a vacuum - \(h\) is the quantum-mechanical Planck constant - \(t\) is the duration of the interaction in Planck time units.

megaphone

Below is the regenerated sample output based on the provided Kotlin code:

--- Federation Fleet --- USS Enterprise - Shield: 100, Phaser Power: 30 USS Voyager - Shield: 120, Phaser Power: 25 USS Defiant - Shield: 90, Phaser Power: 40
--- Romulan Fleet --- IRW Warbird - Shield: 110, Phaser Power: 35 IRW Shadow - Shield: 100, Phaser Power: 30
--- Battle Commences --- USS Enterprise fires phasers (30) at IRW Warbird. IRW Warbird's shield absorbs 30 energy. Remaining shield energy: 80. USS Voyager fires phasers (25) at IRW Shadow. IRW Shadow's shield absorbs 25 energy. Remaining shield energy: 75. USS Defiant fires phasers (40) at IRW Shadow. IRW Shadow's shield absorbs 40 energy. Remaining shield energy: 60. IRW Warbird fires phasers (35) at USS Enterprise. USS Enterprise's shield absorbs 35 energy. Remaining shield energy: 65. IRW Shadow fires phasers (30) at USS Enterprise. USS Enterprise's shield absorbs 30 energy. Remaining shield energy: 35. USS Enterprise fires phasers (30) at IRW Warbird. IRW Warbird's shield absorbs 30 energy. Remaining shield energy: 50. USS Voyager fires phasers (25) at IRW Shadow. IRW Shadow's shield absorbs 25 energy. Remaining shield energy: 35. USS Defiant fires phasers (40) at IRW Shadow. IRW Shadow's shield absorbs 40 energy. Remaining shield energy: -5. IRW Shadow has been destroyed! --- End of Battle --- The Federation fleet emerges victorious! All Romulan ships have been eliminated.
In this output, the status of the ships before and after each attack is documented. Additionally, the destruction of the Romulan ship IRW Shadow is noted, resulting in the victory of the Federation fleet in the Earth-Romulan War simulation.
This output effectively captures the outcome of one possible battle simulation occurance.
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.