JAVA 141 Stetson University Inventory Management System Program Project

JAVA 141

Stetson University


Unformatted Attachment Preview

Programming Project 4 DeLand Space Car Dealer needs a new program for their inventory management system. The program needs the following classes: • A main class ( that includes the main method and GUI. Two instantiable classes: • o Variables to store the dealer name, and the carsOnLot array in Car type. o A constructor to initialize the name variable with the given dealer name. o An accessor method to return the name of the dealer. o An accessor method to return the cars on lot. o A mutator method to buy a car and add to the car dealer inventory. o A mutator method to sell the car with the given sale price and remove the car from dealer’s inventory. o A mutator method that makes the necessary changes to update the sale price of the car. • o Variables to store makeAndModel, purchasePrice, and salePrice. o A constructor to initialize the variables with the given parameters. o An accessor method to return the purchase price. o A mutator method to update the sale price with the given new price. * Please use ProgrammingProject4.gif for the sample program output. * You are free to layout your own GUI as you wish. * Submit your program,, files to the Blackboard import javax.swing.JOptionPane; public class SpaceCarDealer { public static void main(String[] args) { String input; int response = 0; double newPrice; Car selectedCar; CarDealer delandCarDealer = new CarDealer("DeLand", 20); String[] option = {"Exit", "Sell", "Buy", "UpdatePrice"}; do { response = JOptionPane.showOptionDialog(null, delandCarDealer.getCarsOnLot(), "DeLand Car Dealer", 0, JOptionPane.INFORMATION_MESSAGE, null, option, option[2]); switch(response) { case 0: break; case 1: selectedCar = (Car) JOptionPane.showInputDialog(null, "Select: ", "Pick Car to Sell: ", JOptionPane.QUESTION_MESSAGE, null, delandCarDealer.getCarsOnLot(), delandCarDealer.getCarsOnLot()[0] ); delandCarDealer.sellACar(selectedCar); break; case 2: input = JOptionPane.showInputDialog(null, "Make and Model: "); newPrice = Double.parseDouble(JOptionPane.showInputDialog("Purchase Price: ")); //sale price with 20 percent profit: newPrice*1.2 delandCarDealer.buyACar(new Car(input, newPrice, newPrice*1.2 )); break; case 3: selectedCar = (Car) JOptionPane.showInputDialog(null, "Select: ", "Update the sale price", JOptionPane.QUESTION_MESSAGE, null, delandCarDealer.getCarsOnLot(), delandCarDealer.getCarsOnLot()[0] ); newPrice = Double.parseDouble(JOptionPane.showInputDialog("Purchase Price: ")); delandCarDealer.UpdateSalePrice(selectedCar, newPrice); break; } } } }while(response != 0); public class Car { private String makeAndModel; private double purchasePrice; private double salePrice; public Car() { this.makeAndModel = null; this.purchasePrice = 0; this.salePrice = 0; } @Override public String toString() { return String.format("%20s $%12.2f", makeAndModel, salePrice); } } import java.util.Arrays; public class CarDealer { private String dealerName; private Car[] carsOnLot; public CarDealer(String dealerName, int num) { this.dealerName = dealerName; this.carsOnLot = new Car[num]; } @Override public String toString() { return "CarDealer [dealerName=" + dealerName + ", carsOnLot=" + Arrays.toString(carsOnLot) + "]"; } } ...
Purchase answer to see full attachment
Student has agreed that all tutoring, explanations, and answers provided by the tutor will be used to help in the learning process and in accordance with Studypool's honor code & terms of service.

Final Answer

Made a sma...

onesmasd (5211)
Rice University

Return customer, been using sp for a good two years now.

Thanks as always for the good work!

Excellent job