Write a program to swap the values of private data members of a class named as class_1 and class_2 by using the concept of friend classes.
Q: write an oop program using c++ consist from two classes (base class) represent a person with…
A: Person is a base class and Employee is child class and thus the methods declared inside Person class…
Q: In c#, a class can inherit directly from multiple classes? A.) True B.) False
A: Multiple inheritance allow a subclass to inherit from two or more classes.
Q: C++ is a programming language that can be used to Make a program that calculates the volume of…
A: C++ Program: #include <iostream>using namespace std; // Make a constant for piconst float pi =…
Q: The base class Pet has attributes name and age. The derived class Dog inherits attributes from the…
A: class Pet: def __init__(self,name,age): #constructor of Pet class self.name=name…
Q: Write a class having two private variables and one member function which will return the area of the…
A: The asked C++ program code is coded in the next step and is explained by using comments.
Q: Demonstrate your class works with a main() function that instantiates an array of three Rectangle…
A: #include <iostream>using namespace std;class Rectangle{private: double width; double…
Q: Suppose Chair is a class and c1 and c2 are objects of the Chair class. In order for the following…
A: new operator is used to allocate memory for an object and constructors are invoked while creating…
Q: Can a class be a super class and a sub-class at the same time? Give example.
A: Yes, Lets Take an Example:
Q: b. Modify the Downdog Yoga Studio program so that numeric class requests can be entered continuously…
A: I'm providing you the code, output of code & flow chart which you required. I hope this answer…
Q: Write a program that does the following: 1-Define two classes Teacher and Department. Each…
A: a program that does the following: Define two classes Teacher and Department Explanation:…
Q: If class A is a subclass of class B, then A has access to all of B's instance variables, including…
A: Private data: A private data can be accesses within the class only. Private data not allowed to…
Q: Suppose that class Child extends class Parent, and that Parent does not explicitly extend another…
A: At the point when a child object is made and no contentions I passed then a super keyword is related…
Q: Using the information given above, create the following three classes. a. A parent class named…
A: C++ Code: #include <iostream>using namespace std; class Person{ private: string…
Q: Write a program to use Friend function within three classes. The classes are pk901, pk902, pk903 and…
A: A friend function is a special function that can access the private members of a class as though it…
Q: Suggest a simple scheme for creating a new class SafeMember that would allow us to export a…
A: Given: Suggest a simple scheme for creating a new class SafeMember that would allow us to export a…
Q: Task 2: Write a program to define two classes A and B to preserve the values of length of wires as…
A: The solution involves use of classes, operator overloading.
Q: Let B be a class with a constructor that can receive an int as its parameter_
A: Given :- In the above given question, a code or statement is mention in the above given question…
Q: Write a program that defines a class with a data member to holds a “serial number” for each object…
A: PROGRAM CODE: #include <iostream> using namespace std; class Test{private://the static keyword…
Q: a new class SafeMember that would allow us to export a reference to a Member. The classes outside…
A: Suggest a simple scheme for creating a new class SafeMember that would allow us to export a…
Q: Design the class doctorType, inherited from the class personType with an additional data member to…
A: As per our company guidelines, we are not supposed to answer more than 3 subparts of question and…
Q: 1. Based on the below UML diagram, write the implementation code to represent each class? 2. in the…
A: Given:- Code this in c sharp
Q: . Write a class named Point such that it works as in the main below.
A: C++ programming is an object-oriented programming language, It will also be supported by procedural,…
Q: Create a class employee with the data members,name,id and salary as private data member . Create…
A: Step 1:- Program Approach:- 1.Include the header file 2.Create the class employee with its data…
Q: uggest a simple scheme for creating a new class SafeMember that would allow us to export a reference…
A: solution:
Q: 1. Based on the below UML diagram, write the implementation code to represent each class? 2. in the…
A: Below is the required C sharp program. Program Approach: Define a class as Dog. Inside the dog…
Q: using c++: Write a class service (servant_name, tip, and the static total_tip and static…
A: /******************************************************************************…
Q: b. Modify the Downdog Yoga Studio program so that numeric class requests can be entered continuously…
A: I'm providing you the code, output of code & flow chart which you required. I hope this answer…
Q: Consider, the code: public class MyClass { public MyClass() { // some code } // some more code } To…
A: Question 1 In order to initiate MyClass , you need to create create an object for that which is…
Q: Write the definition of the default constructor of YClass so that the instance variables of YClass…
A: public YClass() { this.a=0; this.b=0; }
Q: What is a singleton class? Give a practical example of its usage.
A: Singleton class: Singleton is nothing but a concept of object-oriented programming language which…
Q: Write a class called Person that has two private data members - the person's name and age. It should…
A: Below is the code:- class Person(): def __init__(self, name, age): self.__name = name…
Q: Write a java program, that makes two text files then store 10 employee information e.g., EmpID,…
A: 1- In this assignment, Create an employee class and three string type variables. 2- Note: Please…
Q: Add an unusual copy constructor for the Point class. When the copy constructor is invoked, it will…
A: pointCloud *x = new pointCloud; The above line creates a new pointCloud object. Since no parameter…
Q: C++ is a programming language that can be used to Make a program that calculates the volume of…
A: Ans: Code: #include <iostream> using namespace std;class Cylinder { float r, h; public :…
Q: A(n)_ is a class that only contains virtual functions that are pure virtual. Fill in the blanks with…
A: Introduction to Abstract classes A class that has been declared abstract is one that may or may not…
Q: Class student inherits from superclass Person. Which assignment is legal? a) Student s = new…
A: class Person { //Code } class Student extends Person { //code } A subclass inherits all the…
Q: 2. Implement the following classes: Person Employee name: String age: int address: String…
A: Answer: Java Source Code: Main.java: public class Main{ public static void main (String[] args) {…
Q: Suppose, we have two related (child) classes named Doctor and Patient. Data members required by each…
A: As you have not mentioned the programming language to be used but description is showing that you…
Q: Write a class definition that creates a class called leverage with one private data member, crowbar,…
A: PROGRAM CODE: class leverage // start definition of class leverage{…
Q: Write a program (read and print information) that simulates the three classes defined as shown…
A: Inheritance is a concept in which one class acquires the properties of another class. An inheriting…
Q: Write a class called Person that has two private data members - the person's name and age. It should…
A: Python code for the given problem :- def std_dev(list) : sum = 0 for p in list: sum…
Q: uggest a simple scheme for creating a new class SafeMember that would allow us to export a reference…
A: Scheme: Many accessor methods need to return values which are references to objects which represent…
Q: The task is to implement two classes: Shopping Cart and Item according to the following…
A: Ans:) NOTE: As the programming language is not mentioned here so i am going to use python for this…
Q: write a class having three variables and one member function which will return the area of the…
A: Program: //included header file #include<iostream> //included namespcace using namespace std;…
Q: Write a program to overload the delete operator so that it works with objects of a class which…
A: #include<iostream>#include<stdlib.h> using namespace std;class student{ string name; int…
Q: Write a program to add members of two different classes using friend Function. Problem: Design:…
A: Friend function- It is a function which is used to access private and protected members of different…
Write a program to swap the values of private data members of a class named as class_1 and class_2 by using the concept of friend classes.
Step by step
Solved in 2 steps
- dayType Class We will be working on a project that designs a class calendarType, so that a client program can use this class to print a calendar for any month starting Jan 1. 1900. An example of the calendar for September 2019 is: September 2019 Sun Mon Tue Wed Thu Fri Sat 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 We will develop several classes which will work together to create a calendar. The first of these classes is called dayType which will manipulate a day of the week. The class dayType will store a day, such as Sun for Sunday. The class should be able to perform the following operations on an object of type dayType: a. Set the day. b. Print the day. c. Return the day. d. Return the next day. e.…Write in python. Write a class named Employee that has **private** data members for an employee's name, ID_number, salary, and email_address. It should have an init method that takes four values and uses them to initialize the data members. It should have get methods named get_name, get_ID_number, get_salary, and get_email_address.Write a separate function (not part of the Employee class) named **make_employee_dict** that takes as parameters a list of names, a list of ID numbers, a list of salaries and a list of email addresses (which are all the same length). The function should take the first value of each list and use them to create an Employee object. It should do the same with the second value of each list, etc. to the end of the lists. As it creates these objects, it should add them to a dictionary, where the key is the ID number and the value for that key is the whole Employee object. The function should return the resulting dictionary.For example, it could be used like…Write a C# program that uses a class called ClassRegistration as outlined below: The ClassRegistration class is responsible for keeping track of the student id numbers for students that register for a particular class. Each class has a maximum number of students that it can accommodate. Responsibilities of the ClassRegistration class: It is responsible for storing the student id numbers for a particular class (in an array of integers) It is responsible for adding new student id numbers to this list (returns boolean) It is responsible for checking if a student id is in the list (returns a boolean) It is responsible for getting a list of all students in the class (returns a string). It is responsible for returning the number of students registered for the class (returns an integer) It is responsible for returning the maximum number of students the class is allowed (returns an integer) It is responsible for returning the name of the class. (returns a string)
- Write a C#program that uses a class called ClassRegistration as outlined below: The ClassRegistration class is responsible for keeping track of the student id numbers for students that register for a particular class. Each class has a maximum number of students that it can accommodate. Responsibilities of the ClassRegistration class: It is responsible for storing the student id numbers for a particular class (in an array of integers) It is responsible for adding new student id numbers to this list (returns boolean) It is responsible for checking if a student id is in the list (returns a boolean) It is responsible for getting a list of all students in the class (returns a string). It is responsible for returning the number of students registered for the class (returns an integer) It is responsible for returning the maximum number of students the class is allowed (returns an integer) It is responsible for returning the name of the class. (returns a string) ClassRegistration -…Question: Write a program to Simulate a game of tic tac toe. A game of tic tac toe has two players. A Player class is required to store /represent information about each player. The UML diagram is given below. Player -name: string -symbol :char Player (name:string,symbol:char) getName():string getSymbol():char getInfo():string The tic tac toe board will be represented by a two dimensional array of size 3 by 3 characters. At the start of the game each cell is empty (must be set to the underscore character ‘_’). Program flow: Your program must ask for each player’s name and their special symbol or character (usually an ‘X’ or ‘O’). Display each player’s name and symbol. The program must then display the board (the 2 dimensional array). The player whose turn it is has their name displayed and is asked for a row and column number to place their symbol. They can enter -1 -1 as the row and column number to quit. Repeat 2 and 3 until one player enters -1 -1. Your…3. Person and Customer Classes The Person and Customer Classes Write a class named Person with data attributes for a person’s name, address, and telephone number. Next, write a class named Customer that is a subclass of the Person class. The Customer class should have a data attribute for a customer number, and a Boolean data attribute indicating whether the customer wishes to be on a mailing list. Demonstrate an instance of the Customer class in a simple program.
- Write a program that declares two classes. The parent class is called Simple that has two data members num1 and num2 to store two numbers. It also has four member functions. The add() function adds two numbers and displays the result. The sub() function subtracts two numbers and displays the result. The mul() function multiplies two numbers and displays the result. The div() function divides two numbers and displays the result. The child class is called Complex that overrides all four functions. Each function in the child class checks the value of data members. It calls the corresponding member function in the parent class if the values are greater than 0. Otherwise, it displays error message. SUBJECT: OBJECT ORIENTED PROGRAMMING. WRITE CODE IN C++In C++ create a program that acts like a bank account. It asks the user whether to deposit or withdraw. That has 3 classes. The first class must be a generic class that holds basic info deposit, withdraw, calculate monthly interest rate, and a monthly service fee.The second class must be a savings account class that if the savings account falls below $25 it becomes inactive. The final class must be a checking account if someone withdraws more than what they have a service charge of $15 is added and go into a negative balance. The output should display the basic information how much someone deposited or withdrew and their monthly interest rate.IN C++, Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four pieces of information as instance variables - a part number (type String), a part description (type String), a quantity of the item being purchased (type int) and a price per item (double). Your class should have a constructor that initializes the four instance variables. Provide a set and a get method for each instance variable. In addition, provide a method named getInvoiceAmount that calculates the invoice amount (i.e., multiplies the quantity by the price per item), then returns the amount as a double value. If the quantity is not positive, it should be set to 0. If the price per item is not positive, it should be set to0. Write a test app named InvoiceTest that demonstrates class Invoice's capabilities.
- Suppose that a class is defined to represent a deck of cards or a player's hand in a card game. This class is implemented as below: A class, also, is defined to develop a card game in which a list of all players' names and their hand is stored. Part of the implementation of this class looks like the following code: A) Specify what should be the return type of getPlayersHand()? B) Assume that the cardGame is a composition of Deck. With this assumption, i) implemnt getPlayerHand(). ii) implement the overloaded constructor of Deck. No java methods can be used for part ii. C) Assume that cardGame is an aggregation of Deck. With this assumption, implement getPalyerHand(). D) An equals() method has been implemented for Deck class. Fill in the gaps to create a fully working equals() method.Write a program that declares two classes. The parent class is called Simple that has two data members’ num1 and num2 to store two numbers. It also has four member functions.· The add() function adds two numbers anddisplays the result.· The sub() function subtracts two numbersand displays the result.· The mul() function multiplies twonumbers and displays the result.The div() function divides two numbersand displays the result. The child class is called Complex that overrides all four functions. Each function in the child class checks the value of data members. It calls the corresponding member function in the parent class if the values are greater than 0. Otherwiseit displays error message.In 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 Person