-------------------------Screenshot-----------------------
-------------------------Metro.java-----------------------
import java.util.Random;
public class Metro{
private int metroID;
private int stationNum;
private int direction;
private int passTotal;
private Random randomGenerator;
public Metro(){
randomGenerator = new
Random();
metroID =
randomGenerator.nextInt(1000)+1;
stationNum = 0;
direction = 1;
passTotal = 0;
}
public Metro(int metroID){
randomGenerator = new
Random();
this.metroID = metroID;
stationNum = 0;
direction = 1;
passTotal = 0;
}
public String toString(){
String str = "Metro " +
metroID;
str += " leaving station " +
stationNum;
if(direction==1)
str += " east
bound";
else
str += " west
bound";
str += " with " + passTotal + "
passenger(s)";
return str;
}
public Boolean equals(Metro other){
return
other.getPassTotal()==this.passTotal;
}
public int nextStation(int lastStation){
if((stationNum+direction>lastStation) ||
(stationNum+direction<1)){
direction =
-direction;
}
return stationNum+direction;
}
public int getMetroID(){return metroID;}
public int getStationNum(){return stationNum;}
public int getDirection(){return direction;}
public int getPassTotal(){return passTotal;}
public void setMetroID(int metroID){this.metroID =
metroID;}
public void setStationNum(int
stationNum){this.stationNum = stationNum;}
public void setDirection(int direction){this.direction
= direction;}
public void setPassTotal(int passTotal){this.passTotal
= passTotal;}
}
-------------------------Driver.java-----------------------
import java.util.Random;
import java.util.Scanner;
public class Driver{
public static void main(String[] args) {
Random randomGenerator = new
Random();
Scanner s = new
Scanner(System.in);
System.out.println("Welcome to
Metro Manager - Enjoy your metro experience");
System.out.println("-----------------------------------------");
System.out.print("Enter number of
metro stations (minimum 3): ");
int numStations =
s.nextInt();
while(numStations<3){
System.out.print("Enter number of metro stations (minimum 3):
");
numStations =
s.nextInt();
}
System.out.println("This Metro has
3 stations.\n");
System.out.println("-----------------------------------------");
Metro m = new Metro();
m.setStationNum(1);
int[][] passengersLeft = new
int[numStations+1][3];
for(int
i=0;i<numStations+1;i++){
for(int
j=0;j<3;j++){
passengersLeft[i][j] = 0;
}
}
char cont = 'y';
while(cont=='y' ||
cont=='Y'){
int
newPassengers = randomGenerator.nextInt(120);
int snum =
m.getStationNum();
int dir =
m.getDirection();
System.out.println("--------------------------");
if((snum==1
&& dir==1) || (snum==numStations &&
dir==-1)){
System.out.println("Only in");
System.out.println("(New Passengers waiting
"+newPassengers+")");
System.out.println("(Passengers left from last
time "+passengersLeft[snum][1+dir]+")");
}else
if((snum==numStations && dir==1) || (snum==1 &&
dir==-1)){
System.out.println("All out");
newPassengers = 0;
}else{
System.out.println("In the middle");
System.out.println("(Passengers left from last
time "+passengersLeft[snum][1+dir]+")");
}
System.out.println("--------------------------");
int toBoard =
newPassengers + passengersLeft[snum][1+dir];
int gotOff =
randomGenerator.nextInt(m.getPassTotal()+1);
if((snum==numStations && dir==1) || (snum==1 &&
dir==-1)) gotOff = m.getPassTotal();
m.setPassTotal(m.getPassTotal()-gotOff);
int gotOn =
Math.min(300-m.getPassTotal(),toBoard);
m.setPassTotal(m.getPassTotal()+gotOn);
passengersLeft[snum][1+dir] = toBoard-gotOn;
System.out.println(m);
System.out.println("\tPassenger(s) got off: " + gotOff);
System.out.println("\tPassenger(s) new passengers waiting to board:
" + toBoard);
System.out.println("\tPassenger(s) got on: " + gotOn);
System.out.println("\tPassenger(s) left behind waiting for next
train: " + passengersLeft[snum][1+dir]);
System.out.println("\nDo you want to continue following Metro train
"+m.getMetroID()+"?");
System.out.print("Type \"y\" or \"Y\" for yes, anything else for
no: ");
cont =
s.next().charAt(0);
if((snum==1
&& dir==1) || (snum==numStations &&
dir==-1)){
m.setStationNum(snum+dir);
}else
if((snum==numStations && dir==1) || (snum==1 &&
dir==-1)){
m.setDirection(-dir);
}else{
m.setStationNum(snum+dir);
}
}
m.setStationNum(3);
}
}
java Object Oriented Programming The assignment can be done individually or in teams of two. Submit one as...
Advanced Object-Oriented Programming using Java Assignment 4: Exception Handling and Testing in Java Introduction - This assignment is meant to introduce you to design and implementation of exceptions in an object-oriented language. It will also give you experience in testing an object-oriented support class. You will be designing and implementing a version of the game Nim. Specifically, you will design and implement a NimGame support class that stores all actual information about the state of the game, and detects and throws...
60 points, Complete javadocs documentation required Be sure to submit all files (.java and dictionary.txt) required to run your program Background Boggle is a word game using a plastic grid of lettered dice, in which players attempt to find words in sequences of adjacent letters. The dice are randomly arranged in the grid, and players have 90 seconds to form as many words as possible from adjacent top-facing letters For example, the word SUPER is spelled in the gameboard to...
Solve it for java Question Remember: You will need to read this assignment many times to understand all the details of the you need to write. program Goal: The purp0se of this assignment is to write a Java program that models an elevator, where the elevator itself is a stack of people on the elevator and people wait in queues on each floor to get on the elevator. Scenario: A hospital in a block of old buildings has a nearly-antique...
please help!!!! JAVA I done the project expect one part but I still give you all the detail that you needed... and I will post my code please help me fix the CreateGrid() part in main and make GUI works List Type Data Structures Overview : You will be implementing my version of a linked list. This is a linked list which has possible sublists descending from each node. These sublists are used to group together all nodes which...
C LANGUAGE. PLEASE INCLUDE COMMENTS :) >>>>TheCafe V2.c<<<< #include <stdio.h> int main() { int fries; // A flag denoting whether they want fries or not. char bacon; // A character for storing their bacon preference. double cost = 0.0; // The total cost of their meal, initialized to start at 0.0 int choice; // A variable new to version 2, choice is an int that will store the // user's menu choice. It will also serve as our loop control...
hello there, i have to implement this on java processing. can someone please help me regarding that? thanks War is the name of a popular children’s card game. There are many variants. After playing War with a friend for over an hour, they argue that this game must never end . However! You are convinced that it will end. As a budding computer scientist, you decide to build a simulator to find out for sure! You will implement the logic...
Available Feb 11 at 12am - Mar 8 at 11:59pm 26 days Not for IV Use: The Story of an Enteral Tubing Misconnection The Story of Robin and Addison Lowe (United States) LEARNING OBJECTIVES After completing this case study, you will be able to: 1. Explore the scientific feld of human factors and how errors like tubing misconnections can be prevented. 2. Discuss the complexity of having two patients to treat, a mother and her fetus. 3. Describe suitable...
While reading the story, consider the culture (or sub culture) and related communication styles the story reveals. Consider too, possibly, the values, behavioral norms, social practices, social artifacts, etc. After reading the story through the lens of this idea, please compose a full academic length (evidence-based 7 to 11 sentence long) paragraph which addresses the following prompt: What does the story reveal about the culture it portrays and/OR the communication styles the culture shares? In other words, what does the...
Chapter 12 Patlent Teaching 105 Part 3. Review Questions Circle the correct answer(s). In some questions, more than one answer is correct. Select all that apply 13. Which of the following is the best rationale for nurses 19. Tell the patient to wait until you harve fin ished teaching before asking questions. Adults learn best when they understand the relevance of the information presented Do not assume an interpreter will be needed. Always ask the patient if he or she...
Hello, my name is Shady Slim. I understand you are going to help me figure out my gross income for the year... whatever that means. It's been a busy year and I'm a busy man, so let me give you the lowdown on my life and you can do your thing I was unemployed at the beginning of the year and got $2,000 in unemployment compensation. I later got a job as a manager for Roca Cola. I earned $57,500...