Coder Social home page Coder Social logo

ruby-classes's Introduction

#Ruby Classes

Fork and clone this repo to get started.

In each of the ruby files provided, create a class that meets the following requirements. Once the classes have been created, test them by creating an instance and calling the appropriate methods.

###Robot

  • Create a Robot class
  • Initialize each Robot with a name and purpose
  • Robot should have a greet method that returns "beep boop"

#####Robot Test

  • Create one Robot instance with a name and purpose
  • Have the robot greet you

###Dice

  • Create a Dice class
  • Initialize each Dice with a number_of_sides (greater than 0).
  • Dice should have a roll method that randomly returns a number from 1 up to the number_of_sides.
    • You'll need to call some type of random function
  • Dice should have a get_rolls method that returns an array containing previous rolls.
  • Dice should have a class variable called total_dice that keeps track of how many Dice instances have been created.

#####Dice Test

  • Create two new Dice instances with different numbers of sides
  • Roll each Dice three times
  • Print the rolls that each Dice made
  • Print the number of dice

###Agent

  • Create a Agent class
  • Initialize each Agent instance with a secret and name
  • Agent should have a private method called print_secret that will print Agent's secret.
    • Note that the secret should not be accessible by a getter/setter or by calling the print_secret method.
  • Agent should have a go_rogue method that takes a boolean
    • If the boolean is true, the Agent should tell his secret by calling the print_secret method
    • If the boolean is false, nothing should happen

#####Agent Test

  • Create two new Agent instances with different names and secrets
  • Tell the first agent to "go rogue"
  • Tell the other agent to "not go rogue"

ruby-classes's People

Contributors

bhague1281 avatar

Watchers

James Cloos avatar  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.