Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modify this code in Java by defining a new method named drawHouse, and calling this method from main. Your new method drawHouse draws the house

Modify this code in Java by defining a new method named drawHouse, and calling this method from main. Your new method drawHouse draws the house by invoking (calling) the given methods to draw a cone, and a box which are defined BELOW
 public class PrimitiveFiguresLibrary { // Draw a box. public static void drawBox () { System.out.println ("+----+"); System.out.println ("| |"); System.out.println ("| |"); System.out.println ("+----+"); } // end drawBox // Draw a cone. public static void drawCone () { System.out.println (" /\\ "); System.out.println (" / \\"); } // drawCone // Draw a V. public static void drawV () { System.out.println (" \\ /"); System.out.println (" \\/ "); } // end DrawV } // end PrimitiveFiguresLibrary 

THE ACTUAL CODE IS UNDER HERE

 public class DrawFiguresUpdated { // Draw figures. public static void main (String[] args) { drawDiamond(); // calling a method drawDiamond defined in the same class System.out.println (); drawX(); // calling a method drawX defined in the same class System.out.println (); // Draw 2 rockets, by calling the same method twice. // We are passing a String as a parameter to the drawRocket method. drawRocket(" "); drawRocket("This is a rocket"); } // end main // Draw a diamond. public static void drawDiamond() { drawCone(); drawV(); } // Draw an X. public static void drawX() { drawV(); drawCone(); } // Draw a rocket. // Parameter: extra, a String storing something extra to print after drawing the rocket. public static void drawRocket(String extra) { drawCone(); drawBox(); System.out.println ("| US |"); drawBox(); drawCone(); System.out.println(extra); // Print extra (a String received from calling method) } // Draw a cone. public static void drawCone() { System.out.println (" /\\ "); System.out.println (" / \\"); } // Draw a V. public static void drawV() { System.out.println (" \\ /"); System.out.println (" \\/ "); } // Draw a box. public static void drawBox() { System.out.println ("+----+"); System.out.println ("| |"); System.out.println ("| |"); System.out.println ("+----+"); } } // end DrawFigs 

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

Step: 3

blur-text-image

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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

Are robots going to displace all workers? Explain your answer.

Answered: 1 week ago