GithubHelp home page GithubHelp logo

xiunhon / assign-airplane-seats-java Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 16 KB

Practice designing proper classes without using Scanner or PrintStream outside of class main.

Java 100.00%
passengers seats aisle window center travelclass java enum airplane map

assign-airplane-seats-java's Introduction

Airplane Seats Assignment

Write a program that assigns seats on an airplane. Assume the airplane has 20 seats in first class (5 rows of 4 seats each, separated by an aisle) and 90 seats in economy class (15 rows of 6 seats each, separated by an aisle). Your program should take three commands: add passengers, show seating, and quit. When passengers are added, ask for the class (first or economy), the number of passengers traveling together (1 or 2 in first class; 1 to 3 in economy), and the seating preference (aisle or window in first class; aisle, center, or window in economy). Then try to find a match and assign the seats. If no match exists, print a message. Print an error message if the user enters an incorrect value. Allow the user to re-enter a value if an incorrect value was entered. Your solution should include a class Airplane that is not coupled with the Scanner or PrintStream classes. Sample Output A)dd S)how Q)uit s 1:. . . . 2:. . . . 3:. . . . 4:. . . . 5:. . . . 6:... ... 7:... ... 8:... ... 9:... ... 10:... ... 11:... ... 12:... ... 13:... ... 14:... ... 15:... ... 16:... ... 17:... ... 18:... ... 19:... ... 20:... ... A)dd S)how Q)uit a F)irst E)conomy f Passengers? (1-2) 1 A)isle W)indow a

A)dd S)how Q)uit a F)irst E)conomy f Passengers? (1-2) 2

A)dd S)how Q)uit a F)irst E)conomy e Passengers? (1-3) 1 A)isle C)enter W)indow a A)dd S)how Q)uit a F)irst E)conomy e Passengers? (1-3) 2 A)isle C)enter W)indow c A)dd S)how Q)uit a F)irst E)conomy e Passengers? (1-3) 3 A)dd S)how Q)uit s 1:. * * * 2:. . . . 3:. . . . 4:. . . . 5:. . . . 6:*** *** 7:... ... 8:... ... 9:... ... 10:... ... 11:... ... 12:... ... 13:... ... 14:... ... 15:... ... 16:... ... 17:... ... 18:... ... 19:... ... 20:... ... A)dd S)how Q)uit q Press any key to continue . . .

assign-airplane-seats-java's People

Contributors

xiunhon avatar

Watchers

 avatar

assign-airplane-seats-java's Issues

Recomendaciones de principios SOLID

SRP
En la clase Airplane, nos permitía acceso a FoundMatched y realizaba operaciones con allSeats, donde este método no es propio de la clase Airplane, para solucionar este problema, se implementó una clase addseat con su método para que ahora si se cumpla este principio.

OCP
Primer OCP
En la clase SeatType era tipo enum, donde si se quería agregar otro seattype era necesario modificar en código, por lo que para solucionarlos se creó una clase abstracta Seat_type y 3 clases hijas que heredan el método de este, las cuales son: Aisle, center y window, así quedará abierto a extensión y cerrado para modificación.

Segundo OCP
En la clase TravelClass era tipo enum, donde si se quería agregar otra TravelClass era necesario modificar en código, por lo que para solucionarlos se creó una clase abstracta Travel_Class y las 2 clases hijas que heredan el método de este, las cuales son: First_Classy Economy_Class, así quedará abierto a extensión y cerrado para modificación.

LSP
Primer LSP
Concordando con la solución anterior de OCP, TravelClass.FIRST_CLASS Y TravelClass.ECONOMY_CLASS deberían de contar con su propio método add para que se pueda usar sin depender de if, con esto se solucionaría este principio.

Segundo LSP
Con la solución al problema OCP de la clase enum SeatType, se da la solución a este principio debido a que SeaType.Aisle, SeaType.Center y SeaType.Window deberían de contar con su propio método para no depender de if.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.