Skip to content

Conversation

@jasonstratton
Copy link
Owner

…c, and refactor getName to getFirstName

@jasonstratton jasonstratton requested a review from Copilot June 25, 2025 16:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces the simple “Hello, World!” with a dynamic greeting system by defining a Person interface and multiple implementations, then randomly instantiating and greeting them. Key changes include:

  • Introduce an abstract Person interface and concrete classes (Moe, Larry, Curley, Shemp).
  • Implement random generation of 3–10 Person objects and print personalized greetings.
  • Refactor getName to getFirstName and keep a legacy print_hello_world helper.
Comments suppressed due to low confidence (1)

main.cpp:55

  • The function print_hello_world is defined but never used; consider removing it or documenting its intended usage.
void print_hello_world() {

std::uniform_int_distribution<> type_dist(0, 3);
int num_people = num_dist(gen);
for (int i = 0; i < num_people; ++i) {
switch (type_dist(gen)) {
Copy link

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a default case or an assertion inside the switch to handle unexpected values and make the intent explicit.

Copilot uses AI. Check for mistakes.

int main(int argc, char* argv[]) {
(void)argc; (void)argv;
std::vector<std::unique_ptr<Person>> people;
Copy link

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reserve the vector capacity with people.reserve(num_people) before the loop to avoid repeated reallocations.

Copilot uses AI. Check for mistakes.
std::vector<std::unique_ptr<Person>> people;
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> num_dist(3, 10);
Copy link

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Extract the magic numbers 3 and 10 into named constants to clarify their purpose and improve readability.

Suggested change
std::uniform_int_distribution<> num_dist(3, 10);
std::uniform_int_distribution<> num_dist(MIN_PEOPLE, MAX_PEOPLE);

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants