cpp2_code_s08 - CGS-2421 C+ EXAM 2 CODING PART USERNAME _...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CGS-2421 C++ EXAM 2 CODING PART SPRING 2008 USERNAME ___________________ NAME __________________________________ 1. ( 15 pts ) This question is related to the Route Class in the multiple-choice section of this test. You are asked to add a method named isConnected() to determine if two routes connected. This class can be used to represent a bus route where the strings in the array (chain) are names of bus stops. If two routes have at least one stop with same name, they are connected. The prototype of the method is given by: bool isConnected(Route r); Example: string stop[4]={"aa", "ab","ac","ad"}; string stop1[4]={"fa", "fb","fc","fd"}; string stop2[4]={"ea", "ec","ab","ed"}; Route r1(10,stop,30), r2(15,stop1,35), r3(20,stop2,40); r1.isConnected(r2); //the return vale is 0. r1.isConnected(r3); //the return vale is 1. --------------------------------------------- Your Solution -------------------------------------------- bool Route::isConnected(Route r){ for ( int i = 0; i < 4; i++) for ( int j = 0; j < 4; j++) if (chain[i]==r.chain[j]) return true; return false; }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/05/2011 for the course CGS 2421 taught by Professor Onal during the Fall '09 term at University of Florida.

Page1 / 4

cpp2_code_s08 - CGS-2421 C+ EXAM 2 CODING PART USERNAME _...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online