/* Assignment 3- Classes radio_orz.cpp Tom Orzechowski orzecht1@lasalle.edu This is the cpp file for the radio class */ #include "radio_orz.h" //constructors for the class Radio::Radio() : station(101.1), volume(2), on(false) { for(int count=0; count<6; count++) preset[count]=0; } Radio:: Radio(bool onstart, double stationstart, int volumestart) : on(onstart) ,station(stationstart), volume(volumestart) { for(int count=0; count<6; count++) preset[count]=0; } void Radio::TogglePower(){ //toggles between the power being on off if(on) on=false; else on=true; } bool Radio::TuneUp(){ //goes up a radio station by .4 //and reports whether not it was successfull if(station+.4<=108.9){//checks to make sure that the station can be tuned up further station+=.4; return true; } return false; } bool Radio::TuneDown(){ //goes down a radio station by .4 //and reports whether not it was successfull if(station-.4>=87.8){//checks to make sure that the station can be tuned down further station-=.4; return true; } return false; } bool Radio::VolumeUp(){ // increases volume by 1 (max 10) //and reports whether not it was successfull if(volume+1<=10){//checks to make sure that the volume can be increased volume++; return true; } else return false; } bool Radio::VolumeDown(){ // decreases volume by 1 (min 0) //and reports whether not it was successfull if(volume-1>=0){//checks to make sure that the volume can be reduced volume=volume-1; return true; } else return false; } bool Radio::Preset(int number){ //presets current station (buttons 1-6) //and reports if it was successfull if(number>0 && number<=6){//checks that the number sent is valid preset[number-1]=station; return true; } return false; } bool Radio::GoPreset(int number){ //goes to preset station and reports whether or not it //was successfull if(number>0 && number<=6){//checks for valid input if(preset[number-1]!=0){//checks that the preset station has a value station=preset[number-1]; return true; } } return false; } //the following are simple functions used to return the station, volume, and on values double Radio::GetStation(){ return station; } int Radio::GetVolume(){ return volume; } bool Radio::GetStatus(){ return on; } ostream& operator << (ostream & strOut, Radio & myRadio){//allows for the class to be used with cout if(myRadio.GetStatus()){ strOut<<"Power: ON Station: "<