Java help needed ! Thanx ListQueue.txt package cis223.lab2; import java.util.*;
ID: 3891335 • Letter: J
Question
Java help needed ! Thanx
ListQueue.txt
package cis223.lab2;
import java.util.*;
public class ListQueue<E> implements QueueInterface<E> {
private Node<E> front;
private Node<E> tail;
public ListQueue() {
front = null;
tail = null;
}
public boolean isEmpty() {
}
@Override
public E getFront() {
}
public void enqueue(E element) {
}
@Override
public void clear() {
}
public E peek() {
}
public E dequeue() {
}
public String toString() {
String result = "front [ ";
Node<E> nodeRef = front;
while (nodeRef != null) {
result += nodeRef.data + " ";
nodeRef = nodeRef.next;
}
return result + "] tail";
}
private static class Node<E> {
private E data;
private Node<E> next;
public Node(E element, Node<E> nextNode) {
data = element;
next = nextNode;
}
}
}
QueueInterface.txt
package cis223.lab2;
public interface QueueInterface<E>
{
public boolean isEmpty();
public E getFront();
public E dequeue();
public void enqueue(E e);
public void clear();
}
Car.txt
package cis223.lab;
public class Car {
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public int getTopSpeed() {
return topSpeed;
}
public void setTopSpeed(int topSpeed) {
this.topSpeed = topSpeed;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public int getMpg() {
return mpg;
}
public void setMpg(int mpg) {
this.mpg = mpg;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public boolean isSold() {
return sold;
}
public void setSold(boolean sold) {
this.sold = sold;
}
private String brand;
private String model;
private int topSpeed;
private int year;
private String color;
private int mpg;
private double price;
private String imageUrl;
private int id;
private boolean sold;
public Car(){
brand = "Unknown";
}
public Car(String barnd){
this.brand = brand;
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
brand = brand;
}
/*
Create a car class with the following specifications:
- Fields:
o String Brand
o String Model
o int Top speed
o int Year
o String Color
o int Mpg
o double Price
o String Image Url
o int id
o boolean sold
- Methods:
o Getters and Setters Methods
o printInfo() // pretty print on available information
*/
public static void main(String[] args){
Car c = new Car();
}
}
CarDealer.java
package cis223.lab2;
import java.util.Iterator;
import java.util.*;
import java.util.LinkedList;
public class CarDealer {
/*
Define static fields here
*/
private static List<Car> cars;
public CarDealer(){
}
public static void addNewCar(Car c) {
if(cars==null){
cars = new LinkedList<>();
cars.add(c);
}else{
cars.add(c);
}
}
public static Car getCarByBrand(String carBrand) {
Car searchResult=null;
for(Car c: cars){
if(c.getBrand()==carBrand){
searchResult = c;
}
}
return searchResult;
}
public static void main(String[] args){
//test your code
CarDealer toyotaDealer = new CarDealer();
Car car1 = new Car();
car1.setBrand("Toyota");
car1.setColor("Blue");
car1.setId(1);
car1.setModel("4Runner");
toyotaDealer.addNewCar(car1);
Car car2 = new Car();
car2.setBrand("Toyota");
car2.setColor("Black");
car2.setId(2);
car2.setModel("Camry");
toyotaDealer.addNewCar(car2);
Car ret = toyotaDealer.getCarByBrand("toyota");
int x = 20;
double y = 20.5;
x = (int) y;
}
}
Main.java
package edu.cau.cis223;
import org.academiadecodigo.bootcamp.Prompt;
import org.academiadecodigo.bootcamp.scanners.menu.MenuInputScanner;
public class Main {
public static void main(String[] args) {
boolean isDone = false;
CarDealer dealership = new CarDealer();
while (!isDone) {
// Define some options for the menu
String[] options = {"Add New Car", "List Inventory", "Get Count of Cars" , "Dealer Total Asset in $",
"Search Car by Id", "Search Car by Brand","Search Car by Model", "Load Inventory Data", "Exit"};
// Create a new prompt attached to standard input/output
Prompt prompt = new Prompt(System.in, System.out);
// Instantiate a menu scanner
MenuInputScanner scanner = new MenuInputScanner(options);
// Setup the menu prompt message
scanner.setMessage("Choose an option: ");
Car c = new Car();
// Grab the user in a loop until a valid input is inserted
int userInput = prompt.getUserInput(scanner);
switch (userInput) {
case 1:
//Add New Car
CarDealer.addNewCar();
break;
case 2:
CarDealer.getAllInventory();
break;
case 3:
CarDealer.getInventorySize();
break;
case 4:
CarDealer.getInventoryWorth();
break;
case 5:
CarDealer.getCarById();
break;
case 6:
//CarDealer.getCarByBrand();
break;
case 7:
//CarDealer.getCarByModel();
break;
case 8:
CarDealer.loadData();
break;
case 9:
isDone = true;
break;
default:
break;
}
}
System.out.println("Thank you!");
}
}
1 0 % 14%. T-Mobile Back Lab 3:42 PM Lab03 Detail Submission Grade Due: J 1. Implement the ListQueue class 2. Use the Car class and CarDealer class provided to you and add a CarWash Service to your dealer using the ListQueue you just implemented. Make sure that you have place for 10 cars at a time to stay in line for car . ListQueue.java . Queuelnterface.java » Car.java » CarDealer.java » Main.java //modify main to add a new option for car wash Submit all java files separately. Submit a word document explaining on how to use your program Dashboard Calendar To Do Notifications InboxExplanation / Answer
here is your listQueue.java : ----------->>>>>>>>>>
import java.util.*;
public class ListQueue<E> implements QueueInterface<E> {
private Node<E> front;
private Node<E> tail;
public ListQueue() {
front = null;
tail = null;
}
public boolean isEmpty() {
return front == null;
}
@Override
public E getFront() {
if(isEmpty()){
return null;
}
return front.data;
}
public void enqueue(E element) {
if(isEmpty()){
front = new Node<E>(element,null);
tail = front;
}else{
tail.next = new Node<E>(element,null);
tail = tail.next;
}
}
@Override
public void clear() {
front = tail = null;
}
public E peek() {
return getFront();
}
public E dequeue() {
if(isEmpty()){
return null;
}
E d = getFront();
if(front == tail){
front = tail = null;
return d;
}
front = front.next;
return d;
}
public String toString() {
String result = "front [ ";
Node<E> nodeRef = front;
while (nodeRef != null) {
result += nodeRef.data + " ";
nodeRef = nodeRef.next;
}
return result + "] tail";
}
private static class Node<E> {
private E data;
private Node<E> next;
public Node(E element, Node<E> nextNode) {
data = element;
next = nextNode;
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.