Question
(this is how the output is supposed to look like) ---------------- bashemin.in (you should create this file and use it in your program). Its text
(this is how the output is supposed to look like)
----------------
bashemin.in (you should create this file and use it in your program). Its text is:
aVAX785
aPDP11
aIBM360
aMTHCSC
dPDP11
p
aMAC512
dVAX785
aPI314
aCSB-1
dCSB-1
dIBM360
p
aPDP11
a257ADT
dMAC512
---------------------------------------
(program might start off like this)
--------------------------
Your program might start out like this
import java.io.*;
class BasheminParkingLot
{
public static void main(String[] args) throws Exception
{
Stack parkinglot = new Stack();
Stack alley = new Stack();
File f = new File("bashemin.in");
FileInputStream finstream = new FileInputStream(f);
InputStreamReader finreader = new InputStreamReader(finstream);
BufferedReader finput = new BufferedReader(finreader);
String line = finput.readLine();
String plate=" ";
System.out.println();
System.out.println("The Bashemin Status");
System.out.println();
while(line!=null)
{
if(line.charAt(0)=='a')
{
plate=line.substring(1);
System.out.println("car " + plate + " arrived and parked");
parkinglot.Push(plate
}
-------------------------------------------------------------------------------------------------------------------------------------------------------------
(stack that needs to be used that is mentioned on the first page)
--------------------------------------------------------------
public class Stack { private StringNode headNode; // refers to top of the stack private StringNode endNode; // refers to bottom of stack //Constructor establishes an empty stack public Stack() { // sets up two linked dummy "bookend" nodes endNode = new StringNode(null,null); headNode = new StringNode(null,endNode); } //Methods - Push, Pop and Peek public void Push(String item) { if(headNode.link==endNode) { // if the list is empty StringNode n = new StringNode(); n.datum=item; n.link=endNode; headNode.link=n; } else { StringNode n = new StringNode(); n.datum=item; n.link=headNode.link; headNode.link=n; } } public void Pop() { headNode.link=headNode.link.link; } public String Peek() { return headNode.link.datum; } public boolean IsEmpty() { return headNode.link == endNode; } // Method Display // Not normally a required method for Stack, but only for convenience. public void Display(){ //System.out.println("The data in the linked list are:"); StringNode l = headNode.link; while (l != endNode) { System.out.println( l.datum); l = l.link; } } }
--------------------------------------------------------------------------------------------------------
P.S: i am aware that this has been posted before but it was incomplete
Langauge: java
CSC1 231 Due: Thursday, 19 October 2017 There will be NO extensions! Dn the due date submit your complete main program so that all I have to do is run it. This is individual, NOT collaborative work. You are encouraged to consult with me about the solution or about clarifications. This is an application of STACKS You MUST use our Stack class in this THE BASHEMIN PARKING LOT (Bash 'em in, get it?) e Bashemin Parking Lot is nothing more than a delightful little dead-end alley situated in downtown Rochester. It's not very big. It holds only five cars, but in Rochester every little bit helps! Because it is a dead-end alley, the cars can enter and exit from only one end. (Like a stack maybe?) The owners of the Bashemin Parking Lot, realizing the limitations of only one entrance and exit, would like to study the operation of the parking lot. One of the problems is that if a customer arrives to pick up his car and it is not the car nearest to the exit, all of the cars behind him must be backed out of the alley into the dead-end al ley adjacent to Bashemin, the customer's car moved out, and all backed out cars are restored in order. To find out how much extra work they are doing moving cars in and out because of the dead-end alleys, they would like to keep track of how many cars they have to move in order to release a car that is leaving. Your assignment is to write a program to read the order of arrivals and departures of cars for one day. Assume that the parking lot is empty when the day begins. You hould print a message when a car arrives to park in the parking lot. Tell whether or not it was able to park (remember that the capacity of the parking lot is five cars!). You should print a message when a car departs the parking lot. Include in all messages the license number of the car. In the departure message also include the number of cars that had to be moved in order to let it out. At the end of the day, the parking lot is going to be locked up. The owners don't want the responsibility for keeping the cars overnight. So they have a towing service to take them away. Print an appropriate message when the day is finished and list all the cars that are towed away in the order that they are towed out of the Bashemin Parking Lot. CSC1 231 Due: Thursday, 19 October 2017 There will be NO extensions! Dn the due date submit your complete main program so that all I have to do is run it. This is individual, NOT collaborative work. You are encouraged to consult with me about the solution or about clarifications. This is an application of STACKS You MUST use our Stack class in this THE BASHEMIN PARKING LOT (Bash 'em in, get it?) e Bashemin Parking Lot is nothing more than a delightful little dead-end alley situated in downtown Rochester. It's not very big. It holds only five cars, but in Rochester every little bit helps! Because it is a dead-end alley, the cars can enter and exit from only one end. (Like a stack maybe?) The owners of the Bashemin Parking Lot, realizing the limitations of only one entrance and exit, would like to study the operation of the parking lot. One of the problems is that if a customer arrives to pick up his car and it is not the car nearest to the exit, all of the cars behind him must be backed out of the alley into the dead-end al ley adjacent to Bashemin, the customer's car moved out, and all backed out cars are restored in order. To find out how much extra work they are doing moving cars in and out because of the dead-end alleys, they would like to keep track of how many cars they have to move in order to release a car that is leaving. Your assignment is to write a program to read the order of arrivals and departures of cars for one day. Assume that the parking lot is empty when the day begins. You hould print a message when a car arrives to park in the parking lot. Tell whether or not it was able to park (remember that the capacity of the parking lot is five cars!). You should print a message when a car departs the parking lot. Include in all messages the license number of the car. In the departure message also include the number of cars that had to be moved in order to let it out. At the end of the day, the parking lot is going to be locked up. The owners don't want the responsibility for keeping the cars overnight. So they have a towing service to take them away. Print an appropriate message when the day is finished and list all the cars that are towed away in the order that they are towed out of the Bashemin Parking LotStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started