Question

In: Computer Science

Task : (Please Answer in C#) Class Polynomials The class Polynomials is a collection of polynomials...

Task : (Please Answer in C#)

Class Polynomials

The class Polynomials is a collection of polynomials of either implementation stored in an instance of the generic library class List.

class Polynomials

{

private List L;

// Creates an empty list L of polynomials

public Polynomials ( )

{ … }

// Retrieves the polynomial stored at position i in L

public Polynomial Retrieve (int i)

{ … }

// Inserts polynomial p into L

public void Insert (Polynomial p)

{ … }

// Deletes the polynomial at index i

public void Delete (int i)

{ … }

// Returns the number of polynomials in L

public int Size ( )

{ … }

// Prints out the list of polynomials

public void Print ( )

{ … }

}

Solutions

Expert Solution

Solution :

Short Summary:

Implemented all the methods as per the requirement
Attached source code and screenshot
**************Please do upvote to appreciate our time. Thank you!******************

Source Code:

import java.util.ArrayList;
import java.util.List;

/** The class Polynomials is a collection of polynomials of either implementation stored in an instance of the
generic library class List. **/
class Polynomials
{
private List<Polynomial> L;
// Creates an empty list L of polynomials
public Polynomials ( )
{
L=new ArrayList<>();  
}
// Retrieves the polynomial stored at position i in L
public Polynomial Retrieve (int i)
{
return L.get(i);
}
// Inserts polynomial p into L
public void Insert (Polynomial p)
{
L.add(p) ;
}
// Deletes the polynomial at index i
public void Delete (int i)
{
L.remove(i) ;
}
// Returns the number of polynomials in L
public int Size ( )
{

return L.size(); }
// Prints out the list of polynomials
public void Print ( )
{
for(Polynomial pol:L)
{
System.out.println(pol.toString());  
}
}


}

Code Screenshot:

Thank you...!


Related Solutions

Task 4 The class Polynomials is a collection of polynomials of either implementation stored in an...
Task 4 The class Polynomials is a collection of polynomials of either implementation stored in an instance of the generic library class List. class Polynomials { private List<Polynomial> L; // Creates an empty list L of polynomials public Polynomials ( ) { … } (1 mark) // Retrieves the polynomial stored at position i in L public Polynomial Retrieve (int i) (1 mark) { … } // Inserts polynomial p into L public void Insert (Polynomial p) (1 mark) {...
The class Polynomials is a collection of polynomials of either implementation stored in an instance of...
The class Polynomials is a collection of polynomials of either implementation stored in an instance of the generic library class List. class Polynomials { private List L; // Creates an empty list L of polynomials public Polynomials ( ) { … } (1 mark) // Retrieves the polynomial stored at position i in L public Polynomial Retrieve (int i) (1 mark) { … } // Inserts polynomial p into L public void Insert (Polynomial p) (1 mark) { … }...
c++ please Your task is to write the implementation for a class of polynomial operations. Your...
c++ please Your task is to write the implementation for a class of polynomial operations. Your will write the code for: 2 constructors, a destructor, print, addition, multiplication , differentiation and integration of polynomials. The polynomials will be comprised of linked TermNodes. struct TermNode { int exp; // exponent double coef; // coefficient TermNode * next; }; class Polynomial { public: Polynomial (); // default constructor Polynomial (int r, int c); // constructor makes a 1 node polynomial Polynomial(const Polynomial...
(Please answer in C++ ) This approach is similar to Task 2B. The only difference is,...
(Please answer in C++ ) This approach is similar to Task 2B. The only difference is, the computer will generate a random integer in the range as a guess. In this strategy, a guess is a random int in a given range. Hence, for the same range and same answer, the number of guesses will be different. For example, suppose the range is in [0, 10] and the answer is 7. These are possible outputs. The following running takes 8...
Implementing Polynomials using Singly Linked List in C++ The Term Class Create a class to represent...
Implementing Polynomials using Singly Linked List in C++ The Term Class Create a class to represent a term in an algebraic expression. As defined here, a term consists of an integer coefficient and a nonnegative integer exponent. E.g. • in the term 4X2, the coefficient is 4 and the exponent 2 • in -6X8, the coefficient is -6 and the exponent 8 Your class will have a constructor that creates a Term object with a coefficient and exponent passed as...
Please answer it in C++ (a) Declare a class called Book representing a textbook.      A...
Please answer it in C++ (a) Declare a class called Book representing a textbook.      A textbook has a title (eg. “Programming in C++”) A textbook has an author (eg. “Helen Johnstone”) A textbook has a size in number of pages (eg. 550) A textbook has a price (eg. $135.99). These attributes should be represented as the data members of the class and be hidden from the outside of the class. The class should also have a constructor used to...
Task use c++ and Create Base class task with virtual method Create a pair of derivative...
Task use c++ and Create Base class task with virtual method Create a pair of derivative classes of architecture, scientist, economist - Define a salary in each of these classes and create a method that prints the salary for each job Create a working object Use dynamic_cast Use typeid Create an object for each job that it will include the number of employees of that type and the method of printing these numbers
implement please... ........................................... public class TernarySearch {     /** Task: Searches for a value in an array....
implement please... ........................................... public class TernarySearch {     /** Task: Searches for a value in an array.      * @param a an array of Comparable objects      * @param desiredItem an item to search for         * @param n an integer > 0      */     public static <T extends Comparable<? super T>>     boolean ternarySearch(T[] a, T desiredItem, int n)     {         // it is assumed that the data is already sorted         return ternarySearch(a, 0, n-1, desiredItem);     } // end ternarySearch     /** Task: recursive ternarySearch search through...
Which is the correct answer a, b, or c What variables are deallocated by garbage collection?...
Which is the correct answer a, b, or c What variables are deallocated by garbage collection? a. Global Variable b. Class field c. Unreachable objects When should you call garbage collection? a. After each method b. After declaring a class c. You don't call garbage collection
1. Let W be the collection of polynomials, p(x), for which p'(5)=0 (the derivative of the...
1. Let W be the collection of polynomials, p(x), for which p'(5)=0 (the derivative of the polynomial when x = 5 is 0). State two polynomials that would belong to this set, W. State one polynomial that does not belong to this set. Is W a subspace of the vector space containing all polynomial functions? That is, is this subset of polynomials closed under addition and scalar multiplication, and does it contain a zero vector? Justify your answer. (You do...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT