Giter Site home page Giter Site logo

cosc1430_lab24's Introduction

COSC1430_Lab24

For this assignment, you're given a partially completed class RadioStation. Complete it's following methods:

void setName(string): check if the string is empty. If it is then throw an std::runtime_error with this message:

  -Station name must not be empty!
  -otherwise, set the name to that new string. 
  -This function is provided to you as a reference for the implementation of the functions below.

void setChannel(float): check if the float is negative, or more than 100 and throw an std::runtime_error with the following message:

  -Invalid channel!
  -otherwise, set the channel to that new float

void setBandwidth(int): check if the int is negative and throw an std::runtime_error with the following message:

  -Bandwidth must be a positive number!
  -otherwise, set the bandwidth to that new int

void broadcast(string): check if the string is empty and throw an std::runtime_error with the following message:

  -Message must not be empty!
  -Then, check if bandwidth is not positive and throw an std::runtime_error with the following message:
  -Insufficient Bandwidth!
  -otherwise, print out the message and decrement the bandwidth

A constructor that takes in (name, channel, bandwidth), make sure to call the setter functions (setName, setChannel,…) so that the exception checking is effective!

Main.cpp

In the main function, surround each of the indicated (commented) blocks of code with a try catch block that catches the runtime_error and print out it's message with error.what().

cosc1430_lab24's People

Contributors

ohaluminum avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.