Code Monkey home page Code Monkey logo

test's Introduction

Specification

The goal of this homework is to write a program that can receive three arguments: object type, width (radius), length, and calculate its area. Your program needs to support 3 shape types: circle, triangle, rectangle.

Input

Your program needs to accept 2 or 3 arguments. The 1st argument is object type, the 2nd is width (or radius for circle), the 3rd is length. The 3rd argument is not necessary if the input object is "circle".

Usage:

a.out [type] [w] [l]

Examples:

a.out triangle 3 4
a.out circle 5

Output

Print the area size of input shape directly. Example:

> a.out triangle 3 4
> 6
> a.out circle 1
> 3.1415926

Requirements

We have provided a template. Create a “shapes.h” file and define 4 classes with area() function. The 4 class you need to write are: Base class: Shape Derived class: Circle, Triangle, Rectangle

In the template we already provide class Shape and Rectangle. You need to complete Circle and Triangle.

Compile Your Code

We include a Makefile. Just type “make” in your command-line window.

Test your code

Run the commands on Linux

kt@ntut:~/oop/hw1$ make
kt@ntut:~/oop/hw1$ ./a.out rectangle 2 4.5
kt@ntut:~/oop/hw1$ 9

test's People

Contributors

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