Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ only Problem 3: Create a program (48 points) Sock drawers can either hold a max number of 3 socks (if the area of the

image text in transcribed

image text in transcribed

c++ only

Problem 3: Create a program (48 points) Sock drawers can either hold a max number of 3 socks (if the area of the bottom is less than 5 sq ft) or 5 socks (if the area of the bottom is greater than or equal to 5 sq ft). You can't add more socks if space is not available for all socks you are trying to add (see sample run). A user can give the sock colors and whether or not there is a hole in the sock (see sample run). Sock colors can then be shown if there is no hole in the sock. Given the following main, write a COMPLETE program that matches the sample run. You do not need to re-write main. You should make a Drawer class and a Sock class to keep sock information in (0 points if you do not create a Sock class that keeps sock information). int main(int argc, char **argv) { Drawer d1("Soheil", 3, 4); //creating a sock drawer, 3 is length, 4 is width (---10 points creating Drawer correctly) Drawer d2("Reehan", 2, 2); //creating a sock drawer, 2 is length, 2 is width d1.add_socks(2); //adding 2 socks to the sock drawer (--19 points for adding socks w/info) d1.add_socks(1); //adding 1 sock to the sock drawer d1.get_sock(1).show_colors(); //get a specific sock in the drawer (the first sock entered) and show colors if there is no hole (--19 points for showing colors if there is no hole) d1.get_sock(2).show_colors();//get a specific sock in the drawer (the second sock entered) and show colors if there is no hole d2.add_socks(4); //trying to add 4 socks to the sock drawer } Sample Run: Soheil's drawer created. Max number of socks allowed: 5 Reehan's drawer created. Max number of socks allowed: 3 Adding 2 sock(s) for Soheil! //adding 2 socks to the sock drawer --Adding sock 1: Enter sock colors (on one line): purple red This sock has 2 color(s). Does it have a hole in it? yes --Adding sock 2: Enter sock colors (on one line): yellow orange green This sock has 3 color(s). Does it have a hole in it? no 2 sock(s) added. You still have space for 3 sock(s). Adding 1 sock(s) for Soheil! //adding 1 sock to the sock drawer --Adding sock 1: Enter sock colors (on one line): blue This sock has 1 color(s). Does it have a hole in it? no 1 sock(s) added. You still have space for 2 sock(s). --Sorry, you can't see the colors because there is a hole in the sock. //can't see sock info wwwSock colors! //see sock info yellow orange green Sorry Reehan, no space for more socks! Max allowed: 3 //trying to add 4 socks to the sock drawer

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

Advances In Databases And Information Systems 22nd European Conference Adbis 2018 Budapest Hungary September 2 5 2018 Proceedings Lncs 11019

Authors: Andras Benczur ,Bernhard Thalheim ,Tomas Horvath

1st Edition

3319983970, 978-3319983974

Students also viewed these Databases questions

Question

Draft a business plan.

Answered: 1 week ago