Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client-b.txt #52

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions client-b.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,44 @@
# Client Task B #
# Add your pseudocode to this file below this line: #
# ------------------------------------------------- #
START
// Define the warehouse layout as a grid
DEFINE warehouseGrid as a 2D array of locations
SET currentPosition = (startX, startY) // Starting coordinates of the customer
SET targetLocation = (targetX, targetY) // Target coordinates to find
SET found = FALSE

PRINT "Welcome to the Find the Spot application!"
PRINT "You can move north, south, east, or west to find your location."

// Loop until the customer finds the target location
WHILE found = FALSE
PRINT "You are currently at (" + currentPosition.x + ", " + currentPosition.y + ")"
PRINT "Enter your move (north, south, east, west):"
SET userMove = GET_USER_INPUT()

// Update the current position based on user input
IF userMove = "north" THEN
SET currentPosition.y = currentPosition.y + 1
ELSE IF userMove = "south" THEN
SET currentPosition.y = currentPosition.y - 1
ELSE IF userMove = "east" THEN
SET currentPosition.x = currentPosition.x + 1
ELSE IF userMove = "west" THEN
SET currentPosition.x = currentPosition.x - 1
ELSE
PRINT "Invalid move. Please enter north, south, east, or west."
CONTINUE // Skip the rest of the loop and ask for input again
END IF

// Check if the current position matches the target location
IF currentPosition = targetLocation THEN
PRINT "Congratulations! You have found the location at (" + targetLocation.x + ", " + targetLocation.y + ")"
SET found = TRUE
ELSE
PRINT "Keep looking! You are still searching."
END IF
END WHILE

END