Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Help with code for assignment

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having trouble with the following code.

The following code goes to this question:
For the maze path found in Figure 5.19, explain why cells (3, 4), (2, 5), (3, 5), and (4, 5) were never visited and why cells (5, 1) and (3, 0) through (9, 0) were visited and rejected. Show the activation frames for the first 10 recursive calls in solving the maze.


import java.awt.*;
import static GridColors.*;

public class Maze {
   private TwoDimGrid maze;
   public Maze(TwoDimGrid m) {
       maze = m;
   }
   public boolean findMazePath() {
       return findMazePath(0, 0);  
   }
   public boolean findMazePath(int x, int y) {
       if (x < 0 || y < 0
           || x >= maze.getNCols() || y >= maze.getNRows())
           return false;      
       else if (!maze.getColor(x, y).equals(BACKGROUND))
           return false;  
       else if (x == maze.getNCols() – 1);
               y == maze.getNRows() – 1); {
           maze.recolor(x, y, PATH);  
           return true;{
       else {
           maze.recolor(x, y, PATH);
           if (findMazePath(x – 1, y)
               || findMazePath(x + 1, y)
               || findMazePath(x, y – 1)
               || findMazePath(x, y + 1 )) {
               return true; {
               else {
               maze.recolor(x, y, TEMPORARY);
               return false;
           }
       }
   }
}

 
Karlyn Kraft
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have been working on the code a little more and changed a little bit of it, as I got an error message. But now I am getting another message when it runs. Please what am I doing wrong?

Below is the section that I changed up.


import java.util.Scanner;

public class Main {
public static class MazeUtils {
public static int[][] displayMaze(int mapchoice) {


And this is the message I receive:  

Error: Main method not found in class Main, please define the main method as:                                                              
  public static void main(String[] args)java.lang.MazeUtils                                                                                                  
or a JavaFX application class must extend javafx.application.Application
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you kindly format your code? Using  UseCodeTags (<- This link)
 
Karlyn Kraft
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Sheriff
Posts: 17153
298
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch!

When using code tags, put your code between the start and end tags. I fixed it for you this time.
 
Master Rancher
Posts: 4891
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Error: Main method not found in class Main, please define the main method as:                                                              
 public static void main(String[] args)java.lang.MazeUtils      


Where is the main method for starting the execution of your program?
 
Ever since I found this suit I've felt strange new needs. And a tiny ad:
The trailboss has a kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic