Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use the following C++ class to create a working implementation in Java. You are welcome to write a separate class containing the main method to
Use the following C++ class to create a working implementation in Java. You are welcome to write a separate class containing the main method to test out your class, but it is not required for this quiz. Please put this class in the following package: cpsc2150.quizzes
#includeusing namespace std; class Person { public: // Constructor: sets firstName and lastName according to the parameters. // @pre [ first and last names are valid ] // @post firstName = first AND lastName = last Person(string first, string last); // Function to output the first name and last name in the form (with a space separating the two strings): firstName lastName // @pre None // @post [ Output person's name to console ] AND firstName = #firstName AND lastName = #lastName void print() const; // Function to set firstName and lastName according to the parameters // @pre [ first and last names are valid ] // @post firstName = first AND lastName = last void setName(string first, string last); // Function to return the first name // @pre None // @post getFirstName = firstName AND firstName = #firstName AND lastName = #lastName string getFirstName() const; // Function to return the last name // @pre None // @post getLastName = lastName AND firstName = #firstName AND lastName = #lastName string getLastName() const; private: string firstName; string lastName; };
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