/*
*/
package circle;
import static javax.swing.Spring.height;
public class Circle {
int radius;
public int setRadius(){
return radius;
}
public int getRadius(){
return radius;
}
public float Circumference(float r){
return (float) (2*(Math.PI))*r;
}
public float Area(float radius){
return (float) (radius*radius*(Math.PI));
}
public static void Display(){
System.out.print(" ");
}
public static void main(String[] args) {
Circle c=new Circle();
c.Area((float) 2.5);
c.Circumference((float) 2.5);
Circle.Display();
}
public static class Cylinder{
int Height;
int Base;
public int setHeight(){
//int setHeight = 0;
return Height;
}
public int getHeight(){
return Height;
}
public int setBase(){
//int setBase = 0;
return Base;
}
public int getBase(){
return Base;
}
public float Area(float r,float h){
return (float) ((float) (2*(Math.PI))*r*r+(2*(Math.PI))*r*h);
}
public float Volume(float r,float h){
return h*(float)(Math.PI)*r*r;
}
public static void Display(){
System.out.println(" ");
}
public static void main(String []args){
Cylinder c1=new Cylinder();
c1.Area((float) 2.5, 5);
c1.Volume((float) 2.5, 5);
Cylinder.Display();
}
}
}
Exercise 1: A circle is defined by its radius (we are not interested in its center)....
C++ code For each of the following classes create default constructor and parameterized constructors(calling parent(s) parameterized constructors where it applies Add accessor and mutator function for the attribute inherent to the class Create a Base class called Shape2d with the protected floating point attribute area operator overload the + & - and operations to return the float respective to the area Derive from the Base class from called Shape2d called Rectangle with the additional floating-point attributes length & width Derive...
C++ Chapter 10 defined the class circleType to implement the basic properties of a circle. (Add the function print to this class to output the radius, area, and circumference of a circle.) Now every cylinder has a base and height, where the base is a circle. Design a class cylinderType that can capture the properties of a cylinder and perform the usual operations on the cylinder. Derive this class from the class circleType designed in chapter 10. Some of the...
Exercise 2: There can be several constructors as long as they differ in number of parameters or data type. Alter the program so that the user can enter just the radius, the radius and the center, or nothing at the time the object is defined. Whatever the user does NOT include (radius or center) must be initialized somewhere. There is no setRadius function and there will no longer be a setCenter function. You can continue to assume that the default...
Using separate files, write the definition for a class called Point and a class called Circle. The class point has the data members x (double) and y (double) for the x and y coordinates. The class has the following member functions: a) void set_x(double) to set the x data member b) void set_y(double) to set the y data member c) double get_x() to return the the x data member d) double get_y() to return the the y data member e)...
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...
Part 1: Use principles of inheritance to write code calculating the area, surface area, and volume of rectangular objects. First, write an abstract super class RectangularShape, then write a subclass Rectangle that inherits from the super class to compute areas of rectangles, including squares if there is only one data. Finally, write another subclass Cuboid that inherits from its super class Rectangle above to compute surface areas and volumes of cuboids, including 3 equal sided cube. Must apply code-reusability in...
C++ Question 1) Consider a class Point that models a 2-D point with x and y coordinates. Define the class point that should have the following Private data members x and y (of type int), with default values of 0 A constant ID of type int A private static integer data member named numOfPoints This data member should be o Incremented whenever a new point object is created. o Decremented whenever a point object is destructed. A default constructor An...
Project 7: Vehicles 1 Objective In the last couple projects, you’ve created and used objects in interesting ways. Now you’ll get a chance to use more of what objects offer, implementing inheritance and polymorphism and seeing them in action. You’ll also get a chance to create and use abstract classes (and, perhaps, methods). After this project, you will have gotten a good survey of object-oriented programming and its potential. This project won’t have a complete UI but will have a...
Written in python using puTTy!! i'm having a lot of trouble with this, will upvote! also here is the address.csv file Name,Phone,Email,Year_of_Birth Elizi Moe,5208534566,[email protected],1978 Ma Ta,4345667345,[email protected],1988 Diana Cheng,5203456789,[email protected],1970 ACTIVITY I Implement in Python the Subscriber class modeled by the UML diagram provided below. Save in a file called MyClasses.py Subscriber name: string yearOfBirth: int phone: string email: string getName() getAge() getPhone() getEmail() Write a test program that does the following: Read the file addresses.csv. For each record, create an object...