you are required to write
a program for a logic game called "Weaver's Island".
The object of the game is transport "cargo" (Monkeys, Coconuts, and
Alligators) from a land port to an island.
In order to "transport" the cargo, you will need a "ship" (a character array)
that allows you to "transport" only 1 item at a time.
MMMM MM /
MM M LAND /
\ +----------+ CC CCC / C = Coconuts
\ | DOCK | C CCCC / M = Monkeys
\ +--+-------+ +----+ A = Alligators
\ | AAAA AA /
\ | AAAAA /
+--+-----------+
~~~~~
~~ ~~ ~~~~~~~~~~~~~~~~
~~~~~~ +------+ ~~~
~~~~~~~ ~~~~~~~~~ | |
~~~~~~ ~~~~~~~~~ ~ | | ~~~~~~~
~~~ OCEAN ~~ | SHIP | ~~ ~~~
~~~~ ~~~~~~~~~ ~~~ | | ~~~~~~~~ _/)_ *
~~~ _/)_ * \ / ~~~
~~~~~~~~~~~ ~~~~~ \ /
~~~ ---- ~~~~~~~~~
~~~~~~ ~~ ~~~ ~~~~~~~~~
~~~~~~~~~~~~~~~~ _/)_ * ~~~~~ ~~~~~~
~~ ~~~ +----------------+
~~~~~~~ / \ ~~~~~~~
~~~~~~ / \ ~~
+------+ / ~~~
~~ / / ~ ~~~
/ +------------+ / ~~~~~
+ | WEAVER'S | / ~~ ~~~~ OCEAN ~~~~~~
~ | | ISLAND | / ~~~~~~~~~~~~~~~~~
+ +-----+------+ / ~~~~~~~~~~~~~~
~~ \ | / ~~~
+---------+------------+ ~~~~~~~
~~~ ~ ~~~ ~~~ ~~~~~~~~~~~~
~~~~~~ ~~~~~~ OCEAN ~~~~ ~~~~~~~ ~~~~
However, the game has the following rules:
1. Only 1 type of cargo can be transported at a time.
2. The Monkeys cannot be left alone with the Alligators
because the Alligators will eat the Monkeys.
3. The Monkeys cannot be left alone with the Coconuts, because
the Monkeys will eat the Coconuts.
SPECIFICATIONS (REQUIREMENTS):
------------------------------ -----------
In order to complete this assignment, you will be required
to complete the code for the following functions that make use of
characters strings.
Recall:
void loadCargo(char ship[ ], char land[ ], char type);
void transportCargo(char ship[ ], char destination[ ], int dir);
void loadCargo(char ship[ ], char land[ ], char type);
For example:
char letter1 = 'M';
char letter2;
letter2 = letter1 + 32; /* letter2 now contains 'm' */
OUTPUT:
#include <stdio.h>
#include <string.h>
void loadCargo(char ship[ ], char land[ ], char type);
void transportCargo(char ship[ ], char destination[ ], int dir);
void printRegion(char region[ ], int dir);
int main( ) {
char land[121] = " CCCCCCCCAAAAAAAAAAAAAAAAAAAAAM MMMM";
char island[121] = "";
char ship[121] = "";
int i;
/*
YOUR CODE HERE...
YOUR CODE HERE...
*/
printRegion(land, 1);
printRegion(island, 0);
return 0;
}
void loadCargo(char ship[ ], char land[ ], char type) {
/* YOUR CODE HERE... */
}
void transportCargo(char ship[ ], char destination[ ], int dir) {
/* YOUR CODE HERE... */
}
void printRegion(char region[ ], int dir) {
int i;
printf("%s: ", dir == 1 ? "LAND" : "ISLAND");
for(i=0; region[i] != '\0'; i++) {
printf("%c", region[i]);
}
printf("\n");
}
would display:
LAND: ccccccccaaaaaaaaaaaaaaaaaaaaam mmmm
ISLAND: mmmmmAAAAAAAAAAAAAAAAAAAAACCCC CCCCMMMMM
Hello there,
I have seen your project's description and I am pretty sure that I can complete this task within the given time frame. I can make Weaver's Island with all your specified requirements.
So let's talk about your project. Open chat to discuss it further. Thanks