Giter Club home page Giter Club logo

spreadsheet-calculator's Introduction

Spreadsheet Calculator

A simple textual spreadsheet calculator based on java. Developed for a coding challenge.

Problem Description

Unable to share problem description and company's name as its was marked Confidential and asked not to distribute.

Supported Functionalities

  1. Supports operations on negative and positive Integers and cell based references.
  2. Detects and reports circular dependencies between cells
  3. Supported Operations as of now:
    1. Additon +
    2. Subtraction -
    3. Multiplication *
    4. Division /
    5. Increment ++
    6. Decrement --

File Description

Filename Description
Token.java Abstract token class
OperatorToken.java Concrete class derived from Token.java to represent operators as Tokens
ReferenceToken.java Concrete class derived from Token.java to represent Cell References as Tokens
ValueToken.java Concrete class derived from Token.java to represent Values (operands) as Tokens
TokenFactory.java Factory to get appropriate type of Token from the above list of tokens
Cell.java Class which represents the cells in a spreadsheet's workbook
Operators.java Class to represent all the supported operators and their operations.
CircularDependencyException.java Custom Exception class for Circular Dependency
WorkBook.java Composition over Cells to provides a matrix of cells and support their evaluation
Spreadsheet.java The main spreadsheet calculation class
Utils.java Class containing some utility functions
PrettyPrinter.java Class for priting a matrix in a pretty format. Source code taken from here
SpreadsheetTest.java A raw Test class just to bundle up running tests against different input files

How to Run

Clone the repo and from the parent directory Spreadsheet-Calculator run the following commands

  • Compile

Spreadsheet-Calculator$ javac src/main/java/com/rohitsinha/codingchallenge/*.java

  • Run

Spreadsheet-Calculator$ cat input1.txt | java -classpath src/ main.java.com.rohitsinha.codingchallenge.Spreadsheet

  • For prettyPrint Results

Spreadsheet-Calculator$ cat input1.txt | java -classpath src/ main.java.com.rohitsinha.codingchallenge.Spreadsheet -p

Examples

1. input1.txt

Inputs:

1 2 3
A A2 4 5 * A1
B A1 B2 / 2 + 3 39 B1 B2 * /

Results:

20.00000

20.00000

20.00000

8.66667

3.00000

1.50000

PrettyPrint Results:

1 2 3
A 20.00000 20.00000 20.00000
B 8.66667 3.00000 1.50000

2. input2.txt

Inputs:

1 2 3
A A2 4 5 * A1 / A1
B A1 B2 / 2 + 3 39 B1 B2 * /

Results:

Not Evaluated (Circular Dependency)

Not Evaluated (Circular Dependency)

Not Evaluated

Not Evaluated (Circular Dependency)

3.00000

Not Evaluated

PrettyPrint Results:

1 2 3
A Not Evaluated (Circular Dependency) Not Evaluated (Circular Dependency) Not Evaluated
B Not Evaluated (Circular Dependency) 3.00000 Not Evaluated

Testing

The program has been tested on following operating systems:

  1. Mac OSX 10.9.2

##To Do

  1. Add function headers and improve code documentation. This complete project was developed in less than 4 hours so the documentation kind of sucks :/

##Version 1.0 beta

##Contact Information Please report any bugs or issues to: [email protected]

##License MIT License

spreadsheet-calculator's People

Contributors

rohitsinha54 avatar

Watchers

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