Question
C++ Build a Super heroes name generator code and build a simple class to manage the information needed to generate names. Name the class called
C++
Build a Super heroes name generator code and build a simple class to manage the information needed to generate names.
Name the class called Heroes that will store the information needed to generate a super heroes name for a person.
Create two additional files for this project.
o Person.cpp o Main.cpp
Build your program so the main function (in main.cpp) creates one object of type Person. Using that object load the required data using the methods defined in the class, then generate your Star Wars name to show that your class works properly. You can hard code your data for a sample person for this part.
Load your data from a file. Modify your program so it reads the four input strings needed for a person from standard input (using cin). Test your new program to make sure it still works as before, only now reading the four names from user input. Next, create a test file named name.data containing this data: George Washington Superman
That is all on one line.
Then, assuming your program executable is named superman.exe, open up a command prompt and navigate to the project directory. Make sure your program file and data file are both in that directory, then do this: $ superman < names.dat This is called command redirection, and it makes the operating system feed the contents of a file to your program, which still thinks a human is tying things in. The difference is that this human type really fast!
You should see your Superheroes name for this person.
READ MORE NAMES
Now modify your program so it creates an array of Heroes objects.
Heroes Object [10]
Now, create a loop around the part of your code that reads in the data and loads it in the object for a person. This time, we will load one of the objects in the heroes array. Assuming your re using a for-loop with i as the counter variable. cin >> first; cin >> last; Heroes [i].set_name(first, last)
Next, add another method to the Person class called get_name that returns a string that looks like this: first last. With this method in place generate a final display of names and associated start wars names that looks like this: George Washington: Superman
Note: Please use comments for clear understanding
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started