×
Reviews 4.9/5 Order Now

Create A Program to Create a Treasure Hunting Game in Java Assignment Solution

July 02, 2024
Sofiya Marcus
Sofiya Marcus
🇬🇧 United Kingdom
Java
PhD-qualified in Computer Science from the University of Bolton, I am Sofiya Marcus, a Java assignment expert with 7 years of experience. I specialize in delivering high-quality, tailored solutions for complex programming tasks.
Key Topics
  • Instructions
    • Objective
  • Requirements and Specifications
Tip of the day
Understand Haskell’s core concepts like pure functions, recursion, and immutability before diving into assignments. Use type annotations to catch errors early and test small components frequently. Tools like GHCi can help you experiment and debug interactively—perfect for refining functional logic.
News
In Spring 2025, IntelliJ IDEA 2025.2 EAP launched, bringing enhanced remote development, Spring ecosystem updates, Maven 4 support, and UI/HTTP client improvements—perfect for students working on cloud-based Java or Kotlin assignments

Instructions

Objective

Write a program to create a treasure hunting game in java language.

Requirements and Specifications

Program-to-treasure-hunting-game-in-java

Source Code

import java.io.IOException; import java.util.Arrays; public class FindPath { private Map pyramidMap; public FindPath(String filename) { try { pyramidMap = new Map(filename); } catch (IOException e) { throw new RuntimeException(e); } } public DLStack path() { DLStack stack = new DLStack<>(); Chamber start = pyramidMap.getEntrance(); int n = pyramidMap.getNumTreasures(); stack.push(start); start.markPushed(); int found = 0; while(!stack.isEmpty()) { Chamber top = stack.peek(); if (top.isTreasure()) { found++; if (found == n) { break; } } Chamber c = bestChamber(top); if (c == null) { top.markPopped(); stack.pop(); } else { stack.push(c); c.markPushed(); } } return stack; } public Map getMap() { return pyramidMap; } public boolean isDim(Chamber currentChamber) { if (currentChamber != null && !currentChamber.isSealed() && !currentChamber.isLighted()) { for (int i = 0; i<6; i++) { Chamber neighbor = currentChamber.getNeighbour(i); if (neighbor == null) { continue; } if (neighbor.isLighted()) { return true; } } } return false; } public Chamber bestChamber(Chamber currentChamber) { for (int i = 0; i<6; i++) { Chamber neighbor = currentChamber.getNeighbour(i); if (neighbor == null) { continue; } if (!neighbor.isMarked() && neighbor.isTreasure()) { return neighbor; } } for (int i = 0; i<6; i++) { Chamber neighbor = currentChamber.getNeighbour(i); if (neighbor == null) { continue; } if (!neighbor.isMarked() && neighbor.isLighted()) { return neighbor; } } for (int i = 0; i<6; i++) { Chamber neighbor = currentChamber.getNeighbour(i); if (neighbor == null) { continue; } if (!neighbor.isMarked() && isDim(neighbor)) { return neighbor; } } return null;

Similar Samples

Explore our extensive collection of programming homework samples at ProgrammingHomeworkHelp.com. From Java and Python to Machine Learning and more, our samples showcase our expertise in delivering top-notch solutions tailored to your assignments. Each example demonstrates our commitment to quality and accuracy, ensuring you receive the best assistance for your programming needs. Dive into our samples to see how we can help you excel in your coursework.