C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 17, Problem 17.21E
Program Plan Intro
Program plan:
- Define class IntegerSet. Inside this class,
- Include a private data member setwhich is an array of size 100of type int.
- Include a constructor to initialize above data member to zero.
- Provide a function insertElement to addinteger element to the set.
- Provide a function deleteElement to delete an element fromthe set.
- Provide a function unionOfSets to find union of two integer sets.
- Provide a function intersectionOfSets to find intersection of two integer sets.
- Provide a function isEmpty to check if the set is empty.
- Provide a function isEqualTo to check if two sets are equal.
- Provide a function printSet to print the values in the set.
- Define a main function. Inside main function,
- Define four objects set1, set2, set3 and set4 of IntegerSet class.
- Use all of IntegerSet class functions on these objects.
Program Description: The following program will create aIntegerSet class to represent the set of integers numbers and include functions for operations on two integer sets.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(Tic-Tac-Toe) Write a program that allows two players to play the tic-tac-toe game. Your program must contain the class ticTacToe to implement a ticTacToe object. Include a 3-by-3 two-dimensional array, as a private member variable, to create the board. If needed, include additional member variables. Some of the operations on a ticTacToe object are printing the current board, getting a move, checking if a move is valid, and determining the winner after each move. Add additional operations as needed.
Question 2: (TicTacToe Class)
Create a class TicTacToe that will enable you to write a complete program to play the game of
tic-tac-toe. The class contains as private data a 3-by-3 two-dimensional array of integers. The
constructor should initialize the empty board to all zeros.
Allow two human players. Wherever the first player moves, place a 1 in the specified square.
Place a 2 wherever the second player moves. Each move must be to an empty square. After
each move, determine whether the game has been won or is a draw. If you feel ambitious,
modify your program so that the computer makes the moves for one of the players. Also, allow
the player to specify whether he or she wants to go first or second.
# Coding - Simulate a robot
Write a program that simulates the movements of a robot. The robot can have three possible movements:
turn right turn left advance
The robot is placed on a hypothetical infinite grid, facing a particular direction (north, east, south, or west) at a set of `{x,y}` coordinates,e.g., `{3,8}`, with coordinates increasing to the north and east.
Create a Class `Robot` that contains a method `execute` which given a number of instructions will calculate the robot's new position, and the the direction in which it is pointing.
## Example
The letter-string "RAALAL" means:
Turn right Advance twice Turn left Advance once Turn left yet again
Say a robot starts at `{7, 3}` facing north. Running this stream of instructions should leave it at `{9, 4}` facing west.
## Inputs and Outputs
The argument of the `execute` is `string` in the format `X Y BEARING COMMANDS`. The method should return a one-liner `string` in the format `X Y BEARING`. In the…
Chapter 17 Solutions
C How to Program (8th Edition)
Ch. 17 - (Scope Resolution Operator) Whats the purpose of...Ch. 17 - (Enhancing Class Time) Provide a constructor thats...Ch. 17 - (Complex Class) Create a class called Complex for...Ch. 17 - (Rational Class) Create a class called Rational...Ch. 17 - Prob. 17.7ECh. 17 - Prob. 17.8ECh. 17 - Prob. 17.9ECh. 17 - Prob. 17.10ECh. 17 - (Rectangle Class) Create a class Rectangle with...Ch. 17 - (Enhancing Class Rectangle) Create a more...
Ch. 17 - Prob. 17.13ECh. 17 - (Hugelnteger Class) Create a class Hugelnteger...Ch. 17 - (TicTacToe Class) Create a class TicTacToe that...Ch. 17 - Prob. 17.16ECh. 17 - (Constructor Overloading) Can a Time class...Ch. 17 - Prob. 17.18ECh. 17 - Prob. 17.19ECh. 17 - (SavingsAccount Class) Create a SavingsAccount...Ch. 17 - Prob. 17.21ECh. 17 - (Time Class Modification) It would be perfectly...Ch. 17 - Prob. 17.23ECh. 17 - Prob. 17.24ECh. 17 - (Project: Card Shuffling and Dealing) Use the...Ch. 17 - Prob. 17.26ECh. 17 - (Project: Card Shuffling and Dealing) Modify the...Ch. 17 - (Project: Emergency Response Class) The North...
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Rewrite the client program to use the Baby class that you have done using ArrayList. You should also have the following function in this new client program: a) Enter details for each baby (name and age) and thus populate the Baby ArrayList b) Calculate and display the average age of all babies in the ArrayList c) Ask the user to enter the name of a baby, and then remove it from the ArrayList d) Allow the user to add new baby information in the ArrayList e) Output the details of each baby from the ArrayList (name and age) Compare this client program using the ArrayList with the client program you have done using array, comment on the differences between the two. Modify your client program in the last question, by adding a sort function such that when that option is selected, it sorts the ArrayList using the baby names in alphabetical order and output the details in the sorted ArrayList to a CSV (sortedbabylist.csv) file. public class Baby { private String name; private int age;…arrow_forwardDon't use vector array .using ifstream and ofstream. C++ programarrow_forward2 photos for the questionarrow_forward
- def winning_card(cards, trump=None): Playing cards are again represented as tuples of (rank,suit) as in the cardproblems.pylecture example program. In trick taking games such as whist or bridge, four players each play one card from their hand to the trick, committing to their play in clockwise order starting from the player who plays first into the trick. The winner of the trick is determined by the following rules:1. If one or more cards of the trump suit have been played to the trick, the trick is won by the highest ranking trump card, regardless of the other cards played.2. If no trump cards have been played to the trick, the trick is won by the highest card of the suit of the first card played to the trick. Cards of any other suits, regardless of their rank, are powerless to win that trick.3. Ace is the highest card in each suit.Note that the order in which the cards are played to the trick greatly affects the outcome of that trick, since the first card played in the trick…arrow_forward[In c#] Write a class with name Arrays . This class has an array which should be initialized by user.Write a method Sum that should sum even numbers in array and return sum. write a function with name numFind in this class with working logic as to find the mid number of an array. After finding this number calculate its factorial.Write function that should display sum and factorial.Don’t use divide operatorarrow_forwardQ2:- Write C++ program that create class called (car) that have arrays of stack and top variables private. The objects are C1 and C2, Do the following operations: fill locations (0,1,2 and 3) in object C1 by following statement (BMW,KIA,DOG, TOYOTA) fill locations (0,1,2 and 3) in object C2 by speed of these CARS according to the following data: Read distance and time and find the speed by following equation: speed-distance/time. Fill the last location in array stack of object C2 by the smaller speed.arrow_forward
- Don't use vector array .using c++ languagearrow_forwardData Structure & Algorithum java program Do the following: 1) Add a constructor to the class "LList" that creates a list from a given array of objects.2) Add a method "addAll" to the "LList" class that adds an array of items to the end of the list. The header of the method is as follows, where "T" is the generic type of the objects in the list. 3) Write a Test/Driver program that thoroughly tests all the methods in the class "LList".arrow_forwardAttach code and screenshotarrow_forward
- (Find the nonleaves) Java Define a new class named BSTWithNumberOfNonLeaves that extends BST with the following methods: /** Return the number of nonleaf nodes */public int getNumberofNonLeaves() // BEGIN REVEL SUBMISSION class BSTWithNumberOfNonLeaves<E> extends BST<E> { /** Create a default BST with a natural order comparator */ public BSTWithNumberOfNonLeaves() { super(); } /** Create a BST with a specified comparator */ public BSTWithNumberOfNonLeaves(java.util.Comparator<E> c) { super(c); } /** Create a binary tree from an array of objects */ public BSTWithNumberOfNonLeaves(E[] objects) { super(objects); } public int getNumberOfNonLeaves() { return getNumberOfNonLeaves(root); } /** Returns the number of non-leaf nodes */ private int getNumberOfNonLeaves(TreeNode<E> root) { // WRITE YOUR CODE HERE } } // END REVEL SUBMISSIONarrow_forward(Enhancing Class Rectangle) Create a more sophisticated Rectangle class than the one youcreated in Exercise 17.11. This class stores only the Cartesian coordinates of the four corners of therectangle. The constructor calls a set function that accepts four sets of coordinates and verifies thateach of these is in the first quadrant with no single x- or y-coordinate larger than 20.0. The set function also verifies that the supplied coordinates do, in fact, specify a rectangle. Provide member functions that calculate the length, width, perimeter and area. The length is the larger of the twodimensions. Include a predicate function square that determines whether the rectangle is a squarearrow_forwardMatch (std::array member function on left with the correct description on right. Hint: You might want to look this up here . fill at begin empty swap [Choose ] [Choose ] returns an iterator pointing to the first element in the array container. returns a direct reference to the first element in the array container. returns a const_iterator pointing to the first element in the array container. set all the values in the array with the parameter passed. check whether array is empty. returns a reference to the element at position, i passed as the parameter. exchanges the content of the array by the content of another array object of the same type and the same size. [Choose ] [Choose ] >arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning