//C++ program
#include<iostream>
#include <utility>
#include <math.h>
using namespace std;
class shape{
protected:
pair <double,double>
location;
public:
shape(double x=0,double y=0){
location.first =
x;
location.second=y;
}
double area();
double border();
pair <double,double> where(){
return
location;
}
};
class circle:public shape{
private:
double radius;
public:
circle(double x=0,double y=0,double
r=0):shape(x,y){
radius=r;
}
double area(){
return
M_PI*radius*radius;
}
double border(){
return
2*M_PI*radius;
}
};
class square:public shape{
private:
double edge;
public:
square(double x=0,double y=0,double
e=0):shape(x,y){
edge=e;
}
double area(){
return
edge*edge;
}
double border(){
return
4*edge;
}
};
c++ 6. Define classes shape, and classes circle and square, which inherit from shape. At the bottom of the page is a sample program using these classes, followed by its output. (a) Class shape h...
Problem: Develop the ‘Shape’ application such that: · ‘Rectangle’, ‘Ellipse’, and ‘Triangle’ classes inherit from the ‘Shape’ class. · Develop the ‘Square’ and ‘Circle’ class where ‘Square’ inherits from ‘Rectangle’ and ‘Circle’ inherits from ‘Ellipse’. ‘Triangle’ has no derived class. · For each class, implement the overridden methods ‘draw’, ‘move’, and ‘erase’. Each method should only have an output statement such as “Rectangle – draw method” that will be displayed when the method is invoked. · Implement the default constructors...
Create class definitions using the following: Classes: Circle, Cube, Shape, Sphere, Square, ThreeDimensionalShape, TwoDimensionalShape Functions: Draw, GetArea, GetDimensions, GetHeight, GetLength, GetSurfaceArea, GetVolume Members: height, length, width – all of type double Don’t actually write function implementations, just define the classes as you would in a header file. Use inheritance as appropriate. Use keywords such as “const” and “virtual” as appropriate. Make functions and members public, private, or protected as appropriate. Don’t forget constructors and destructors. Some classes may be abstract,...
in C++ use Inheritance for the following Shape Circle Sphere Cylinder Rectangle Square Cube You must define one class for each shape. And, use public inheritance when deriving from base classes. Circle int r; void area(); void perimeter(); void volume(); //No volume for circle Sphere int r; void area();//Sphere surface area= 4 × pi × radius2 void perimeter(); //No perimeter for Sphere void volume();//Sphere volume= 4/3 × pi × radius2 Cylinder int r, height; void area();// Cylinder surface area=perimeter of...
Language is JAVA.
Clarification for the Shape class (highlighted):
The following requirements specify what fields you are expected
to implement in your Shape class;
- A private String color that specifies the color of the
shape
- A private boolean filled that specifies whether the shape is
filled
- A private date (java.util.date) field dateCreated that
specifies the date the shape was created Your Shape class will
provide the following constructors;
- A two-arg constructor that creates a shape
with...
using c++ Please create a class "Circle" that - uses template type as data type for private data member radius. overrides "operator>>" to take a value from user input and assign it to radius', when taking a Circle object as the right operand. (friend function) overrides "operator<<" to display radius of the circle object and its area, when taking a Circle object as the right operand.(friend function) overrides binary "operator+" that takes an int parameter to increment the Circle object's...
This question is about java program. Please show the output and the detail code and comment.And the output (the test mthod )must be all the true! Thank you! And the question is contain 7 parts: Question 1 Create a Shape class with the following UML specification: (All the UML "-" means private and "+" means public) +------------------------------------+ | Shape | +------------------------------------+ | - x: double | | - y: double | +------------------------------------+ | + Shape(double x, double y) | |...
Using Python Write the following well-documented (commented) program. Create a class called Shape that has a method for printing the area and the perimeter. Create three classes (Square, Rectangle, and Circle) which inherit from it. Square will have one instance variable for the length. Rectangle will have two instance variables for the width and height. Circle will have one instance variable for the radius. The three classes will have methods for computing the area and perimeter of its corresponding shape....
Pure Abstract Base Class Project. Define a class called BasicShape which will be a pure abstract class. The class will have one protected data member that will be a double called area. It will provide a function called getArea which should return the value of the data member area. It will also provide a function called calcArea which must be a pure virtual function. Define a class called Circle. It should be a derived class of the BasicShape class. This...
java language
Problem 3: Shape (10 points) (Software Design) Create an abstract class that represents a Shape and contains abstract method: area and perimeter. Create concrete classes: Circle, Rectangle, Triangle which extend the Shape class and implements the abstract methods. A circle has a radius, a rectangle has width and height, and a triangle has three sides. Software Architecture: The Shape class is the abstract super class and must be instantiated by one of its concrete subclasses: Circle, Rectangle, or...
Project 1 – Classes and Top-down Design Overview Software development projects using the object-oriented approach involve breaking the problem down into multiple classes that can be tied together into a single solution. In this project, you are given the task of writing some classes that would work together for providing a solution to a problem involving some basic computations. Learning Objectives The focus of this assignment is on the following learning objectives: • Be able to identify the contents of...