The method takes an array

Assignment Help C/C++ Programming
Reference no: EM13168178

The method takes an array of integers and returns true if there exists any item in the array that satisfies a specified condition. For instance, the following code fragment:

int[] input = {100, 37, 49};

boolean result1 = contains(input, new Prime( ));
boolean result2 = contains(input, new PerfectSquare( ));
boolean result2 = contains(input, new Negative( ));
result1 would return true since 37 is prime, result2 would also return true since 100 and 49 are perfect squares, and result3 would return false because none of the elements are negative. The code needs to implement:

    an interface used to specify the second parameter to contains.

    the contains method itself (which is a static method).

    the classes Negative, Prime, and Perfect Square. 

After doing this we have to rewrite it using generics. I can write the classes no problem but I'm struggling with getting them to work together. I think I'm messing up with generics. My error message comes up in my main method where I wrote:

boolean result1 = contains(<Integer>, new Prime<Integer());

Obviously, this isn't right.

Reference no: EM13168178

Questions Cloud

How to select the primary key : How to select the primary key from the candidate keys? How do foreign keys relate to candidate keys? provide examples from either your workplace or class assignments
Ohio phonebook has gotten mixed up : In an accident, the Ohio phonebook has gotten mixed up. The names are now really out of order. You and your enthusiastic, but naive, assistant Carl must fix the problem. No one can use the phonebook while you are sorting it, so every extra second of ..
A university library database records : A university library database records information about books; for each book, it records the book isbn number (which is unique), and the book name. In addition, it records which books have been checked out
Program that computes and prints the value of 6!/5! using : Write a Java program that computes and prints the  value of 6!/5! using Scanner.
The method takes an array : The method takes an array of integers and returns true if there exists any item in the array that satisfies a specified condition. For instance, the following code fragment:
Write a class volumeofbox that calculate the volume : write a class VolumeOfBox that calculate the volume by this formula : length * breadth *
Implement one class called parkingmeter : implement one class called parkingmeter, that is a simple model of a coin operated parking meter
Create a road class : Create a Road class. The class should have functions for setting the width of the road in feet and the length of the road in miles. It should also have functions for obtaining the width of the road the length of the road
Winning number combinations from the missouri lottery : The file input.txt contains all of the winning number combinations from the Missouri Lottery since it took its current form on January 3, 1998.  The data is in a file called "input.txt"  All of the data in the file is integer.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Build a definition for a class that stores data

Using C++ language, build a definition for a class that stores data about a two dimensional vector. The class has to have mutators and accessors to get and set the x and y values. Make x and y integers. Then overload the operator * so that it retu..

  You are the admissions office at abc medical university

You are the Admissions Office at ABC Medical University. You have a large number of applicants for a very few number of available openings at your school. As a result, you need to set some high admission standards. To be accepted, a student ..

  Write program to read from file to find number of integers

Write down the program which reads from file numbers.txt 30 integers in range 0 - 200. Program ‎then determines number of integers in each of given ranges.

  The first will be a structure called point

Create two structures. The first will be a structure called Point and will have as its data members an x and y coordinate. The second will be called Line and will have two Point structures as its data members.

  Write a matrix multiplication program

Write a C++, matrix multiplication program which you can instrument to monitor and measure execution time as a function of problem size. Make sure it works in Microsoft Visual Studio.

  A used car dealership maintains an inventory

Submit the completed program (all 4 parts) including all class definitions/implementations in a single .cpp source file (i.e., do not construct separate files for class headers and implementation).

  Implementation of data member counter of type int

Write the implementation (.cpp file) of Counter class. Here is the full specification of the class: A data member counter of type int.

  Counts the number of numbers between 150 and 200

create a program that counts the number of numbers between 150 and 200. This is what I have so far, but it's not working. It is an array of 500 number, I did not include the array because of obvious reasons.

  Allows you to enter 10 phonecalls into an array

Create a main() function that allows you to enter 10 PhoneCalls into an array. If a PhoneCall is already been placed to a number, do not allow a second PhoneCall to the same number

  The main program should create an ifstream

For decryption, the main program should create an ifstream for the file to be decrypted. It should use the getline method of the ifstream to read lines from the file, call the encryption / decryption function with the line to be decrypted, and dis..

  Create program to input miles driven and gallons used

Create a program in C++ which will input miles driven and gallons used (both as integers) for each tankful. Program must compute and display the miles per gallon

  Translate than c source code

Why does Ada take so much more time to translate than C source code? What phase of the Ada translation takes the longest?

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