Can Anybody write help me to write java code for this projec

Can Anybody write help me to write java code for this project please?


Here is the file of bag of objects from lab 2.

public class Soda
{
private String sodaFlavour;
private double sodaPrice;


/**
* Constructor
* @param newSodaType The value to store in sodaFlavour.
* @param newSodaPrice The value to store in sodaPrice.
*/

public Soda(String newSodaFlavour, double newSodaPrice)
{
sodaFlavour = newSodaFlavour;
sodaPrice = newSodaPrice;
}

/**
* The setSodaFlavour method stores a value in the SodaFlavour field.
* @param newSodaFlavour The value to store in SodaFlavour.
*/

public void setSodaFlavour(String newSodaFlavour)
{
sodaFlavour = newSodaFlavour;
}

public String getSodaFlavour()
{
return sodaFlavour;
}

/**
* The setSodaPrice method stores a value in the sodaPrice field.
* @param newSodaPrice The value to store in sodaPrice.
*/

public void setSodaPrice(double newSodaPrice)
{
sodaPrice = newSodaPrice;
}

/**
* The getSodaPrice method returns a Cheese objects price.
* @return The value in the sodaPrice field.
*/

public double getSodaPrice()
{
return sodaPrice;
}

@Override
public String toString()
{
return \"Soda Flavor:\" + sodaFlavour + \"Soda Price:\" + sodaPrice;
}

}

Here is the file for node<e> from lab 5

public class Node<E>
{ // Start main class
private Node<E> link;
private E data;
  
/**
* @param initialData is set to data
* @param initialLink is set to link
*/
public Node (E initialData, Node<E> initialLink)
{
initialData = data;
initialLink = link;
  
}
/*
* getData method calls for value from LinkedBag
* @return data
*/
public E getData()
{
return data;
}
/*
* getLink method calls for value from LinkedBag
* @return the value stored in link
*/
public Node<E> getLink()
{
return link;
}
  
/*
* setLink method sets data
* @param initialLink
*/
public void setData(E initialData)
{
  
}
public void setLink(Node<E> initialLink)
{
  
}
  
  
} // End main class

And here is the last file from Lab 5 Linked bag

public class LinkedBag<E>
{ // Start class
private Node<E> head; // declare variables
private int numElements; // declare variables
  
public LinkedBag()
{
head = null;
numElements = 0;
}
/*
* @param getSize gets the numbers stored
* @return the values of numElements
*/
public int getSize()
{
return numElements;
}
  
/*
* Add values
* @return the value stored in numElements
*/
public void add(E element)
{
head = new Node<E>(element, head);
numElements++;
  
}
/*
* countOccurrences method returns value stored in numOccurrences field
* @param target
* @return value in numOccurrences field
*/
public int countOccurrences(E target)
{
Node<E> cursor = head;
int numOccurences = 0;
for(cursor = head; cursor != null; cursor = cursor.getLink())
{
if (cursor.getData() == target)
{
numOccurences++;
}
}
return numOccurences;
}
  
/*
* exists method returns the value stored in found
* @param target
* @return value stored in found
*/
public boolean exists(E target)
{
boolean found = false;
Node<E> cursor = head;
  
while(cursor != null && !found)
{
if (cursor.getData() == target)
{
found = true;
}
else
{
cursor = cursor.getLink();
}
}
return found;
}
/*
* remove method returns the value stored in found
* @param target
* @return value stored in found
*/
public boolean remove(String target) {
Node<E> cursor = head;
boolean found = false;

while (cursor!= null && !found)
{
if (cursor.getData().equals(target))
found = true;
else
cursor = cursor.getLink();
}
  
if (found) {
  
cursor.setData(head.getData());
head = head.getLink();
numElements++;
}
return found;
}
@Override
public String toString() { // Start method
String stringToReturn = \"\";
Node<E> cursor;

if (numElements == 0) {
stringToReturn = \"empty\";
}
else {
for (cursor = head; cursor != null; cursor = cursor.getLink()) {
stringToReturn = stringToReturn + cursor.getData();
if (cursor.getLink() != null) {
stringToReturn = stringToReturn + \", \";
}
}
} // End method
return stringToReturn;
}
  
}// End class

Create a program that allows a user to maintain a \"Bag\" of \"Objects\" using your Class from Lab 2 and your Node and LinkedBag from Lab 5. Regarding your class: You will have to add an equals() method to your Class so that equals, remove () and countOccurrences () will work. [honors option will have to add compare To () as well] You will also have to add a toString() method to your Class You may need to add a constructor that accepts ALL parameters to make the call of to the methods easier. example: after prompting user for yearEntered and makeEntered, then can execute: if (myBag.exists(new Car(yearEntered.makeEntered))) Your class from Lab 2 is subject to the same requirements as Lab 2. Your program should have the following options: A - Add \"Object\" to bag Asks the user to enter attributes for an \"Object\" and then adds the \"Object\" to the bag (calls .add() method) Honors Option: maintain order on add() R - Remove \"Object\" from bag Asks the user to enter attributes for an \"Object\" and then attempts to remove the \"Object\" from the bag - should return a success/failure message (calls .remove() method - need to use if for success/failure) Honors Option: maintain order on remove() F - finds if an \"Object\" is in the bag Asks the user to enter attributes for an \"Object\" and then a message based on whether the object is in the bag (calls exists() method) C - Counts the number of occurrences of an \"Object\" in bag Asks the user to enter attributes for an \"Object\" and then displays the number of occurrences of that \"Object\" in the bag (calls countOccurrences () method) D - displays contents of bag Honors Option: if you maintained order for add() and remove(), they should display in order S - Display Size of Bag Displays the size of the bag (calls .size() method) X - gracefully exits A ¢ G - grab - extra Credit

Solution

package Sample;

import java.util.Scanner;

public class BagOfobjects {
  
   public LinkedBag<Soda> bagofSodas;
   //scanner for both string and double
   Scanner scString = new Scanner(System.in);
   Scanner scDouble = new Scanner(System.in);
  
   public BagOfobjects() {
       bagofSodas = new LinkedBag<Soda>();
   }
  
   /**
   * @param args
   */
   public void add() {
      
       //getting the soda details
       System.out.println(\"Enter the flavour of Soda: \");
       String flavour = scString.next();
       System.out.println(\"Enter the price of Soda: \");
       double price = scDouble.nextDouble();
       Soda soda = new Soda(flavour, price);
       bagofSodas.add(soda);
   }

   public void delete()
   {
       System.out.println(\"Enter the flavour to delete: \");
       String flavour = scString.next();
       System.out.println(\"Enter the price: \");
       double price = scDouble.nextDouble();
       Soda soda = new Soda(flavour, price);
       //bagofSodas.remove();
   }
}

more coming...

Can Anybody write help me to write java code for this project please? Here is the file of bag of objects from lab 2. public class Soda { private String sodaFlav
Can Anybody write help me to write java code for this project please? Here is the file of bag of objects from lab 2. public class Soda { private String sodaFlav
Can Anybody write help me to write java code for this project please? Here is the file of bag of objects from lab 2. public class Soda { private String sodaFlav
Can Anybody write help me to write java code for this project please? Here is the file of bag of objects from lab 2. public class Soda { private String sodaFlav
Can Anybody write help me to write java code for this project please? Here is the file of bag of objects from lab 2. public class Soda { private String sodaFlav

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site