8000 GitHub - rishirajkumar97/calculator: Assignment to implement Calculator with TDD practices
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

rishirajkumar97/calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Calculator

A simple string-based calculator built using Ruby with TDD practices. This project demonstrates the Test-Driven Development (TDD) approach by implementing a string calculator that supports custom delimiters, handling multiple delimiters, and handling various edge cases like negative numbers.


Features

  • Add numbers provided as a comma-separated string.
  • Supports custom delimiters of any length, e.g., //[***]\n1***2***3.
  • Handles multiple custom delimiters, e.g., //[*][%]\n1*2%3.
  • Handles delimiters of varying lengths, e.g., //[***][%%]\n1***2%%3.
  • Throws exceptions for negative numbers with details of the negative values.

Installation

  1. Clone the repository:
    git clone https://github.com/rishirajkumar97/calculator.git
    cd calculator
  2. Install dependencies:
        bundle install
  3. Run tests to ensure everything is set up correctly:
        bundle exec rspec
    

Usage

Run the Calculator

  1. Navigate to the project directory:
    cd calculator
  2. Start the IRB Terminal using the command
    irb
  3. Use the calculator.rb file to perform calculations. For example:
require './calculator'

calculator = Calculator.new

# Examples
puts calculator.add("")                 # Output: 0
puts calculator.add("1")                # Output: 1
puts calculator.add("1,2")              # Output: 3
puts calculator.add("1\n2,3")           # Output: 6
puts calculator.add("//[***]\n1***2***3") # Output: 6
puts calculator.add("//[*][%]\n1*2%3")  # Output: 6
puts calculator.add("//[***][%%]\n1***2%%3") # Output: 6

About

Assignment to implement Calculator with TDD practices

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0