What will the following
#include <iostream>
using namespace std;
class Sky
{
public:
Sky ()
{ cout ≪ “Entering the sky.\n”; }
Sky (string color)
{ cout ≪ “The sky is ” ≪ color ≪ endl; }
∼Sky()
{ cout ≪ “Leaving the sky.\n”; }
};
class Ground : public Sky
{
public:
Ground()
{ cout ≪ “Entering the Ground.\n”; } Ground(string c1, string c2) : Sky(c1)
{ cout ≪ “The ground is “≪ c2 ≪ endl; }
∼Ground()
{ cout ≪ “Leaving the Ground.\n”; }
};
int main()
{
Ground object;
return 0;
}
Want to see the full answer?
Check out a sample textbook solutionChapter 15 Solutions
REVEL for Gaddis C++ -- Access Card (What's New in Computer Science)
Additional Engineering Textbook Solutions
Starting Out with C++: Early Objects
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Absolute Java (6th Edition)
Concepts of Programming Languages (11th Edition)
Web Development and Design Foundations with HTML5 (8th Edition)
- q ) Employee class is having three properties known as name, EmployeeID, address. Writea Java program to create class with two constructors one with no arguments, anotherwith three arguments.arrow_forwardIn C++ Language: Suppose I have a class named Person. Here is how I would like to use the class: //Create a person named Dave Smith Person dave("Smith", "Dave", 'R'); //Create a person named Gal Gadot Person gal("Gadot", "Gal", 'G'); //Dave and Gal gets married gal = dave + gal; dave = dave + gal; //print Gal and Dave's new married name cout << gal << endl; cout << dave << endl; This will output the following: Gal Smith-Gadot Dave Smith-Gadot Write the class declaration for Personarrow_forwardPlease help me with this using java. And comment the code The following is some code designed by J. Hacker for a video game. There is an Alien class to represent a monster and an AlienPack class that represents a band of aliens and how much damage they can inflict: class Alien { public static final int SNAKE_ALIEN = 0; public static final int OGRE_ALIEN = 1; public static final int MARSHMALLOW_MAN_ALIEN = 2; public int type; // Stores one of the three above types public int health; // 0=dead, 100=full strength public String name; public Alien ( int type , int health, String name) { this.type = type; this.health = health; this.name = name; } } public class AlienPack { private Alien[] aliens; public AlienPack (int numAliens) { aliens = new Alien[numAliens]; } public void addAlien(Alien newAlien, int index) { aliens[index] = newAlien; } public Alien[] getAliens() { return aliens; } public int calculateDamage() { int damage = 0; for (int i=0; i < aliens.length; i++) { if…arrow_forward
- 1. I Love Shapes by Codechum Admin Shapes are the best thing in the world! We see them everywhere, from triangular pizza pies to her perfectly shaped almond eyes ? For this program, you are tasked to implement the Shape class. This class should be an abstract class and should have the following properties: private String name private String color private boolean isFlat It should have a constructor with the following signature, public Shape(String name, String color, boolean isFlat), getter methods for all the properties, and a setter method for the color. Then implement two more abstract classes that inherit from this Shape class: TwoDShape and ThreeDShape. The TwoDShape will have the following additional details: Additional property: private int numberOfSides Additional methods: getter for the numberOfSides public abstract double getArea() public abstract double getPerimeter() Constructor with the following signature: public TwoDShape(String name, String color,…arrow_forwardCircle Class (This is in JAVA) /** * Defines a basic shape with just area * * @author Jo Belle * @version 0.2 (10/05/2020) */ public class Shape{ private double area; public Shape(){ area = 0.0; } public Shape( double a ){ this.area = a; } public void setArea( double a ){ area = a; } public double getArea(){ return area; } public String toString(){ return "Shape:\n\tarea: " + area; } }/** * Create a simple Circle object * * @author Jo Belle * @version 0.2 (10/12/2020) */ public class ShapeDriver{ public static void main( String[] args ){ Circle cir = new Circle( ); cir.setRadius( 5.0 ); System.out.println( cir.toString() ); } } Given the code above, write a Circle class (and save it in a file named Circle.java) that inherits from the Shape class. Include in your Circle class, a single private field double radius. Also include a method void setRadius(double r) (which also sets area) and a method double getRadius() (which also returns the current radius). Change the accessibility…arrow_forwardCreate a class called Pizza (Pizza.java). It should have the following private data members: String size: size of the pizza could be small, medium, or large int numOfToppings: number of toppings could be 1, 2 or 3. double price and should provide the following methods: default constructor (set size to an empty string, numOfTopping and price to 0) non-default constructor Pizza(String s, int n, double p) getters and setters for the three data members method toString()returns a string representing the Pizza object, formatted as: Size: large Toppings: 2 Price: 9.95 method equals (Object obj) to indicate some other object is “equal to” this one public class Pizza { }arrow_forward
- Create a class called Pizza (Pizza.java). It should have the following private data members: String size: size of the pizza could be small, medium, or large int numOfToppings: number of toppings could be 1, 2 or 3. double price and should provide the following methods: default constructor (set size to an empty string, numOfTopping and price to 0) non-default constructor Pizza(String s, int n, double p) getters and setters for the three data members method toString()returns a string representing the Pizza object, formatted as: Size: large Toppings: 2 Price: 9.95 method equals (Object obj) to indicate some other object is “equal to” this one public class Pizza { } Complete the following unit test for the class Pizza described above. Make sure to test each public constructor and each public method, print the expected and actual results. // Start of the unit test of class Pizza public class PizzaTester { public static void main(){ // Your source codes are placed here return; } }arrow_forwardhello! can you help debug my program? it's in Java! here are the errors I'm getting: line 189: total_weight cannot be resolved or is not a fieldline 93: the type Snake must implement the inherited abstract method Animal.makeNoise()line 139: the method actual_num_animals(int) is undefined for the type Zooline 152: the left-hand side of an assignment must be a variableline 169: syntax error, insert } to complete Blockline 152: syntax error, insert “. class” to complete expressionline 139: syntax error on token “<“, ( expectedline 139: syntax error on token “{“ invalid AssignmentOperatorline 152: i cannot be resolved to a variableline 152: i cannot be resolved to a variableline 154: i cannot be resolved to a variable here is my code: package zoo; public abstract class Animal { private String name; private double weight; private int age; public Animal() { name=""; weight=0; age=0; } public Animal(String name, double weight, int age) { this.name = name; this.weight = weight;…arrow_forward/* TestCarSensor.java - program to test the CarSensor class.*/public class TestCarSensor{public static void main (String[] args){CarSensor generic = new CarSensor();CarSensor tempCel = new CarSensor("temperature sensor", -50, +300, "C"); CarSensor speed = new CarSensor("speed sensor", 0, 200, "km/h"); CarSensor speed2 = new CarSensor("speed sensor 2", 0, 200, "m/h"); // 2. test changing desc and limitsSystem.out.println ();System.out.println ( generic ); // display generic sensor (zero)generic.setDesc ("special sensor"); // change descriptiongeneric.setLimits (-5,5,"units"); // change limitsSystem.out.println ( generic ); // display generic sensor again// 3. test displaying object (calling .toString() )System.out.println ();System.out.println ( tempCel );System.out.println ( speed );System.out.println ( speed2 );// 4. test setlimits() ruleSystem.out.println ();System.out.println ( generic ); generic.setLimits (10, -10, "blah"); System.out.println ( generic ); generic.setLimits (-10,…arrow_forward
- write a cooments of every single line of code of the following: public class MyBean{ private String name; private String city; private String country; private static final String[] VALID_COUNTRIES = {"GB","US","DE"}; private static final String[] VALID_CITIES = { {"London","Oxford","Leeds"}, {"New York","Los Angeles","Miami"}, {"Berlin","Frankfurt","Baden-Baden"} }; private static final String[] DEFAULT_CITIES = {"Leeds","Miami","Berlin"}; private static final String[] DEFAULT_COUNTRY = "GB"; private static final String[] DEFAULT_CITY = "Leeds"; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getCity() { return city; } public void setCity(String city) { this.city = validateCity(city); } public String getCountry() { return country; } public void setCountry(String country) {…arrow_forwardclass gene { public: gene( ); gene(string n, string cl); string get_genename( ); //required the user to input the gene name. void print( ); private: string name; string chromosomal_location; }; a. Define the class gene. b. What kind of function overloading is achieved in this code? c. Define the constructor gene(string n, string cl) in such a way that user will input the name of the gene, which will be assigned to the variable “name”. d.Run this complete program on your computer and paste the screenshots of the output. e. Are the following two constructor functions possible in this class code? i. gene(string n); ii. gene(string cl);C++ coding (do this in C++ programming)arrow_forwardwhat problem in this java code cant find the main, can you check code package EmployeePersonal; //create a Driver class public class Driver { //Define main() method public static void main(String[] args) { //create object for sub class "Employee" Employee obj=new Employee(); //Call the super class member function setName() using object of sub class "Employee" obj.setName("David"); //Call the super class member function setAge() using object of sub class "Employee" obj.setAge(35); //Call the super class member function setAddress() using object of sub class "Employee" obj.setAddress("Chicago"); //Call the super class member function setPhone() using object of sub class "Employee" obj.setPhone(25648713); //Call the function to set employeeid obj.setEmployeeID(100); //Call the function to set department…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education