Submission 6: Interfaces

Objective: Utilize interfaces to define common behaviors across unrelated classes.

Instructions:

  1. Create an Interactable Interface:

    • Methods:

      • void interact(Player player)

  2. Implement Interactable in Classes:

    • NPC Class:

      • NPCs provide quests or information.

      • Implement interact(Player player) to start a dialogue.

    • Chest Class:

      • Represents treasure chests.

      • Implement interact(Player player) to open the chest and collect items.

"NPC" stands for "Non-Player Character."

An NPC is a character within the game that is not controlled by the player but can interact with the player in various ways. NPCs are used to enhance the game's narrative and interactivity. They can provide:

Quests or Missions: Assign tasks for the player to complete.

Information or Dialogue: Offer hints, backstory, or engage in conversations.

Trade Opportunities: Buy or sell items with the player.

Environmental Interaction: Affect the game world in ways that impact the player's experience.

  1. Update the Game World:

    • Create an ArrayList<Interactable> to manage various interactable objects in the game.

    • Place NPCs and Chests in different locations.

  2. Modify the Game Loop:

    • Allow the player to encounter and interact with different Interactable objects.

    • Use polymorphism to handle interactions seamlessly.

Deliverables:

  • Final source code files.

  • Screenshot of the program running

COSC-1437 / ITSE-2457 Computer Science Dept. - Author: Dr. Kevin Roark