Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you assist me to figure out to make my code draw corridors between the rooms that requested from the user. My code does the

Can you assist me to figure out to make my code draw corridors between the rooms that requested from the user. My code does the rooms however, it doesn't make the corridors. Here is my code /* PERMITTED COMMANDS move, turnLeft, turnRight, treeLeft, treeRight, treeFront, onLeaf, putLeaf, removeLeaf, mushroomFront JAVA if, while, for */ class MyClara extends Clara { int roomWidth; int roomHeight; int numRooms; void run() { roomWidth = readInt("please enter width: "); roomHeight = readInt("please enter height: "); numRooms = readInt("please enter number of rooms: "); while (roomWidth > 18){ roomWidth = readInt("please re-enter width, maxWidth = 18 "); } while (roomHeight > 13){ roomHeight = readInt("please re-enter height, maxHeight = 13 "); } while ((numRooms * roomWidth) > 24 ) { numRooms = readInt("please re-enter number of rooms, The number of rooms you have entered, do not fit inside the house "); } for(int r= 1; r <= numRooms; r++){ drawRoom(); for(int y=1; y < roomWidth; y++){ move(); } } } void drawRoom(){ for(int h=1; h <= 2; h++){ dreawWidth(); drawHeight(); } } void dreawWidth(){ for( int i=1; i < roomWidth; i++){ checkingIfClaraOnLeaf(); move(); } turnLeft(); } void drawHeight(){ for(int j=1; j < roomHeight; j++){ checkingIfClaraOnLeaf(); move(); } turnLeft(); } void checkingIfClaraOnLeaf(){ if(!onLeaf()){ putLeaf(); } } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions