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) { … }...
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...
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...
All the answer need to be in C++ 1) Write a class for a "Vector". The...
All the answer need to be in C++ 1) Write a class for a "Vector". The members of the class will be: Data: int data[100]; methods: void inserts(int element); int remove(); int getsize(); bool is empty(): ------------------------------------------------------------------------------------------------------- 2) Using your vector class, create an object using a regular instantiation and a pointer instantiation. What are the advantages and disadvantages of both approaches? ------------------------------------------------------------------------------------------------------- 3) What does the following function do and write a program that uses the function: int foo(int...
what are some examples of class merger and class expansion (please answer in psychology or behavioral...
what are some examples of class merger and class expansion (please answer in psychology or behavioral analysis)
Iterating a method over a collection of objects is a common task that you may complete...
Iterating a method over a collection of objects is a common task that you may complete unknowingly each day. Within a collection of similar things, you identify the characteristics that make the individual elements unique and treat them differently according to their classifications. For example, assume that you are at a store and want to pay for something in cash. The bills in your wallet or purse represent a collection of similar objects, differentiated by denomination. It would not be...
C++ please #include <iostream> using namespace std; /** * defining class circle */ class Circle {...
C++ please #include <iostream> using namespace std; /** * defining class circle */ class Circle { //defining public variables public: double pi; double radius; public: //default constructor to initialise variables Circle(){ pi = 3.14159; radius = 0; } Circle(double r){ pi = 3.14159; radius = r; } // defining getter and setters void setRadius(double r){ radius = r; } double getRadius(){ return radius; } // method to get Area double getArea(){ return pi*radius*radius; } }; //main method int main() {...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT