Question

Create a program named TilingDemo that instantiates an array of 10 Room objects and demonstrates its...

Create a program named TilingDemo that instantiates an array of 10 Room objects and demonstrates its methods. The Room constructor requires parameters for length and width fields; use a variety of values when constructing the objects. The Room class also contains a field for floor area of the Room and number of boxes of tile needed to tile the room. Both of these values are computed by calling private methods. A room requires one box of tile for every 12 full square feet plus a box for any partial square footage over 12, plus one extra box for waste from irregular cuts. In other words, a 122 square foot room requires 12 boxes—10 boxes for the first 120 square feet, 1 box for the 2 extra square feet over 120, and 1 box for waste. Include read-only properties to get a Room’s values."

The solution should be a console application in C#. Thank you.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code will be like:

using System;

namespace PaintingDemo
{
class Program
{
static void Main(string[] args)
{
Room obj1 = new Room(5, 7, 20);
Room obj2 = new Room(2, 7, 20);
Room obj3 = new Room(3, 7, 20);
Room obj4 = new Room(4, 7, 20);
Room obj5 = new Room(7, 7, 20);
Room obj6 = new Room(8, 7, 20);
Room obj7 = new Room(9, 7, 20);
Room obj8 = new Room(10, 7, 20);

Console.ReadLine();
}
}
class Room
{
public int length;
public int width;
public int height;


public Room(int len, int width,int heigh)
{
this.length=len;
this.width=width;
this.height=heigh;

wallArea();
Console.WriteLine("Number of gallons of paint needed are "+gallonsOfpaint());

}

private double wallArea()
{
return length width height;
}

private double gallonsOfpaint()
{

double paintCount = wallArea()/350;


return Math.Ceiling(paintCount);
}
}
}

Add a comment
Answer #2

//the above screenshot only shows the first 5 rooms out of 10

using System;

namespace TilingDemo
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            //initialises an array of rooms
            Room[] rooms = new Room[10];
            Random r = new Random ();

            //iterates over the array
            for (int i = 0; i < 10; i++)
            {    
                //initialises rooms with random integer vaule <100
                rooms [i] = new Room (r.Next (100),r.Next(100));
            
            }

            //iterates over the array and prints all the instatcfes
            for (int i = 0; i < 10; i++) {

                Console.WriteLine ("\nRoom" + i);
                Console.WriteLine (rooms [i].ToString() );
            }
        }
    }

    class Room
    {
        int length;
        int width;
        int area;
        int boxoftiles;

        //the required constructor
        public Room(int length, int width)
        {
            this.length = length;
            this.width = width;
            this.area = calculateArea();
            this.boxoftiles = calculateBoxes ();
        }
                        
        override public String ToString()
        {
            String str="length: "+this.length;
            str = str + "\nwidth: " + this.width;
            str = str + "\narea: " + this.area;
            str = str + "\nBOxes required: " + this.boxoftiles;
            return str;

        }


        int getArea(){
            return this.area;
        }
        int getBoxes()
        {
            return this.boxoftiles;
        }

        //returns the area by simply multipling width to length
        private int calculateArea()
        {
            return this.width* this.length;
        }

        //calcultes the number of boxes required
        private int calculateBoxes()
        {
            int boxes = this.area / 12;
            //if the area is divisible by 12 then return the number of boxes
            if (this.area%12 == 0) {
                return boxes;
            
            } else {
                //if not divisible add 1
                return boxes + 1;
            }
        }

    }
}

Add a comment
Know the answer?
Add Answer to:
Create a program named TilingDemo that instantiates an array of 10 Room objects and demonstrates its...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • summatize the following info and break them into differeng key points. write them in yojr own...

    summatize the following info and break them into differeng key points. write them in yojr own words   apartus 6.1 Introduction—The design of a successful hot box appa- ratus is influenced by many factors. Before beginning the design of an apparatus meeting this standard, the designer shall review the discussion on the limitations and accuracy, Section 13, discussions of the energy flows in a hot box, Annex A2, the metering box wall loss flow, Annex A3, and flanking loss, Annex...

  • summarizr the followung info and write them in your own words and break them into different...

    summarizr the followung info and write them in your own words and break them into different key points.   6.5 Metering Chamber: 6.5.1 The minimum size of the metering box is governed by the metering area required to obtain a representative test area for the specimen (see 7.2) and for maintenance of reasonable test accuracy. For example, for specimens incorporating air spaces or stud spaces, the metering area shall span an integral number of spaces (see 5.5). The depth of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT