# **AndyBot**
:::danger
<b>Due: Wednesday, September 18th, 2024 at 11:59pm ET</b>
:::
**<font color="#ff0000">There is no late deadline for this project. That means anything submitted past the above date will receive no credit.</font>**
Watch the demo [here](https://www.youtube.com/watch?v=HWcQmAsB5xU)!
# Assignment Roadmap
:::info
[Silly Premise](#Silly-Premise)
[Collaboration Policy Reminder](#Collaboration-Policy-Reminder)
[New Concepts Covered](#New-Concepts-Covered)
[Helpful Resources](#Helpful-Resources)
[Installing Stencil Code](#Installing-Stencil-Code)
[Grading](#Grading)
### **[FUNCTIONALITY](#Functionality)**
[Coding Incrementally](#Coding-Incrementally)
[Compiling and Running Your Code](#Compiling-and-Running-Your-Code)
[Suggested Order for Incremental Coding](#Suggested-Order-for-Incremental-Coding)
[Saving Your Work on GitHub](#Saving-Your-Work-on-Github)
[Minimum Functionality Requirements](#Minimum-Functionality-Requirements)
[Full Functionality Requirements](#Full-Functionality-Requirements)
### **[IMPLEMENTATION](#Implementation)**
[Support Code and Javadocs](#Support-Code-and-Javadocs)
[How to Read the Javadocs](#How-to-Read-the-Javadocs)
[Stencil Code vs. Support Code](#Stencil-Code-vs.-Support-Code)
### **[DESIGN](#Design)**
[Calling Methods](#Calling-Methods)
[Nesting Methods](#Nesting-Methods)
### **[STYLE](#Style)**
### **[HANDING IN](#Handing-In)**
[README](#README)
[Handin](#Handin)
:::
## Silly Premise
AndyBot is traveling to Omashu. On his journey, he encounters a band of traveling musicians who tell him of a short cut: a secret network of tunnels called The Cave of Two Lovers. After a few minutes, AndyBot finds himself lost in the vast tunnels. Help AndyBot navigate through the many twists and turns of the Secret Tunnel, unclock the exit door, and reach Omashu.
<img style="display: block; margin: auto;" src="https://hackmd.io/_uploads/By5mWrM30.gif" alt="AndyBot Image">
Reference: Avatar the Last Airbender, Nickelodeon
## Collaboration Policy Reminder
If you ever have questions about [the collaboration policy](https://docs.google.com/document/d/10rbbd0Y6s1JUzPe8VmoWcL_Mz26XczX-i7p2LUFa9vc/edit?usp=sharing), refer to the collaboration policy or ask a TA!
<img style="display: block; margin: auto; padding-top: 15px;" src=https://hackmd.io/_uploads/BkSOpo1nC.png width=600px>
## New Concepts Covered
* Reading JavaDocs
* Parameters
* Nesting methods
## Helpful Resources
* This handout!
* [Java Syntax Code Along](https://www.youtube.com/watch?v=G3QjKmxhl1E)
* [AndyBot Demo](https://youtu.be/HWcQmAsB5xU)
* [AndyBot JavaDocs](http://cs.brown.edu/courses/cs015/javadocs/cs15/prj/andyBotSupport/package-summary.html)
* [Calling + Defining Methods Lecture](https://cs.brown.edu/courses/cs015/lecture/pdf/CS15.Lecture_2_Calling_And_Defining_Methods.9.10.24.pdf) and [Parameters + Math Lecture](https://cs.brown.edu/courses/cs015/lecture/pdf/CS15.Lecture_3_Parameters_and_Math.9.12.24.pdf)
* [Project Setup Video](https://www.youtube.com/watch?v=qjBdrj-ivbY&t=96s)
* [Style Guide](https://docs.google.com/document/d/1olSJxbrhuIystA_kVbmKu4V8JfN7HE-eDzM5blkoeFw/edit)
* [GitHub Guide](https://docs.google.com/document/d/1tSxfUIn-Ro6Pr1X4y21BbYKdsiK-nlWW3pGDfyh7SQ8/edit)
* [Understanding Support Code Handout](https://docs.google.com/document/d/1mWR-huHi6PqizbFlghQrRXGnyJRZaClu_pkY7PFQYqY/edit#heading=h.ac49hi2p43ww)
* [README Guide](https://docs.google.com/document/d/1QJPit-_8ZC3r4l_f5F3ydMK34-NchBYgwtm0c21iwsU/edit)
* [Project Hours](https://cs.brown.edu/courses/csci0150/) and [Ed](https://edstem.org/us/courses/63887/discussion/)
## Installing Stencil Code
Click **[here](https://classroom.github.com/a/ie2ZRHjj)** to get the stencil from GitHub - refer to the [CS15 GitHub Guide](https://docs.google.com/document/d/1tSxfUIn-Ro6Pr1X4y21BbYKdsiK-nlWW3pGDfyh7SQ8/edit) for help with GitHub and GitHub Classroom, but here is a summary:
1. Once you have the URL of your personal GitHub repository, open the IntelliJ terminal.
2. Use the command **`cd src`** to move into the **`src`** folder
3. Use the command **`git clone <URL>`**
4. You’ll need to rename the folder from **`andybot-<yourGitHubLogin>`** to just **`andybot`**. You will have issues running your code until you make the change.
## Grading
The grade for this assignment will be determined by [functionality](#Functionality) (60%), [design](#Design) (25%), and [style](#Style) (15%).
---
# Functionality
For this assignment, you'll navigate a **`CS15Robot`** called AndyBot through a maze—surpassing daunting obstacles such as walls and an especially trifling roadblock. Your task is to call move methods on the AndyBot to move it out of the maze (off-screen) so the “Winner!” message appears.
1. Don't try to move your bot into a wall because it will cause AndyBot to get stuck.
2. At the end of the maze, on the square right before the gray door, you’ll encounter the roadblock. To pass it, AndyBot will have to submit a secret password (it will be a number). Unfortunately, this password will be different every time you run the program. Luckily, the maze will help you if you call the right methods
:::spoiler **Hint**
Think about who has this information when calling the method!
:::
<p></p>
3. Once AndyBot is on the last orange square, it may enter the password. If AndyBot tries to enter the password before it reaches the square, the password will not be accepted as that is too early to input it.
4. Once AndyBot submits the correct password, make sure to move your AndyBot upwards 2 more steps and off-screen to victory. The bottom screen should read “WINNER!”
5. A successful program will match the pattern shown below:
<!-- <img src="" alt="Step 1" width="200"> -->

We're providing you with a support class, **`CS15Robot`**, which is code we’ve already written for you (and you can use). We've also provided a stencil class, **`MazeSolver`**, for you to fill in with all your code. Before you start programming, look over the slides from the first three lectures. Make sure you understand objects and classes, and how they look in code.
## Coding Incrementally
After you’ve watched the demo, <u>*thoroughly read this handout and the [Javadocs](http://cs.brown.edu/courses/cs015/javadocs/cs15/prj/andyBotSupport/package-summary.html) in full*</u> to make sure you understand the project. Once you’re ready, start coding! It is important to code **incrementally**, meaning you completely accomplish one logical task before moving on to the next one.
### Compiling and Running Your Code
Refer to the [Rattytouille handout](https://hackmd.io/@Fall2024-CS15/Sy5evK8NA) for more detailed instructions on how to compile and run your code. Here is a summary:
* In the IntelliJ terminal, navigate to the folder where this project is stored with the **`cd`** command.
* To compile your code, type **`javac *.java`** in your terminal
* After you compile your code successfully, move back to the **`src`** directory
* **`(cd ..)`**. Then run your code by typing **`java andybot.App`**
* Each time you want to recompile and run your code, move back to the **`andybot`** folder with **`cd andybot`**, then repeat the 2 steps above.
* Hint: If you’re not sure which folder you’re in, use the **`pwd`** (Mac) / **`cd`**(Windows) command.
### Suggested Order for Incremental Coding
**Step 1.** Navigate to the last orange square
**Step 2.** Get past the roadblock
**Step 3.** Move up 2 more spaces to get off the board
### Saving Your Work on Github
Refer to the [CS15 GitHub guide](https://docs.google.com/document/d/1tSxfUIn-Ro6Pr1X4y21BbYKdsiK-nlWW3pGDfyh7SQ8/edit?usp=sharing) for more detailed instructions on how to save snapshots of your work to GitHub. We recommend doing this around once an hour to make sure you’re maintaining a copy of your code. Here is a summary:
1. Move into the **`andybot`** directory
2. **`git add -A`**
3. **`git commit -m “<some descriptive message>”`**
4. **`git push`**
5. Repeat!
## Minimum Functionality Requirements
MF Policy Summary: *In order to pass CS15, you will have to meet minimum functionality requirements for all projects. If you don’t meet them the first time around, you may hand the project in again until you succeed, but you will keep your original grade. MF requirements are **not** the same as the requirements for full credit on the project. You should attempt the full requirements on every project to keep pace with the course material. An ‘A’ project would meet all of the requirements on the handout and have good design and code style.*
In order to meet MF for AndyBot:
1. AndyBot must move to the roadblock.
## Full Functionality Requirements
Beyond the minimum functionality requirements, the rest of the functionality grade will depend on the following criterion:
* AndyBot passes the roadblock and moves off screen, with the “Winner!” message appearing
* No other minor bugs
---
# Implementation
This section of the handout has valuable details to help with the actual implementation of the assignment. Read it thoroughly for lots of helpful hints!
## Support Code and Javadocs
In many early CS15 projects, you will be using support code. In a nutshell, this means that we have predefined some classes for you, and you can call methods on instances of those classes. In this project, for example, there is a support code class called **`CS15Robot`**. You don't have to edit or even see the definition for this class. However, you can tell an instance of the **`CS15Robot`** class, which is passed into **`MazeSolver`** as a parameter called **`andyBot`**, to do things by calling its methods.
In order to see which methods are contained in the **`CS15Robot`** class, please refer to the [Javadocs](http://cs.brown.edu/courses/cs015/javadocs/cs15/prj/andyBotSupport/package-summary.html). Javadocs is a website that contains documentation of existing Java methods. For CS15, we have our own Javadocs that give information about the classes and methods that you’ll need to use for the first few projects of the course.
The Javadocs have crucial information to understand this assignment - in fact, you will not be able to complete the assignment without some of that information, so be sure to read them carefully.
CS15's philosophy is to give you some “magic” (i.e. support code) in the beginning so that you can create rich, graphical applications in your very first assignments. This makes the projects fun and rewarding from the get-go. As you progress through the semester, however, we'll gradually peel away the magic. By the time you do the Cartoon project, you'll be using no CS15 support code!
### How to Read the Javadocs
First, spend 5 minutes clicking through the andyBotSupport in the JavaDocs to get a sense of what it all means - it’s a lot to take in! Notice that there is one page for each class. Also be sure to scroll the whole way down each page. There are summaries of the method at the top, like this:

But below there is more detail, some of which will be crucial to solving AndyBot! So just be sure you read the whole thing.

## Stencil Code vs. Support Code
We provide you with both stencil code and support code.
**“Stencil” code** or “skeleton” code refers to the classes that are the shell of the program. **You should never delete code that was given to you as stencil code — it is there to help you!** You will be adding your own code to the stencil code that we provide. For this project, the stencil class that you should fill out is **`MazeSolver`**.
On the other hand, **support code** is code that you must use, but will not be able to see or add to. In other words, we’ve written methods for you that you should call! Some classes (like **`MazeSolver`**) have support code methods that you should call from within those classes (using the **`this`** keyword!). There are also entire support classes that are entirely invisible to you, but you will have to use those objects (like **`CS15Robot`**)! For this project, **`MazeSolver`** has some support code methods, but **`CS15Robot`** is an invisible support class.
---
# Design
For this assignment, your “design” grade will be based on your code implementation, such as proper use of nesting method calls. This section has some helpful reminders to guide your implementation.
## Calling Methods
When calling methods, we must always specify a receiver, or the object that should carry out a command. For example, if we’ve defined a **`Waiter`** class with an **`addPepper`** method, perhaps a **`Customer`** wants to ask their waiter to add pepper to their salad like this:
```
// this method is in the Customer class
public void eatSalad(Waiter myWaiter) {
myWaiter.addPepper();
// code to eat the salad
}
```
This example is like saying “Hey waiter! Add pepper please!”
Or maybe the waiter knows to always add pepper to salads before serving them, so the waiter may have code like this:
```
// this method is in the Waiter class
public void serveSalad() {
this.addPepper();
// code to serve the salad
}
```
This example is like saying “Hey me! Add pepper please!”
Notice that we’ve called the same method **`addPepper`** in two different contexts, but when we call the method from the same class where the method is defined (in this case **`Waiter`**), we use the **`this`** keyword.
## Nesting Methods
Nesting methods is putting one method call inside of another. This is useful when we want to pass the return value of a method into another method as an argument. For example, let’s say a waiter must set a table at a restaurant. First, they will need to know how many guests to set the table for!
```
//this method is in the Waiter class
public void setTable(int numberOfCustomers) {
this.addForks(numberOfCustomers);
this.addKnives(numberOfCustomers);
this.addPlates(numberOfCustomers);
}
```
The waiter does not know how many people are going to be sitting at the table, but the hostess does!
```
//this method is in the Hostess class
public int getNumberOfCustomers() {
return 5;
}
```
In the **`Restaurant`** class, we need to call the **`setTable`** method to make sure the customers have everything they need at their table. We can use nesting to pass the return value of **`getNumberOfCustomers`** into **`setTable`** as an argument!
```
//this code is in the Restaurant class
waiter.setTable(hostess.getNumberOfCustomers());
```
**`hostess.getNumberOfCustomers()`** will return 5, so 5 will be passed as the argument, just like if we wrote **`waiter.setTable(5)`**. Then the waiter will set the table with 5 forks, 5 knives, and 5 plates!
---
# Style
Refer to the [CS15 Style Guide](https://docs.google.com/document/d/1olSJxbrhuIystA_kVbmKu4V8JfN7HE-eDzM5blkoeFw/edit) for the specific style guidelines along which your code will be graded for the “style” portion. For this assignment specifically, be sure to use (when appropriate) the **`this`** keyword, remove **`TODO`** comments, and have proper indentation.
# Handing In
## README
In CS15, you’re required to hand in a README file (must be named README) that documents any notable design choices or known bugs in your program. Remember that clear, detailed, and concise READMEs best allow your TAs to understand your thought process, helping them better understand your project as well. We will be providing a file for your README for AndyBot, but will expect you to create your own in subsequent projects.
For this project in the “Design Choices” section of the README, please explain the concept of nesting and how you used it in this project. In the future, please refer to the [README guide](https://docs.google.com/document/d/1QJPit-_8ZC3r4l_f5F3ydMK34-NchBYgwtm0c21iwsU/edit?usp=sharing) for information on what information your README should contain and how you should format it.
At the bottom of your README, add the approximate number of hours you spent on this project. This will be used only to average how long the projects are taking students this semester, and it is completely anonymous.
## Handin
This assignment must be submitted no later than **11:59pm EST** on **Wednesday, September 18th**. There is no late handin for this assignment.
To hand in your assignment, follow these steps:
1. In a terminal, move into the andybot folder as if you were about to compile your code
2. Type the command **`rm *.class`** (**`del *.class`** for Windows) This will remove the **`.class`** files that are created when compiling so that your submission only includes **`.java`** code files.
3. [Add, commit, and push your code to GitHub](#Saving-Your-Work-on-Github)
4. In the submission for AndyBot on Gradescope, click on Github
5. Select your **AndyBot** repository and the **main** branch
6. Upload!
You can submit as many times as you want prior to the deadline, and only your most recent handin will be graded. If you handin before the deadline and again after the deadline, the submission will be counted as late and will receive no credit.
**<font color="#ff0000">Please do not include any identifying information on your handin (name, login, Banner ID) as we grade anonymously. Including identifying information will result in a deduction from your assignment.** </font>