top of page

Working Mothers

Public·11 membres

P2.zip ((NEW))



Project 2 Spring 2023Due: F 2/24 @ 5 PM6 points In this project, you will use classes, inheritance,and polymorphism to implement software that stores information aboutdifferent types of bikes.For simplicity, we will assume that bikes are one of two types:delivery or urban.I have drawn a classdiagram for the project using the Unified Modeling Language (UML), whichappears in the image below.Computer scientists and software engineers commonly use UML to designsoftware and to communicate those designs.We will discuss the diagram in class, but its interpretation shouldbe relatively straightforward.A rectangle represents a class and is divided into three sectionsfor the class's 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.As the diagram indicates, you should implement the Bike class anduse inheritance to derive two subclasses, Delivery and Urban.All bikes have an ID, a name, and a number of gears, which must beprotected.Delivery bikes have a carrying capacity.Each class should have virtual methods that read and print the bike'sinformation from and to a stream.Naturally, the set methods should perform range checks and throwinvalid_argument when values are invalid.Storing information about a single bike is not very interesting, soalso implement a Bikes (plural) class that stores pointers toBike objects in a C++ vector.As the composition link in the diagram indicates, there is a one-to-manyrelationship between the Bikes class and the Bike class.The UML diagram depicts the vector as a private attribute of theBikes class, but you could also derive Bikes fromthe vector class.Implement methods to read bikes from a file, print the bikes stored inthe vector, compute the total number of gears of all of the bikes,and compute the total carrying capacity of the delivery bikes.For further information, see thep2 design documentation.The file format consists of a bike's ID, name, numberof gears, and if it is a delivery bike, its carryingcapacity.The ID is a three-character string. The first character isin A, ..., Z and indicates the type of the bike.This character is 'D' for delivery bikes, and it is 'U'for urban bikes.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 bikes in this format is as follows:U01 "Trek Soho Deluxe" 8D01 "Trek Transport+" 8 80D02 "Johnny Loco Cargo Cruiser" 8 75U02 "Johnny Loco Urban Londoner" 3U03 "Johnny Loco Urban Moscow" 1U04 "Kona Dew DL" 9D03 "Kona Minute" 8 70D04 "Kona Ute" 8 100As Bikes::read reads the input file, it usesBikeFactory::make to make either a Deliveryobject or an Urban object a based on the contentsof the input stream.Once BikeFactory::make determines whether the information inthe stream corresponds to a delivery bike or an urban bike and createsthe appropriate object, it invokes the polymorphic read method to fullyinstantiate the object.The factory can determine which subtype of Bike to make byexamining the first character of the ID.It should then use iostream::putback to put the characterback into the input stream so the object's read method can processthe information in the stream properly.A Factoryis a common method pattern in object-oriented programming.As the name suggests, it is a class designed to produce objects.For this project, its method make returns a pointer toeither an Urban object or a Delivery object.In the main function, write a simple driver program that constructsa Bikes object, reads bikes from the file bikes.dta, prints themto the console, prints the total number of gears of those bikes, andprints the total carrying capacity of the delivery bikes.The main function should also catch the thrown exceptions and issuean 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 StartedI'm sure that messing around with the Makefile for p1 was fun, but forp2, you'll use a Makefile that is less obvious, but more general. Youshould be able to use it for the rest of the projects this semester.To get started, log on to cs-class and copy over the following zip file:cs-class% cdcs-class% cp maloofm/cosc052/p2.zip ./cs-class% unzip p2.zipIn the p2 directory, you will find .h files and a Makefile.I'll explain this Makefile in class. It might be a useful exerciseto get this Makefile working for your solution to p1 just to makesure you know what you're doing.Instructions for Electronic SubmissionIn a file named HONOR, include the following statement withthe appropriate modifications:In accordance with the class policies and Georgetown's Honor System,I certify that, with the exceptions of the class resources and thoseitems noted below, I have neither given nor received any assistanceon this project.NameNetIDYou will submit p2 exactly like you submitted p1.For convenience, I added a submit target to the Makefile thatproduces submit.zip for Autolab.To produce this file, type 'make submit'.Make sure you remove all debugging output before submitting.Plan BIf Autolab is down, upload your zip file toCanvas.Copyright 2023 Mark Maloof. All Rights Reserved.This material may not be published, broadcast, rewritten,or redistributed.




p2.zip


Download Zip: https://www.google.com/url?q=https%3A%2F%2Ftweeat.com%2F2ug78S&sa=D&sntz=1&usg=AOvVaw0_lXIi78Ej5wQ_hsUP4C4-

041b061a72


À propos

Welcome to the group! You can connect with other members, ge...
bottom of page