Implement the following classes: Polygon numSide: int /* constructor */ /* accessor-mutator */ + area (): double + perimeter (): double Triangle sideA: double sideB: double sidec: double /* constructor */ /* accessor-mutator */ + area () : double + perimeter (): double Create an object for Triangle class and invoke area and perimeter method. Input Format Take triangle sides (sideA,sideB,sideC) as input from user. Constraints For Triangle, sideB+sideC > sideA
Q: Quiz Task: Create a class Student with following instance private variables and member functions:…
A: The answer is given below.
Q: Preliminaries • Write a Point class with two properties: r, y. Write required constructor, get &…
A: NOTE: As per the policy we can answer only one question at a time, kindly repost the other part to…
Q: create a class rectangle with attributes length and width both encapsulated, each of which defaults…
A: Program code: File name: "Rectangle.java" //import the required packages import…
Q: Design a class Circle with the following Private double data for radius One no arg constructor One…
A: //note: since the programming language is mentioned we are providing answer in cpp #include…
Q: This composition example contains classes Date, Employee and EmployeeTest .Class Date declares…
A: This composition example contains classes Date, Employee and EmployeeTest .Class Date declares…
Q: Create a class circle class with radius as data member. Create two constructors (no argument, and…
A: Class A class is user define interface which act as blueprint for creating objects and instances…
Q: Implement a class called BankAccount that is used to keep track of a bank account. This class will…
A: In the solution of given problem, we define the class BankAccount, with two private members id (int)…
Q: Slide Type Slide · Exercise # 2: Implement a class Portfolio. This class has two objects, checking…
A: Required:
Q: Make a class "Shape" that stores two values: the name of a shape and its area. Initially the name of…
A: A class is the basic building block of object oriented modelling. It contains data and operations on…
Q: Class: Square Create a class called "Square", which is inherited from “TwoDimensionShape”…
A: public abstract class TwoDimensionalShape { //creating abstract method which should be override by…
Q: Make a class "shape" that stores two values: the name of a shape and its area. Initially the name of…
A: Program approach:- Create a class Shape. Constructor that assigns the string to the variable name.…
Q: s that will extend the given Animal class and optionally implement a leg count interface. (Image…
A: Given : Animal.java abstract class Animal { String FUR="fur"; String FEATHER = "feather"; String…
Q: All or Nothing Implement a public class named All that provides a single static method name…
A: We need to create an All class in java language and a static method orNothing. This method received…
Q: using c++ oop !!! kindly need help asap. Implement the shape, rectangle, and square classes with…
A: The question is to write c++ code for the given problem.
Q: Create a class namely Circle and do the following: (i) Circle will have the following member…
A: The program is written in java
Q: Your task is to create a Circle constructor that creates a circle with a radius provided by an…
A: Algorithm - Design a method with one argument as a string. Now use the below logic to solve the…
Q: Write a PaypalAccount class to include both balance and accountID as the instance variables. Make…
A: Java is a programming language was originally developed by James Gosling at Sun Microsystems.
Q: ate a class Rectangle with parameters length, breadth, and color. Use appropriate data types and…
A: public class TestRectangle { public static void main(String[] args) { Rectangle r1=new…
Q: 2019 AP® COMPUTER SCIENCE A FREE-RESPONSE QUESTIONS 2. This question involves the implementation of…
A: Note: As you have not mentioned any programming language, the program is written in JAVA language.…
Q: Write a Rectangle class. A Rectangle has properties of width and length. You construct a Rectangle…
A: Given: A class, Rectangle is designed with two constructors for initializing double data members…
Q: Write a class called Rectangle that implements the Comparable The class should contain three fields:…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: Write an interface as follows: The interface is named ServiceReminder It has one method named…
A: By default interface contains abstract methods. This means that the body of method is not provided…
Q: Preliminaries • Write a Point class with two properties: 1, y. Write required constructor, get &…
A: Please give positive ratings for my efforts. Thanks. PROGRAM class Point { int x,y; public…
Q: Write a Rectangle class that has the following fields: Length (L): a double Width (W): a double The…
A: Since the language was not mentioned , the answer is provided in C++ language. Code: #include…
Q: Create a class Square derived from DrawableShape, as described in the previous exercise. A Square…
A: For classes and methods, the abstract keyword is a non-access modifier: A restricted class that…
Q: Create a rectangle class that can compute the area and the sum of its sides. Create a specialized…
A: Given: To create a rectangle class that can compute the area and the sum of its sides. Create a…
Q: Write a Circle class that has the following field: radius: a double The class should have the…
A: import java.util.Scanner; public class Demo { public static void main(String[] args) { Scanner…
Q: Need help on this. Must be in java. Make the code unique and no plagerism. Implement a Java class…
A: A class named Square is implemented which has one of its coordinates and the side of it as the…
Q: Preliminaries • Write a Point class with two properties: 1, y. Write required constructor, get &…
A: EXPLANATION: - The Point class comprises two instance variables of type double. The parameterized…
Q: Write the Circle class:• A Circle has a radius– Add instance variable– 2 constructors – one should…
A: Create a class Circle and define it's instance variable as private type and just declare default…
Q: Write a Rectangle class that has the following fields: Length (L): a double Width (W): a double The…
A: * Writting program in c++ as no programming language in mentioned in the question. #include…
Q: Create a rectangle class that can compute the area and the sum of its sides. Create a specialized…
A: import java.util.Scanner; public class Rectangle { //class Rectangle int len,…
Q: Write a Rectangle class. Its constructor should accept length and width as a parameter. It should…
A: Answer has been explained below:-
Q: Text Class The Text class inherits from Drawable and it will be used to display the player's score.…
A: It is defined as an interpreted, object-oriented, high-level programming language with dynamic…
Q: Create a Metal class that has at least one weight property. Write proper constructor and other…
A: Java code for above scenario :- class Metal{ public int wt; public Metal(int weight){…
Q: class Point with instance variables as: xCoordinate(int) and yCoordinate(int). Write public instance…
A: Program code: Filename: Point class(PointClass.java) class PointClass{ private int xCoordinate;…
Q: (The HyPoint class) Design a class named MyPoint to represent a point with x- and y-coordinates. The…
A: Answer
Q: This composition example contains classes Date, Employee and EmployeeTest .Class Date declares…
A: public class EmployeeTest { public static void main(String[] args) throws Exception { //create…
Q: Check this code and execute the rectangle class with some modifications: - change to other shapes…
A: Task : Modify rectangle class to show the output of another shape. Add attribute color to the…
Q: Write a class called Dog that contains instance data that represents the dog's (string literal) name…
A: main.java (code) public class Main { public static void main(String[] args) { // Creating…
Q: 1A. Create a Die class with one integer instance variable called sideUp. Give it a constructor and a…
A: Note: Programming language is missing in the question. So we will answer this program in Java…
Q: Implement the above system using inheritance in the best possible way. Keep every object size as…
A: The given system of classes for inheritance are implemented as follows: Class Region acts is…
Q: Design a new Triangle class that extends the abstract GeometricObject class: • Draw the UML diagram…
A: Creating a abstract GeometricObject class defines the abstract functions in that. And extends the…
Q: Create a class Rectangle with parameters length, breadth, and color. Use appropriate data types and…
A: Using C++ Language here
Q: Implement a class Triangle. A Triangle is defined by the x- and y- coordinates of its three corner…
A: Assume a triangle with three points (x1,y1), (x2y2) and (x3, y3) as shown below There are three…
Q: Extend the ItemToPurchase class per the following specifications: Private fields string…
A: import java.util.*;import java.lang.*;import java.io.*; class Item{ private String itemName;…
Q: Define an abstract class Shape with abstract method CalculateSurface() and fields width and height.…
A: class program { static void main(string[] args) { Shape[] shapes = new Shape[6]; shapes[0] = new…
Q: what is needed to be solved: Execute the rectangle class with some modifications: - add color…
A: Answer: Main.cpp: #include <iostream>#include "Rectangle.h"#include "Triangle.h" using…
Q: Design and implement a Java class named Book with two data members: title and price. The class…
A: Class Book contains basic details about book and getter/setter method. Class BookShelf contains an…
Step by step
Solved in 2 steps with 1 images
- 1. Implement the above system using inheritance in the best possible way. Keep every object size as small as possible. Implement all methods (setter/getter/constructors and destructors) Note that the region area is 0 while the city is len*width and the country is the sum of their cities. 2. Create array of countries called Arab of 22 countries, Write a function fill that fills the arrav Arab 3. Write a method that finds the city that has the max area in a country 4. Write a method that sorts the cities in a country from the largest to the smallest area 5. Write a function that retums array of countries of the same area of Arab 6. Write a function that compares between two countries. It returns true if countryl area greater than country2 area. 7. Write a function to move a city from one country to another.Write a class Point with instance variables as: xCoordinate(int) and yCoordinate(int). Write public instance methods (getters & setters) for each instance variable. Now, write a class Circle with private instance variables as radius and Pi (value is 3.14). Write public setter, getter for radius, Area method for calculating Area, Draw method for radius. Formula for calculating area=pi*r^2 Formula for calculating radius= Math.sqrt (xCordinate^2+yCordinate^2) a. Extend a Circle class from Point class such as Class Circle extends Pointb. Write a Default constructor in Circle class that sets radius, xCoordinate & yCoordinate to some default value e.g. -1;c. Write a Parameterized constructor in Circle class which takes xCoordinate, yCoordinate and radius as a parameter.Now write a ColoredCirlce class with private instance variable as color (String) and public setter & getters. Extend the ColoredCircle from Circle and do the following operations.d. Write a default constructor…Define a Polygon interface that has methods area() and perimeter(). Then implement classes for Triangle, Quadrilateral, Pentagon, Hexagon, and Octagon, which implement this interface, with the obvious meanings for the area() and perimeter() methods. Also implement classes, IsoscelesTriangle, Equilateral- Triangle, Rectangle, and Square, which have the appropriate inheritance relationships. Finally, write a simple user interface, which allows users to create polygons of the various types, input their geometric dimensions, and then out- put their area and perimeter. For extra effort, allow users to input polygons by specifying their vertex coordinates and be able to test if two such polygons are similar ORIGINAL WORKS ONLY
- Implement the above system using inheritance in the best possible way. Keep every object size as small as possible. Implement all methods (setter/getter/constructors and destructors) Note that the region area is 0 while the city is len*width and the country is the sum of their cities. Create array of countries called Arab of 22 countries. Write a function fill that fills the array Arab Write a method that finds the city that has the max area in a country Write a method that sorts the cities in a country from the largest to the smallest area Write a function that returns array of countries of the same area of Arab Write a function that compares between two countries. It returns true if country1 area greater than country2 area. Write a function to move a city from one country to another.Write a class Point with instance variables as: xCoordinate(int) and yCoordinate(int). Write public instance methods (getters & setters) for each instance variable. Now, write a class Circle with private instance variables as radius and Pi (value is 3.14). Write public setter, getter for radius, Area method for calculating Area, Draw method for radius. Formula for calculating area=pi*r^2 Formula for calculating radius= sqrt (xCordinate^2+yCordinate^2) Extend a Circle class from Point class such as Class Circle extends Point Write a Default constructor in Circle class that sets radius, xCoordinate & yCoordinate to some default value e.g. -1; Write a Parameterized constructor in Circle class which takes xCoordinate, yCoordinate and radius as a parameter. E.g. Circle (int xCoordinate, int yCoordinate, double radius) { this.xCoordinate= xCoordinate; this.yCoordinate= yCoordinate;…*using java* Create a class AnimalCreate a class Cat, and a class Dog, and a class Bearded Dragon which extend Animal. Add to your Animal class: Member: name Methods: Public Animal(String name) //constructor public void makesSound()with the implementation printing out a generic animal sound. Next, override (add) the makesSound()method to your Cat and Dog class, with the implementation specific to each animal (i.e, cat says purr..). Do not override the makesSound() for your Dragon (bearded dragons don’t make sounds!)Note, you’ll also need a constructor in each of your subclasses which calls super(name) to initialize the common ‘name’ member of Animal. --- Next (in your test harness) create a List of different Animals ( a couple cats, a dog, a dragon... ) and add these Animals to your list. Iterate through your list & call makeSound on each. ( you should observe the implementation of the makeSound() method called will be: cat -> from Cat class, dog-> from Dog class,…
- Create a class Rectangle with parameters length, breadth, and color. Use appropriate data types andaccess specifiers. Write overloaded constructors to create objects of rectangle. First constructor takesall the three parameters. Second constructer takes two parameters length and breadth. If only oneparameter is given then user creates square of red color. Write methods to set and get the values oflength, breadth and color. Write methods to find length of the diagonal of rectangle and to display thecomplete details of rectangle with area. Create another class TestRectangle which uses allconstructors to create the different objects, uses appropriate set and get methods wherever required.Display the details of every rectangle.Create a class Rectangle with parameters length, breadth, and color. Use appropriate data types andaccess specifiers. Write overloaded constructors to create objects of rectangle. First constructor takesall the three parameters. Second constructer takes two parameters length and breadth. If only oneparameter is given then user creates square of red color. Write methods to set and get the values oflength, breadth and color. Write methods to find length of the diagonal of rectangle and to display thecomplete details of rectangle with area. Create another class TestRectangle which uses allconstructors to create the different objects, uses appropriate set and get methods wherever required.Display the details of every rectangle. (IN JAVA LANGUAGE)Write a class that represents a player in a game. The player should have a name, password,experience points, an inventory array of four strings, and a location x,y. Your class shouldhave mutator and accessor methods for all variables. For example: setName(), getName(). Itshould have a suitable display method. Mutators and accessors should be public but allvariables should be private. To implement get inventory, use string * getInv(); Use the scoperesolution operator to implement larger methods such as display(). Use in class methods forshorter methods such as setName(), getName(). (in C++)Example:void setName(string name){this->name = name;}string *getInv();...string* player::getInv(){return inventory;}Note that in the above method setName “this->” is required for disambiguation. If writtenvoid setName(string n){name = n;}“this->” is not required.Write a test program that creates three players and displays them.Example Output:This program generates three player objects and…
- class Point with instance variables as: xCoordinate(int) and yCoordinate(int). Write public instance methods (getters & setters) for each instance variable. Now, write a class Circle with private instance variables as radius and Pi (value is 3.14). Write public setter, getter for radius, Area method for calculating Area, Draw method for radius. Formula for calculating area=pi*r^2 Formula for calculating radius=Math.sqrt(xCordinate^2+yCordinate^2) Extend a Circle class from Point class such as Class Circle extends Point Write a Default constructor in Circle class that sets radius, xCoordinate&yCoordinate to some default value e.g. -1; Write a Parameterized constructor in Circle class which takes xCoordinate, yCoordinate and radius as a parameter. E.g. Circle (int xCoordinate, int yCoordinate, double radius) { this.xCoordinate= xCoordinate; this.yCoordinate= yCoordinate;…1: create a class Pentagon, which implements the RegularPolygon interface. It should have a double field called length, as well as a constructor that initializes this length field to a given value. 2: In the main() method of Pentagon class, add the following code: RegularPolygon sq = new Square(10); RegularPolygon penta = new Pentagon(20); Write code to get the perimeter for sq and penta. 3: In the main() method defined in Q2, add this line of code: sq.getArea(); Will this code pass through compiler? What is the reason? The Java feature in Q1 which create a new version of predefined method getPerimeter() is called Polymorphism Override Overload InheritanceIn Java Write a class definition for a Rectangle class that contains:• Two int fields, length and width.• Mutator and accessor methods for the length and width fields.• A Boolean method named isSquare that returns true if the rectangle’s lengthand width are the same and false otherwise.b) Write a class definition for a RectangleDriver class that contains a main methodthat acts as a driver for the Rectangle class of the previous problem. The main methodshould do this:• Construct a Rectangle object named rect.• Use the mutator methods to assign arbitrary values to rect’s length and widthfields.• Use the Boolean method to determine if rect is a square.-- If rect is a square, print “Square: ” and then the square’s dimensions.For example: Square: 4x4.-- If rect is not a square, print “Rectangle: ” and then the rectangle’sdimensions. For example: Rectangle: 6x13.• In printing the above messages, use the accessor methods to retrieve therectangle’s dimensions