C How to Program (8th Edition)
C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
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.

Blurred answer
Students 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.
Activity: Create a collection of objects using Java generics.  use java to write code. Create a Month class that can accept integer or String data type as an argument. The parameter type will be decided at run time. For this exercise, we will use Month class to store integer and string values that contains 12 months. For example, the integer value of 12 corresponds to string value of “December.” Use the following minimal class definition for Month class. public class Month<T> { private T month; public void setMonth(T month); public T getMonth(); }; Create a new class, MonthApp. This new class will have main method, and will instantiate Month objects to store month indices and names. Here is an example using arrays. // defineMonth<Integer>[] monthsByNumber = new Month<>[12];Month<String>[] monthsByName = new Month<>[12];// adding valuesmonthsByNumber[0] = new Month<Integer>();monthsByNumber[0].setMonth(1);monthsByName[0] = new…
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.
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning