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) { … }...
(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...
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
C++ Task: You are to write a class called Monomial, using filenames monomial.h and monomial.cpp, that...
C++ Task: You are to write a class called Monomial, using filenames monomial.h and monomial.cpp, that will allow creation and handling of univariate monomials, as described below. Monomial Description Each monomial object has following properties: Each monomial has a coefficient and a power. Monomial power is always positive. Monomial power is always integer. Monomials cannot be added if they have different powers Class Details The single constructor for the Monomial class should have 2 parameters: an floating point coefficient value...
Complete the task below C++ This header file declares the Comp315Array Class **************************/ //Include the libraries...
Complete the task below C++ This header file declares the Comp315Array Class **************************/ //Include the libraries #include <iostream> //Allow the use of cin and cout //Declare namespace std for using cin and cout using namespace std; //Class declaration class Comp315Array{ //Public members public: /**************** Default Constructor Task: assign 0 to the array size *********/ Comp315Array(); /**************** Constructor Task: Define an int array of size n *********/ Comp315Array(int n); /***************** getSize method Task: return the array size ******************/ int getSize(); /*****************...
please answer as text You are given a Node class and a List class: public class...
please answer as text You are given a Node class and a List class: public class Node {        int           data;        Node       next;        Node(int d, Node n){             data = d;             next = n;       } } public class List{        Node header; } Write a java method insertNodeBefore( ) which takes two integers: int ref which is the data of the node that we need to insert a new node before, and int d which is...
Complete the following task in C++. Separate your class into header and cpp files. You can...
Complete the following task in C++. Separate your class into header and cpp files. You can only useiostream, string and sstream. Create a main.cpp file to test your code thoroughly. Given : commodity.h and commodity.cpp here -> https://www.chegg.com/homework-help/questions-and-answers/31-commodity-request-presented-two-diagrams-depicting-commodity-request-classes-form-basic-q39578118?trackid=uF_YZqoK Create : locomotive.h, locomotive.cpp, main.cpp Locomotive Class Hierarchy Presented here will be a class diagram depicting the nature of the class hierarchy formed between a parent locomotive class and its children, the two kinds of specic trains operated. The relationship is a...
Complete the following task in C++. Separate your class into header and cpp files. You can...
Complete the following task in C++. Separate your class into header and cpp files. You can only use iostream, string and sstream. Create a main.cpp file to test your code thoroughly. Given : commodity.h and commodity.cpp here -> https://www.chegg.com/homework-help/questions-and-answers/31-commodity-request-presented-two-diagrams-depicting-commodity-request-classes-form-basic-q39578118?trackid=uF_YZqoK Given : locomotive.h, locomotive.cpp, main.cpp -> https://www.chegg.com/homework-help/questions-and-answers/complete-following-task-c--separate-class-header-cpp-files-useiostream-string-sstream-crea-q39733428 Create : DieselElectric.cpp DieselElectric.h DieselElectric dieselElectric -fuelSupply:int --------------------------- +getSupply():int +setSupply(s:int):void +dieselElectric(f:int) +~dieselElectric() +generateID():string +calculateRange():double The class variables are as follows: fuelSuppply: The fuel supply of the train in terms of a number of kilolitres...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT