Giter Site home page Giter Site logo

oop-mentorship's Introduction

OOP-Mentorship

You don't need to clone/fork this project

Create one repository on github and create your own project

Use the best practices and evaluate what you will be using.

  • Classes
  • Abstraction
  • Encapsulation
  • Public, Private, Protected
  • Polymorphism
  • Inheritance
  • Modules
  • Setter and Getter Methods
  • Super
  • Self

Chalenge

Imagine that you're creating an software to register customers, your first challenge will be create an way to:

  • Register customer
  • Search for customer
  • Delete customer
  • Update customer
  1. Register customer
  • be sure to add any kind of indentifier to the customer e.g: 'ID'
  1. Search for customers

Example:

def search_customer(customer_id)
 @customer_obj =  #loadymlfile
 list_of_customer 
end
  1. Delete Customer
  • Delete desired customer and save the file again
de delete_customer(customer_id)
 @customer_obj =  #loadymlfile
 list_of_customer 
 remove customer from the list
 save the file again
end
  1. Update customer
  • We also want to update customer this could be done in loading the desired customer, by findind it first, modifing the data and saving the file again
de update_customer(customer_id)
 @customer_obj =  #loadymlfile
 list_of_customer 
 update customer 
 save the file again
end

Since we don't want the complexity in having an data base set up and handle tables and stuff, we'll use YML files instead.

Example in how to create YMl file and Store data

require 'yaml'

cars  = ["ferrari", "porsche", "mercedez"]
File.open("cars.yml", "w") { |file| file.write(cars.to_yaml) }

Retriving the data

require 'yaml'
cars_array = YAML.load(File.read("cars.yml"))
p cars_array       
#=> ["ferrari", "porsche", "mercedez"]

If you want to have a look in the content, the file will be on your root path

---
- ferrari
- porsche
- mercedez

You can also usa hashes to create the files :)

Bonus part: Add V.I.P customers. ADD a method to add VIP to a customer (during the customer creation you can generate an ID ;) so you can use it later to add the VIP) VIP customers should have an extra property that tells us if a customer is VIP or not.

Second part

Now that we have an way to work with customers we would like to add products to our store.

  • The store will provide products and services, where products are:

Products:

  • sandwich
  • beverages (be sure to check if the customer is 18+) if not return a message saying that isn't allowd to buy.
  • Snacks

Services:

  • Card top-up

Be sure to save values in a format that could be easy manipulated e.g value: 14.90

Creating command line tool

This is just an small example, as part of the challenge you need to search for it.

TIP: Chomp method in ruby


require "readline"
addends = []
while addend_string = Readline.readline("> ", true)
  addends << addend_string.to_i
  puts "#{addends.join(' + ')} = #{addends.sum}"
end

any questions you can contact me on twitter: https://twitter.com/wellavelino

oop-mentorship's People

Contributors

wellavelino 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.