#include "wrapper.h" #include "CarRecord.h" #include "map\map1.hpp" class vinComparer ( public: static Boolean areEqual

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

#include "wrapper.h" #include "CarRecord.h" #include "map\map1.hpp" class vinComparer ( public: static Boolean areEqual

Post by answerhappygod »

Include Wrapper H Include Carrecord H Include Map Map1 Hpp Class Vincomparer Public Static Boolean Areequal 1
Include Wrapper H Include Carrecord H Include Map Map1 Hpp Class Vincomparer Public Static Boolean Areequal 1 (118.5 KiB) Viewed 21 times
#include "wrapper.h" #include "CarRecord.h" #include "map\map1.hpp" class vinComparer ( public: static Boolean areEqual (Text & lhs, Text& rhs) // restores lhs, rhs { return (1hs == rhs); }; // are Equal }} // Key = Text = car VIN // Value CarRecord typedef Mapl CarMap; int main(int argc, char* argv[]) ( CarMap mc1, mc2; CarRecord carRec; Text vin, vinCopy; Integer z; Boolean b; carRec.vin "1HG"; carRec.name = "Charger"; carRec.numberOfDoors = 2; carRec.color="Red"; carRec.year Manufactured 2009; vin carRec.vin; mc1.add(vin, carRec); z = mc1.size(); carRec.vin = "19V"; carRec.name = "Acura ILX"; carRec.numberOfDoors = 4; carRec.color = "Black"; carRec.year Manufactured 2013; vin carRec.vin; Using Map mc1.add(vin, carRec); vin "WBA"; b = mc1.haskey (vin); vin "EK7"; bmc1.hasKey (vin); vin "WMW"; mc1.remove(vin, vinCopy, carRec); vin="2G1"; wcout << mc1.value (vin) << endl; wcout << mc1.value (vin).color << endl; mc1.removeAny (vin, carRec); mc2.transferFrom (mc1); return 0; } // end main // Comment: To make this activity more interesting, Map mc1 is 'seeded' // with 3 mappings listed below. // Normally it would be empty just after declaration and would be written as follows: // mc1 = {} // A real vin looks like this: WMWRH 335X7TJ43830 // But we will use the 1st 3 characters: "WMW" // Each tuple in the map is a (k, v) pair. //kvin // v = CarRecord mc1 = ( ("WMW", ("WMW", "Mustang", 2, "Yellow", 2012)), ("WBA", ("WBA", "Accord", 4, "Silver", 2005)), ("2G1", ("2G1", "A6", 3, "Orange", 2011)) carRec = ("","",0,"",0) z = 0 vin = "" vinCopy = "" b = false; mc1 = carRec = vin = mc1 = carRec= vin = lb = b = mc 1 = Last Updated: 2/27/2017 carRec = vin = What values are wcout? mc1= mc 2 = carRec = vin = Z = z = z = z =
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply