Question: Create a class named Dust Create another class named DustpanDeclare two member variables. The first member variable is named count of type int. The second
Create a class named Dust Create another class named DustpanDeclare two member variables. The first member variable is named count of type int. The second variable is an array of type Dust named dustParticles Add a constructor with a single parameter of type int named size. The size is used to initialize the array with the given size. Add two methods. The first method named add expects a single argument of type DustIt adds the dust object to the next available position in the dustParticles array. Use the count variable to determine the next available spot and subsequently increment it Define a second method named empty It does not have any parameters. This method empties the dust Particles array by using a loop to set each element to null Create a class named Broom with a single method named sweep. The sweep method expects two parameters of type Dustpan and DustThe method adds the dust to the dustpan using the Dustpan's add method. Declare a main function In the main create a broom. Next, create a Dustpan of size Then create an array of Dust particles of size named dustpile. Use a foreach loop to iterate of the dustpile array. In each iteration call the sweep method of the broom to sweep up the dust. Finally, after the loop empty the dustpan using the same named method.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
