builder_pattern::Product

class Product

Represents the complex product being built.

The Product class contains components partA and partB which represent the individual parts of the product. It provides methods to set its parts and to display the details of the constructed product.

Public Functions

void setPartA(const std::string &part)

Sets Part A of the product.

Parameters:

part – A string representing Part A.

void setPartB(const std::string &part)

Sets Part B of the product.

Parameters:

part – A string representing Part B.

std::string toString() const

Provides a string representation of the product.

Combines details of Part A and Part B into a formatted string representation of the product.

Combines the details of Part A and Part B into a formatted string that describes the constructed product.

Returns:

A string describing the product’s parts.

Returns:

A string representation of the product’s parts.

Friends

friend std::ostream &operator<<(std::ostream &os, const Product &product)

Overloads the output stream operator for the Product class.

Allows the details of the Product to be printed to an output stream.

Parameters:
  • os – The output stream.

  • product – The product to be printed.

Returns:

The output stream with product details appended.