Create a class named integerset.

Assignment Help JAVA Programming
Reference no: EM13942134

I need a solution (2 .java files) for the following question. The solution is not to be in the form of an applet. Rather it is to be just .java files. The deadline for this solution is Monday May 5, 2003 at 12:00 Noon.

The first .java file will be named IntegerSet and will incorporate these characteristics:

Create a class named IntegerSet. Each object of the class can hold integers in the range 0 through 100.

A set is represented internally as an array of Booleans. Array element a[i] is true if integer "i" is in the set. Array element a[j] is false if integer "j" is not in the set. The no-argument constructor initializes a set to the so-called "empty set" (i.e., a set whose array representation contains all "false" values).
Provide the folling constructors:
1. A default constructor that initializes a set to the "empty set" in which all Boolean values in the array are set to "false."

2. A second constructor that accepts an IntegerSet object as an argument and creates a new IntegerSet object that is a copy of the original object

Provide the following methods:

1. Method unionOfIntegerSets creates a third set which is the set-theoretic union of the two existing sets (i.e., an element of the third set's array is set to "true" if that element appears in either or both of the existing sets; otherwise, the element of the third set is set to "false).

2. Method intersectionOfIntegerSets creates a third set which is the set-theoretic intersection of the two existing sets i.e., an element of the third set's array is set to false if that element is "false" in either or both of the existing sets; otherwise the element of the third set is set to "true."

3. Method insertElement inserts a new integer "k" into a set (by setting a[k] to "true).

4. Method deleteElement deletes integer "m" (by setting a[m] to "false.

5. Method isEqualTo determines if two sets are equal.

6. Method toString prints all the elements in a set separated by commas.

The second .java file will be called AS7. This is the driver file that tests the above methods. This file must instantiate four IntegerSet objects. The first object is instantiated by calling the default constructor; the second object is instantiated by calling the second constructor. The first two objects are populated by inserting hard coded numbers using Method insertElement. That is, the values that are represented by the index numbers of the elements of the arrays are to be hard coded and added automatically.

The 3rd and 4th IntegerSet objects can be instantiated by calling the second default constructor. IntegerSet objects 3 and 4 are populated by calling Methods unionOfIntegerSets and Method intersectionOfIntegerSets.

Thus for population of all IntegerSet objects no user input is/can be required. Population is to be automatic.

The output

1. must show that the method calls to Class IntegerSet from Class AS7 work and that the respective methods work.

2. should be in the form of a JOptionPane,

3. should show the following text that appears in quotes, and

4. must use Method toString to print the elements in each set.

The output should be as follows:

"The first set is named firstArrayName and was created by calling the default constructor. It is an empty set.
FirstArrayName will represent this set of values: { value1, value2, value3,..., valuen }." (Note: that each value is followed by a "," except the last value).
"The first set is named firstArrayName has been populated and is no longer empty. It was populated using Method insertElement. After population, It represents this set of numbers: { value1, value2, value3, valuen }." (Note: that each number of the array is followed by a "," except the last value).

"The second array set is named secondArrayName and was created by calling the second constructor. It is an empty set.
SecondArrayName will represent this set of values: { value1, value2, value3,..., valuen }." (Again, note: that each value is followed by a "," except the last value).
"The second set is named secondArrayName is has been populated and is no longer empty It was populated using Method insertElement. After population, It represents this set of numbers: { value1, value2, value3,..., valuen }." (Again note: that each number of the array is followed by a "," except the last value).

"The thirdarray set is named thirdArrayName and was created by calling Method unionOfSets on the first two sets. It represents this set of numbers: { value1, value2, value3, valuen }." (Again note: that each number of the array is followed by a "," except the last value).

"The fourth array set is named fourthArrayName and was created by calling Method intersectionOfSets on the first two sets. It represents this set of numbers: { value1, value2, value3, valuen }." (Again note: that each number of the array is followed by a "," except the last value).

"After calling Method deleteElement firstArrayName is again an empty set and all : .

Feel free to call if you have any questions about this project.

Also, please respond to this email and confirm that you are accepting this project and will be able to complete by the above deadline.

Reference no: EM13942134

Questions Cloud

Who are the rivals to the netflix streaming effort : What is the long tail? How "long" is the Netflix tail in the DVD-by-mail business compared to traditional video stores? Who are the rivals to the Netflix streaming effort? Do any of these firm have advantages that Netflix lacks? What are these advan..
Why do you think gender has an impact on crime : Travis Hirschi developed his social control theory on the basis of bonding towards society. Which of the four elements of this bond-attachment, commitment, involvement, and belief-is more important than the others? Why?
What is the emissivity of the disk surface : Determine the fraction of the incident solar irradiation that is absorbed and what is the emissivity of the disk surface
Pose a problematic question about the picture : Your assignment is to pose a problematic question about the picture and explore possible answers to this question. To get full credit for this assignment, you must do the following:
Create a class named integerset. : "The fourth array set is named fourthArrayName and was created by calling Method intersectionOfSets on the first two sets. It represents this set of numbers: { value1, value2, value3, valuen }." (Again note: that each number of the array is follow..
Average rate of return on large-company stocks-treasury bill : Over the past 4 years, large-company stocks and U.S. Treasury bills have produced the returns stated below. Given this information, 1. What are the average rates of return on large-company stocks and Treasury bills? 2. What are the standard deviation..
What are the ethical issues in this case : What are the ethical issues in this case? What are some reasons the decision maker in this case might be inclined to go along? Not go along
Contrast the different wording methods : Compare and contrast the different wording methods you see in these three poems.  How are "Blandeur" and "Jabberwocky" similar in their use of words?  In what ways is the purpose of "English con Salsa"s use of words different than "Jabberwocky"s u..
Evaluate the paradox of markets versus resources : Write an essay answering the following question: Critically evaluate the paradox of markets v resources. Using real world examples, which side (if any) of the paradox seems to hold the most valid arguments ?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Define private instance variable to hold boolean value

Write a Java Enumeration "LetterGrade" that represents letter grades A through F including plus and minus grades. Define a private instance variable to hold a boolean value.

  How to add a static data member

Create one project for each problem; add comments to your code -  write a program which Add a static data member to count the number of objects will be created.

  You have in your program an arraylist which contains

you have in your program an arraylist that contains employee salaries double type in arbitrary order. you need to

  Extend the vending machine

Your task for this assignment is to extend the "Vending Machine" you wrote for assignment seven to add the ability to hold the snacks

  Implementation of memory management

Implementation of memory management

  Write a program brighterdemo that constructs a color object

In the Java library, a color is specified by its red, green, and blue components between 0 and 255. Write a program BrighterDemo that constructs a Color object with red, green, and blue values of 50, 100, and 150.

  Complete the method named countoutofrange

The element is greater than or equal to min AND less than or equal to max. The method should return the new array -

  Create a virtual world application

Create a Virtual World application as your final project. This Virtual World will have several objects including a MyClone object and another object of your choice.

  Which a ball is released from a user-defined height

Write a program in which a ball is released from a user-defined height and free-falls to the ground. The ball is pulled by earth's gravity of 9.8 m/sec 2 . Assume that each pixel represents

  What is the java source filename extension

What is the Java source filename extension? What is the Java bytecode filename extension and write a Java statement to display the string The value is 100 to a user in a plain dialog box.

  Employee type and the number of hours

Write a program that calculates the salary for the employee. The hourly rate for permanent staff (P) is 200, contract staff (C) is 150 and temporary staff (T) is 100. The program accepts the employee type and the number of hours the employee work.

  What things are you struggling to understand

Discuss your experiences with the programming assignment - what things are you struggling to understand?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd