Download - 1 Project 6: Cats in Tree. 2 Project 3: Cats in Tree In this project you will Create a class definition for a Cat class. Populate a BST with Cat information.

Transcript
Page 1: 1 Project 6: Cats in Tree. 2 Project 3: Cats in Tree In this project you will Create a class definition for a Cat class. Populate a BST with Cat information.

1

Project 6: Cats in Tree

Page 2: 1 Project 6: Cats in Tree. 2 Project 3: Cats in Tree In this project you will Create a class definition for a Cat class. Populate a BST with Cat information.

2

Project 3: Cats in Tree

In this project you will Create a class definition for a Cat class. Populate a BST with Cat information from a

file. Display the tree in a vertical orientation. Respond to user queries about cats in the

tree.

Start with most recent version of the BST template.

Page 3: 1 Project 6: Cats in Tree. 2 Project 3: Cats in Tree In this project you will Create a class definition for a Cat class. Populate a BST with Cat information.

3

Class Cat

For the purposes of this program, a cat has: Name Date of birth (mm/dd/yyyy) Weight in pounds

There is a sample input file in the Downloads area: cats.txt

Your program should work with any number of cats in the file.

Page 4: 1 Project 6: Cats in Tree. 2 Project 3: Cats in Tree In this project you will Create a class definition for a Cat class. Populate a BST with Cat information.

4

Sample Input File

Page 5: 1 Project 6: Cats in Tree. 2 Project 3: Cats in Tree In this project you will Create a class definition for a Cat class. Populate a BST with Cat information.

5

Class Date

The cat's date of birth should be a Date object. Not a string.

Define a Date class with just day, month, and year, as integers.

Instantiate Date object with values read from the file.

Page 6: 1 Project 6: Cats in Tree. 2 Project 3: Cats in Tree In this project you will Create a class definition for a Cat class. Populate a BST with Cat information.

6

Class Cat

The << operator for class Cat should output only the cat's name. That's what we want to see in the tree

display.

Provide a display method that shows all information for the cat. Use that in responding to queries.

Provide < and == operators based on the cat's name.

Page 7: 1 Project 6: Cats in Tree. 2 Project 3: Cats in Tree In this project you will Create a class definition for a Cat class. Populate a BST with Cat information.

7

Modify display_v

Modify the BST display_v method to permit the caller to specify the width of the columns in the output.

When you call display_v from main, set the column width to the length of the longest name seen in the input file.

Page 8: 1 Project 6: Cats in Tree. 2 Project 3: Cats in Tree In this project you will Create a class definition for a Cat class. Populate a BST with Cat information.

8

Program Flow

Your program should Instantiate BST<Cat> Read the input file. Instantiate a Cat object with each cat

record in the file. Populate the BST with Cat objects

from the file. Display the tree in a vertical format. Respond to queries about cats.

See sample run.

Page 9: 1 Project 6: Cats in Tree. 2 Project 3: Cats in Tree In this project you will Create a class definition for a Cat class. Populate a BST with Cat information.

9

Program Running

Page 10: 1 Project 6: Cats in Tree. 2 Project 3: Cats in Tree In this project you will Create a class definition for a Cat class. Populate a BST with Cat information.

10

Development Environment

You may develop your program on any system you like.

But you should test the finished program on Circe.

The same source files should compile and run on either Windows or Linux.

Page 11: 1 Project 6: Cats in Tree. 2 Project 3: Cats in Tree In this project you will Create a class definition for a Cat class. Populate a BST with Cat information.

11

Ground Rules You may work with one other person.

OK to work alone if you prefer.

If you do work as a pair Work together!

Both members are expected to contribute. Both members should understand the program in

detail. Submit a single program.

Do not share your code with other students. Before or after submitting the project. OK to discuss the project.

Do not copy any other student’s work. Don’t look at anyone else’s program. Don’t let anyone look at your program.

Page 12: 1 Project 6: Cats in Tree. 2 Project 3: Cats in Tree In this project you will Create a class definition for a Cat class. Populate a BST with Cat information.

12

Ground Rules

Except for code posted on the class web site

Do not copy code from the Internet or any other source.

Write your own code.

Page 13: 1 Project 6: Cats in Tree. 2 Project 3: Cats in Tree In this project you will Create a class definition for a Cat class. Populate a BST with Cat information.

1313

Submission

Project is due by 11:59 PM, Sunday night, March 27

Deliverables: Source files in zipped folder

genBST3.h Date.h, .cpp Cat.h, .cpp main.cpp

OK to zip entire Visual Studio project folder.

If you work with another student, include both names in the assignment comments.

Other student submit just a Blackboard submission comment including both names.

End of Presentation