Initial commit
This commit is contained in:
commit
a7bc29d67d
|
@ -0,0 +1,104 @@
|
|||
### Intellij ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff:
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/dictionaries
|
||||
|
||||
# Sensitive or high-churn files:
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.xml
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
|
||||
# Gradle:
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# CMake
|
||||
cmake-build-debug/
|
||||
|
||||
# Mongo Explorer plugin:
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
## File-based project format:
|
||||
*.iws
|
||||
|
||||
## Plugin-specific files:
|
||||
|
||||
# IntelliJ
|
||||
/out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# Ruby plugin and RubyMine
|
||||
/.rakeTasks
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
### Intellij Patch ###
|
||||
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
|
||||
|
||||
# *.iml
|
||||
# modules.xml
|
||||
# .idea/misc.xml
|
||||
# *.ipr
|
||||
|
||||
# Sonarlint plugin
|
||||
.idea/sonarlint
|
||||
|
||||
### Java ###
|
||||
# Compiled class file
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.war
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
### Kotlin ###
|
||||
# Compiled class file
|
||||
|
||||
# Log file
|
||||
|
||||
# BlueJ files
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
|
||||
# Package Files #
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
|
||||
### Scala ###
|
||||
|
||||
|
||||
# End of https://www.gitignore.io/api/java,scala,kotlin,eclipse,clojure,intellij
|
|
@ -0,0 +1,79 @@
|
|||
# Wallapop Backend Tech Test
|
||||
|
||||
Hello candidate!!
|
||||
|
||||
Welcome to Wallapop and its backend technical test
|
||||
|
||||
## Mars Rover refactoring kata
|
||||
|
||||
We need to improve the existing solution that translates commands sent from Earth to instructions that are understood by our Rover on Mars
|
||||
|
||||
Currently, the code is very complicated and tangled, so we'd like you to invest some time to clean it up
|
||||
|
||||
### Functional requirements
|
||||
```
|
||||
Given:
|
||||
- a two dimensional map of Mars
|
||||
- the initial starting point and direction of the Rover
|
||||
|
||||
When:
|
||||
- a command is received
|
||||
move `forward` or `backward` or rotate `left` or `right` (90 degrees)
|
||||
|
||||
Then:
|
||||
- move the Rover
|
||||
if the Rover disappears over the edge of the map (the horizon), continue on the other side (remember, Mars is a sphere)
|
||||
```
|
||||
|
||||
#### Bonus point
|
||||
|
||||
After ensuring that the functional requirements have been met, as a bonus point (not necessary but more than welcome), add a new feature:
|
||||
```
|
||||
Given:
|
||||
- a list of obstacles with their exact location
|
||||
|
||||
When:
|
||||
- Rover moves
|
||||
|
||||
And:
|
||||
- Rover encounters an obstacle
|
||||
|
||||
Then:
|
||||
- report back the obstacle. The Rover should stay in its previous position
|
||||
```
|
||||
|
||||
## Your solution
|
||||
|
||||
### Must (These points are mandatory)
|
||||
|
||||
- Fulfill the [Functional Requirements](#functional-requirements) stated in this readme.
|
||||
- Refactor the provided code, creating new classes, methods or whatever needed.
|
||||
- Use any JVM language but, if you want to use one other than Java, please convert the initial codebase to that language.
|
||||
- Be testable. This means that we should not need to run the main app in order to check that everything is working.
|
||||
- Be self compiled.
|
||||
- Be self executable.
|
||||
- Have a SOLUTION.md containing all the relevant features of your provided solution.
|
||||
|
||||
### Should (Nice to have)
|
||||
|
||||
- Fulfill the [Bonus point](#bonus-point) section of this readme.
|
||||
- Be bug free.
|
||||
- Use any design patterns you know and feel that help solve this problem.
|
||||
- Be extensible to allow the introduction of new features in an easy way.
|
||||
- Use any package dependency mechanism.
|
||||
|
||||
## Our evaluation
|
||||
|
||||
- We will focus on your design and on your own code over the usage of frameworks and libraries
|
||||
- We will also take into account the evolution of your solution, not just the delivered code
|
||||
- We will evolve your solution with feasible features and evaluate how complex it is to implement them
|
||||
|
||||
## How to do it
|
||||
|
||||
This project is a [Template Project](https://help.github.com/en/articles/creating-a-repository-from-a-template) that allows you to create a new project of your own based on this one
|
||||
|
||||
We would like you to maintain this new repository as private, and give access to `wallabackend` to evaluate it once you are done with your solution
|
||||
|
||||
Please, let us know as soon as you finish, otherwise we will not start the review
|
||||
|
||||
Thanks & good luck!!
|
|
@ -0,0 +1 @@
|
|||
# MY SOLUTION
|
|
@ -0,0 +1,81 @@
|
|||
import java.util.Scanner;
|
||||
|
||||
public class MarsRover {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Scanner reader = new Scanner(System.in);
|
||||
System.out.println("Insert horizontal map size:");
|
||||
int sizex = reader.nextInt();
|
||||
System.out.println("Insert vertical map size:");
|
||||
int sizey = reader.nextInt();
|
||||
|
||||
System.out.println("Insert horizontal initial rover position:");
|
||||
int roverx = reader.nextInt();
|
||||
System.out.println("Insert vertical initial rover position:");
|
||||
int rovery = reader.nextInt();
|
||||
System.out.println("Insert initial rover direction:");
|
||||
String roverz = reader.next(); //n = north, e = east, w = west, s = south
|
||||
|
||||
do {
|
||||
System.out.println("Insert command (f = forward, b = backward, l = turn left, r = turn right):");
|
||||
String command = reader.next();
|
||||
if (command.equals("f")) {
|
||||
if (roverz.equals("n")) {
|
||||
rovery += 1;
|
||||
}
|
||||
if (roverz.equals("w")) {
|
||||
roverx -= 1;
|
||||
}
|
||||
if (roverz.equals("s")) {
|
||||
rovery -= 1;
|
||||
}
|
||||
if (roverz.equals("e")) {
|
||||
roverx += 1;
|
||||
}
|
||||
}
|
||||
if (command.equals("b")) {
|
||||
if (roverz.equals("n")) {
|
||||
rovery -= 1;
|
||||
}
|
||||
if (roverz.equals("w")) {
|
||||
roverx += 1;
|
||||
}
|
||||
if (roverz.equals("s")) {
|
||||
rovery += 1;
|
||||
}
|
||||
if (roverz.equals("e")) {
|
||||
roverx -= 1;
|
||||
}
|
||||
}
|
||||
if (command.equals("l")) {
|
||||
if (roverz.equals("n")) {
|
||||
roverz = "w";
|
||||
}
|
||||
if (roverz.equals("w")) {
|
||||
roverz = "s";
|
||||
}
|
||||
if (roverz.equals("s")) {
|
||||
roverz = "e";
|
||||
}
|
||||
if (roverz.equals("e")) {
|
||||
roverz = "n";
|
||||
}
|
||||
}
|
||||
if (command.equals("r")) {
|
||||
if (roverz.equals("n")) {
|
||||
roverz = "e";
|
||||
}
|
||||
if (roverz.equals("e")) {
|
||||
roverz = "s";
|
||||
}
|
||||
if (roverz.equals("s")) {
|
||||
roverz = "w";
|
||||
}
|
||||
if (roverz.equals("w")) {
|
||||
roverz = "n";
|
||||
}
|
||||
}
|
||||
System.out.println(String.format("Rover is at x:%d y:%d facing:%s", roverx, rovery, roverz));
|
||||
} while (true);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue