Find Jobs
Hire Freelancers

draw

$30-50 USD

Closed
Posted over 17 years ago

$30-50 USD

Paid on delivery
Draw: inherited classes Write a C# program called Draw. ## Deliverables Draw: inherited classes Write a C# program called Draw. The program will simulate drawing different shapes by outputting which shape it is, the color of the shape, and the area of the shape. If the shape is three dimensional the output will include the Volume of the shape. The user will input shapes by clicking on a button that will accept the appropriate input from one or more of the input boxes. The output will be shown when the appropriate Show shape button is pressed. Buttons include First, Last, Previous, and Next. When the current shape is the first shape, Previous will show the last shape. When the current shape is the last shape, Next will show the first shape. Delete will remove the current shape from the array and will replace it with the last shape in the array. Clear will set the number of shapes to 0. When there are no shapes, the current shape is -1. The user will input shapes by clicking on a button that will accept the appropriate input from one or more of the input boxes. Follow the instructions closely. Create your classes first, then create your data members in the Draw class, and finally implement the buttons. Classes: Level I: Create a base class called Shape. Shape will have two data members. a protected String called Name that will contain the name of the shape a protected String called Color Shape will also have a public virtual method called Area that returns a double that must be defined in the derived classes. There will also be a public virtual method called Volume. It returns zero when there is no volume (for two dimensional shapes). The constructor for Shape will take two parameters, one for each of its data member (Name and Color) Level II: Create three classes derived from Shape called Circle, Square and Triangle. Each class will inherit Name and Shape. Each will have additional protected data members appropriate to the shape (needed for calculating the Area and Volume). Each class will have a constructor that takes as parameters all the information needed to initialize the shape. The constructor will explicitly call the Shape constructor. Each class will override the Area method and the Volume method (the volume method on this level will return 0). Circle will also include a private perimeter method. Level III Create a derived class for each of the classes in Level II. Cylinder from Circle, Cube from Square, and Tetrahedron from Triangle. Add appropriate protected data members (see formulas below) Each class will have a constructor that takes as parameters all the information needed to initialize the shape. The constructor will explicitly call the Level II constructor. Each class will override the Area method. Each class will override the Volume method. Shape Formulas Perimeter Circle = 2 * pi * radius Area: Circle = pi * radius squared Square = length * width Triangle = (base * height) / 2 Cylinder = 2 * circle + perimeter * height Cube = square * 6 Tetrahedron = square root of 3 times triangle area squared Volume Cylinder = circle * height Cube = width * length * height Tetrahedron = one twelfth of the square root of 2 times the area cubed Main Program In your Draw class create an array of Shape. Declare the array in the data section of the class. Shape [] shapes;. You will also need an integer that keeps track of the current shape. Call it current. You will also need an integer to keep track of the number of shapes in the array. Call it number. In the Draw constructor, create the Shape array. Shape = new Shape [25]; In the Draw constructor, initialize current to -1 and initialize number to 0. Any of the add shape buttons will add the chosen shape by doing the following. get the values needed that were entered in the textboxes create a new shape object of the appropriate type, depending on the button clicked, passing the corresponding parameters that are taken from the text boxes. assign the shape as it is created into the array using number as the position in the array and increment both number and current. shapes[number++] = new Circle( radius, color, “Circle??); //for example To show the shapes, click one of the show shape buttons. first will set current to 0 and show the 0th element in the array. next will increment current then show that element in the array. If current is equal to number-1 then it will show the 0th element and set current to 0. previous will decrement current then show that element in the array. If current is equal to zero then current become number-1 and shows the last element in the array. Last will set current to number-1 and show that element in the array. Clear will set current to -1 and number to 0. Delete will move the last element in the array (number) and decrement number. Make sure that you test for deleting the last element in the array. To save time you may download the GUI if you like and only do the classes and implementation of the buttons. ## Platform c#
Project ID: 3825534

About the project

19 proposals
Remote project
Active 17 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
19 freelancers are bidding on average $28 USD for this job
User Avatar
See private message.
$42.50 USD in 3 days
4.9 (114 reviews)
6.2
6.2
User Avatar
See private message.
$25.50 USD in 3 days
5.0 (137 reviews)
6.2
6.2
User Avatar
See private message.
$24.65 USD in 3 days
5.0 (82 reviews)
5.3
5.3
User Avatar
See private message.
$38.25 USD in 3 days
5.0 (22 reviews)
5.1
5.1
User Avatar
See private message.
$42.50 USD in 3 days
4.0 (29 reviews)
5.2
5.2
User Avatar
See private message.
$42.50 USD in 3 days
4.3 (8 reviews)
4.2
4.2
User Avatar
See private message.
$34 USD in 3 days
4.5 (42 reviews)
4.0
4.0
User Avatar
See private message.
$17 USD in 3 days
5.0 (27 reviews)
3.7
3.7
User Avatar
See private message.
$29.75 USD in 3 days
5.0 (8 reviews)
3.6
3.6
User Avatar
See private message.
$17 USD in 3 days
4.9 (42 reviews)
3.4
3.4
User Avatar
See private message.
$21.25 USD in 3 days
5.0 (5 reviews)
3.2
3.2
User Avatar
See private message.
$25.46 USD in 3 days
5.0 (10 reviews)
3.0
3.0
User Avatar
See private message.
$19.55 USD in 3 days
4.7 (17 reviews)
2.6
2.6
User Avatar
See private message.
$28.05 USD in 3 days
5.0 (1 review)
1.5
1.5
User Avatar
See private message.
$7.65 USD in 3 days
5.0 (2 reviews)
0.0
0.0
User Avatar
See private message.
$21.25 USD in 3 days
0.0 (0 reviews)
0.0
0.0
User Avatar
See private message.
$25.50 USD in 3 days
0.0 (0 reviews)
0.0
0.0
User Avatar
See private message.
$29.75 USD in 3 days
0.0 (0 reviews)
0.0
0.0
User Avatar
See private message.
$38.25 USD in 3 days
0.0 (0 reviews)
0.0
0.0

About the client

Flag of UNITED STATES
United States
5.0
4
Member since May 3, 2006

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.