Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Write a program that creates a set of electronic components from a common base class. In the main function create an instance of the

C++

Write a program that creates a set of electronic components from a common base class.

In the main function create an instance of the classes Wire, Component, Battery, Switch. Light, Resistor, and Capacitor classes. Assign each instance some non-default value. Using each of the overloaded << operator functions print out each instance

Sample Program I/O: Wire Instance: length = 2 Component Instance : type = something Battery Instance: type = battery, voltage = 9V, current = 2.5A Switch Instance: type = switch, state = closed Light Instance: type = light, state = on Resistor Instance: type = resistor, resistance = 210K Ohms Capacitor Instance: type = capacitor, capcitance = 240 Farads

0. Start with CircuitElement exercise program described in the lecture 10 slide.

1. Make sure you have one header file and one *.cpp file for each class created for this lab. Place the class definitions in the corresponding header file and class member function definitions in the corresponding *.cpp file. (In total you should have eight (8) header files and nine (9) cpp file including main.cpp.)

2. As needed update the Cirucut Element, Wire and Component classes to include the following attributes:

- Accessors and mutators for the the new member items.

- Two (2) constructors: a default constructor to initialize the class value to 0 a constructor with two (2) parameters specify the initial values

3. Create a Battery class that inherits from the Component class with the following attributes:

- A voltage member item.

- A current member item.

- Accessors and mutators for the the new member items.

- Two (2) constructor:

a default constructor to initialize the class value to 0

a constructor with two (2) parameters specify the initial values

4. Create a Switch class that inherits from the Component class with the following attributes:

- A state member item, i.e. open/closed or on/off

- An accessor and mutator for the state.

- Two (2) constructor: a default constructor to initialize the class value to 0 a constructor with one (1) parameters specify the initial values

5. Create a Light class that inherits from the Component class with the following attributes:

- A state member item, i.e. on/off

- An accessor and mutator for the state.

- Two (2) constructor: a default constructor to initialize the class value to 0 a constructor with one (1) parameters specify the initial values

6. Create a Resistor class that inherits from the Component class with the following attributes:

- A resistance member item

- An accessor and mutator for the resistance. - Two (2) constructor: a default constructor to initialize the class value to 0 a constructor with one (1) parameters specify the initial values

7. Create a Capacitor class that inherits from the Component class with the following attributes:

- An capacitance member item.

- An accessor and mutator for the capacitance.

- Two (2) constructor: a default constructor to initialize the class value to 0 a constructor with one (1) parameters specify the initial values

8. Overload the << operator for every class you have created.

9. In the main function create an instance of each class of the Wire, Component, Battery, Switch. Light, Resistor, and Capacitor classes. Assign each instance some non-default value. Using each of the overloaded << operator functions print out each instance.

C++

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

Web Database Development Step By Step

Authors: Jim Buyens

1st Edition

0735609667, 978-0735609662

More Books

Students also viewed these Databases questions

Question

=+What is the nature of the plant or site-level role of unions?

Answered: 1 week ago