Question: (main.cpp) #include #include #include #include #include linkedList.h using namespace std; void getAllPuppiesFromFile (string filename, linkedList& allPuppies ) { istringstream inSS; ifstream input(filename); if (input.is_open()) {

 (main.cpp) #include #include #include #include #include "linkedList.h" using namespace std; void
(main.cpp)
#include
#include
#include
#include
#include "linkedList.h"
using namespace std;
void getAllPuppiesFromFile (string filename, linkedList& allPuppies )
{
istringstream inSS;
ifstream input(filename);
if (input.is_open()) {
Puppy newPuppy;
while (input >> newPuppy.name >> newPuppy.breed >> newPuppy.age ) {
allPuppies.insertLast(newPuppy);
}
}
else {
cout
}
}
int main ( int argc, char **argv )
{
linkedList allPuppies;
string filename = "puppies.txt";
getAllPuppiesFromFile ( filename, allPuppies );
if ( argc >= 2 ) {
allPuppies.printAll();
}
else {
allPuppies.printOldestPuppy();
}
return 0;
}
(linkedList.cpp)
#include
#include
#include
#include
#include "linkedList.h"
using namespace std;
void getAllPuppiesFromFile (string filename, linkedList& allPuppies )
{
istringstream inSS;
ifstream input(filename);
if (input.is_open()) {
Puppy newPuppy;
while (input >> newPuppy.name >> newPuppy.breed >> newPuppy.age ) {
allPuppies.insertLast(newPuppy);
}
}
else {
cout
}
}
int main ( int argc, char **argv )
{
linkedList allPuppies;
string filename = "puppies.txt";
getAllPuppiesFromFile ( filename, allPuppies );
if ( argc >= 2 ) {
allPuppies.printAll();
}
else {
allPuppies.printOldestPuppy();
}
return 0;
}
getAllPuppiesFromFile (string filename, linkedList& allPuppies ) { istringstream inSS; ifstream input(filename); if
(puppies.txt)
Jacky Poodle 12
Bella Beagle 2
Luna Boxer 5
Max Bulldog 6
Shawny Labrador 16
Bailey Terrier 11
Cooper Rottweiler 4
Given the software to manage puppies in an animal shelter. Puppies are stored as a singly linked list. Initial input is provided as a text file. Definition of all relevant classes (i.e. class Puppy, class linkedlist, class nodeType) are in the file linked List.h. The code to read all puppies from a textfile and create the linked list is in main.cpp. Both file are not be changed a. Implement the function insertLast() in the file linkedList.cpp to add another puppy to the end of the linked list b. Implement the function printOldestPuppy in the file linkedList.cpp which traverses the linked List and prints at the end the oldest Puppy using the following format: oldest Puppy 18 Zoldest puppy.name> Age oldest puppy, age> les main.cpp linked List.cpp linked List.h linkedList.h 1 Fifndef LINKEDLIST_H 2 #define LINKEDLIST_H 3 4 #include 5 6 using namespace std; 7 class Puppy { 9 public: 1e string name; 11 string breed; 12 13 puppies.txt int age; 15 16 struct nodeType { Puppy info; nodetype "link; 17 18 19 ); & 21 22 23 24 25 26 -27 28 29 3e 31 32 33 class linked List C private int count: node Type first; node Type -last; public linkedlisto; int length: void insertFirst(const Puppy newItem); void insertlast(const Puppy& newItem); void printAll() const; void printoldestPuppy const; }; 34 35 36 27 sendit

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!