Sale!

Project #2 implement software that stores information

$30.00

Category:

2 February 2019 Project #2
COSC 052 Spring 2019 Page 1 of 4
Background
In this project, you will use classes, inheritance, and polymorphism to implement software that stores information
about different types of bicycles. For simplicity, we will assume that bicycles are one of two types: delivery or
urban. The Unified Modeling Language (UML) diagram below is provided for reference in completing the project.
Computer scientists and software engineers commonly use UML to design software and to communicate those
designs. We will discuss the diagram in class, but its interpretation should be relatively straightforward.
A rectangle represents a class and is divided into three sections for the class’ name, its data members (or attributes
or properties), and its methods (or operators). Characters precede attributes and methods. The hyphen (-)
denotes private, the pound sign (#) denotes protected, and the plus sign (+) denotes public. Additional details and
validation rules are also available at http://people.cs.georgetown.edu/~maloof/cosc052.s19/p2docs.
As the diagram indicates, you should implement the Bike class and use inheritance to derive two subclasses,
Delivery and Urban. All bicycles have an ID, a name, and a number of gears. These are protected in the
base class. Delivery bicycles have a carrying capacity. Each class should have virtual methods that read and
print the bicycle’s information from and to a stream. Naturally, the setter methods should perform range checks
and throw an invalid_argument exception when values are invalid.
Storing information about a single bicycle is not very interesting, so also implement a Bikes (plural) class that
stores pointers to Bike objects in a C++ vector. As the composition link in the diagram indicates, there is a
one-to-many relationship between the Bikes class and the Bike class. Implement methods to read Bike
objects from a file, print the elements (Bike objects) stored in the vector, compute the total number of gears of
all of the bicycles, and compute the total carrying capacity of the delivery bicycles.
2 February 2019 Project #2
COSC 052 Spring 2019 Page 2 of 4
The input data file format consists of a Bike object’s ID, name, number of gears, and if it is a delivery bicycle,
its carrying capacity. The ID is a three-character string. The first character is in {A, …, Z} and indicates the type
of the bicycle. This character is ‘D’ for delivery bicycles, and it is ‘U’ for urban bicycles. The next two characters are
digits and represent an inventory code. The name is delimited with double quotes. The number of gears and
the carrying capacity are integers. An example of input data file records in this format is shown below.
As the method Bikes::read reads the input file, it uses BikeFactory::make to make either a Delivery
object or an Urban object based on the contents of the input stream. Once BikeFactory::make determines
whether the information in the stream corresponds to a delivery bicycle or an urban bicycle and creates the
appropriate object, it invokes the polymorphic read method to fully instantiate the object. The factory can
determine which subtype of Bike object to make by examining the first character of the ID. It should then use
iostream::putback to put the character back into the input stream so the object’s read method can process
the information in the stream properly.
A Factory (https://en.wikipedia.org/wiki/Factory_method_pattern) is a common method pattern in objectoriented programming. As the name suggests, it is a class designed to produce objects. For this project, its
method make returns a pointer to either an Urban object or a Delivery object.
In function main, write a simple driver program that constructs a Bikes object, reads bicycles from the input
data file bikes.dta, prints them to the console, prints the total number of gears of those bicycles, and prints
the total carrying capacity of the delivery bicycles. Function main shall also catch any exceptions that could be
thrown during the program execution and display an appropriate message for those exceptions.
Use stepwise refinement and incremental development. For example, implement the Bike class and test it
thoroughly before implementing, say, the Delivery class.
Getting Started
For convenience, several files are attached to the Project 2 Assignment on Canvas to help get you started. You
should create a directory on your server account named p2 and copy all of these files to that directory. Once that
is done, the p2 directory, will contain a Makefile and .h files for the project. If you are developing on an IDE,
then do the same thing on your local computer and then add the .h files to your IDE project.
U01 “Trek Soho Deluxe” 8
D01 “Trek Transport+” 8 80
D02 “Johnny Loco Cargo Cruiser” 8 75
U02 “Johnny Loco Urban Londoner” 3
U03 “Johnny Loco Urban Moscow” 1
U04 “Kona Dew DL” 9
D03 “Kona Minute” 8 70
D04 “Kona Ute” 8 100
2 February 2019 Project #2
COSC 052 Spring 2019 Page 3 of 4
Academic Integrity
This is an individual project and all work must be your own. Refer to the guidelines specified in the Academic
Honesty section of this course syllabus or contact me if you have any questions. A file named HONOR containing
the following contents is also provided:
Make the appropriate substitutions and ensure that the file is included with your submission.
Instructions for Electronic Submission
Although you may use any development environment for your project, it must compile and execute on the class
server and on Autolab. Make sure it compiles and runs without error on cs-class before submitting.
Your project must be submitted no later than Friday, February 22, 2019 at 5:00pm. Late submissions will be
penalized 1 point for each minute. In general requests for extensions will not be considered.
You will submit Project 2 in the same way you did Project 1. There is a new Makefile for Project 2 that is less
obvious, but more general. You should be able to use it for the rest of the projects this semester. It might be a
useful exercise to get this new Makefile working with a copy of your solution to Project 1 as a test. (Plan B:
ONLY in case of some catastrophic issue with the AutoLab system, one of the servers, or if you have some serious
extenuating circumstances, then upload your zip file to the Project 2 assignment on Canvas).
Emergency Backup
Once you’ve submitted your project, it is important to keep an electronic copy on a university machine such as the
class server (cs-class) that preserves the modification date and time. If we lose your project or the submission
system breaks, then we will need to look at the modification date and time of your project to ensure that you
submitted it before it was due. Retain either the zip file or the directory containing your project’s files.
Grading
This graded assignment is worth 100 points and will be counted as part of the Programming Projects category for
the course. Your final score is based on automated tests performed by AutoLab, as well as a manual review
conducted by one of our Teaching Assistants (TAs). We will talk about the AutoLab tests in class and you will be
able to see exactly what those are when you submit for the first time.
<Name>
<NetID>
In accordance with the class policies and Georgetown’s Honor Code,
I certify that, with the exceptions of the class resources and those
items noted below, I have neither given nor received any assistance
on this project.
2 February 2019 Project #2
COSC 052 Spring 2019 Page 4 of 4
Course Materials Notice
The materials used in Georgetown University courses (“Course Materials”) generally represent the intellectual
property of course instructors which may not be disseminated or reproduced in any form for public distribution
(e.g., sale, exchange, etc.) without the written permission of the course instructor. Course Materials include all
written or electronic documents and materials, including syllabi, current and past examination questions/answers,
and presentations such as lectures, videos, PowerPoints, etc., provided by a course instructor. Course Materials
may only be used by students enrolled in the course for academic (course-related) purposes.
Published course readings (book chapters, articles, reports, etc.) available in Canvas are copyrighted material.
These works are made available to students through licensed databases or fair use. They are protected by
copyright law, and may not be further disseminated or reproduced in any form for distribution (e.g., uploading to
websites, sale, exchange, etc.) without permission of the copyright owner.
More information about intellectual property and copyright can be found here:
https://www.library.georgetown.edu/copyright.
More information about computer acceptable use policy and intellectual property can be found here:

Computer Systems Acceptable Use Policy


This document: Copyright © 2019 W. A. Woods. All Rights Reserved. This material may not be published,
broadcast, rewritten, or redistributed.
On-line documentation: Copyright © 2019 Mark Maloof. All Rights Reserved. This material may not be
published, broadcast, rewritten, or redistributed.

Reviews

There are no reviews yet.

Be the first to review “Project #2 implement software that stores information”

Your email address will not be published.