Commit 767bbb10 authored by Ali Shakoori's avatar Ali Shakoori

initial and final commit of lab7

parents
Pipeline #541 failed with stages
<component name="libraryTable">
<library name="Arquillian JUnit:Release" type="repository">
<properties maven-id="org.jboss.arquillian.junit:arquillian-junit-container:RELEASE" />
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/junit/arquillian-junit-container/1.4.1.Final/arquillian-junit-container-1.4.1.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/junit/arquillian-junit-core/1.4.1.Final/arquillian-junit-core-1.4.1.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/test/arquillian-test-api/1.4.1.Final/arquillian-test-api-1.4.1.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/core/arquillian-core-api/1.4.1.Final/arquillian-core-api-1.4.1.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/test/arquillian-test-spi/1.4.1.Final/arquillian-test-spi-1.4.1.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/core/arquillian-core-spi/1.4.1.Final/arquillian-core-spi-1.4.1.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/container/arquillian-container-test-api/1.4.1.Final/arquillian-container-test-api-1.4.1.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/shrinkwrap/shrinkwrap-api/1.2.6/shrinkwrap-api-1.2.6.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/shrinkwrap/descriptors/shrinkwrap-descriptors-api-base/2.0.0/shrinkwrap-descriptors-api-base-2.0.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/container/arquillian-container-test-spi/1.4.1.Final/arquillian-container-test-spi-1.4.1.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/container/arquillian-container-spi/1.4.1.Final/arquillian-container-spi-1.4.1.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/core/arquillian-core-impl-base/1.4.1.Final/arquillian-core-impl-base-1.4.1.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/test/arquillian-test-impl-base/1.4.1.Final/arquillian-test-impl-base-1.4.1.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/container/arquillian-container-impl-base/1.4.1.Final/arquillian-container-impl-base-1.4.1.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/config/arquillian-config-api/1.4.1.Final/arquillian-config-api-1.4.1.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/config/arquillian-config-impl-base/1.4.1.Final/arquillian-config-impl-base-1.4.1.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/config/arquillian-config-spi/1.4.1.Final/arquillian-config-spi-1.4.1.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/shrinkwrap/descriptors/shrinkwrap-descriptors-spi/2.0.0/shrinkwrap-descriptors-spi-2.0.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/arquillian/container/arquillian-container-test-impl-base/1.4.1.Final/arquillian-container-test-impl-base-1.4.1.Final.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/shrinkwrap/shrinkwrap-impl-base/1.2.6/shrinkwrap-impl-base-1.2.6.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jboss/shrinkwrap/shrinkwrap-spi/1.2.6/shrinkwrap-spi-1.2.6.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_10" default="false" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Lab_7.iml" filepath="$PROJECT_DIR$/Lab_7.iml" />
</modules>
</component>
</project>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Arquillian JUnit:Release" level="project" />
<orderEntry type="module-library">
<library name="JUnit5.2">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.5.0-M1/junit-jupiter-api-5.5.0-M1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.0.0/apiguardian-api-1.0.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.1.1/opentest4j-1.1.1.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.5.0-M1/junit-platform-commons-1.5.0-M1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
\ No newline at end of file
.idea
\ No newline at end of file
import java.util.ArrayList;
/**
* Getting the details of Flight
* @author Milad & Ali
* @version 1.0
*/
public class AirPlane {
private String company;
private String kind;
private ArrayList<Seat> seats ;
/**
* @param company company of Airplane
* @param kind kind of Airplane
*/
public AirPlane (String company , String kind){
this.company = company;
this.kind = kind;
seats = new ArrayList<>();
}
/**
* @param seat the seat for adding to Airplane seats
*/
public void addSeat (Seat seat){
seats.add(seat);
}
public ArrayList<Seat> getSeats() {
return seats;
}
public String getKind() {
return kind;
}
public String getCompany() {
return company;
}
}
import java.util.ArrayList;
/**
* Getting the information of customer
* @author Milad & Ali
* @version 1.0
*/
public class Customer {
private String name;
private String ID;
private int balance;
private ArrayList<Order> orders ;
/**
* @param name name of customer
* @param ID ID of customer
* @param balance balance of customer
*/
public Customer (String name , String ID , int balance){
this.ID = ID;
this.name = name;
this.balance = balance;
orders = new ArrayList<>();
}
/**
* adding the balance of customer
* @param money money to be added to balance of customer
*/
public void addBalance(int money){
this.balance += money;
}
/**
* @param order order for adding to customer's orders
*/
public void addOrder (Order order){
this.orders.add(order);
}
/**
* @return an Arraylist of customer's orders
*/
public ArrayList<Order> getOrders() {
return orders;
}
/**
* @return balance of customer
*/
public int getBalance() {
return balance;
}
/**
* @return getting the ID of customer
*/
public String getID() {
return ID;
}
/**
* @return getting the name of customer
*/
public String getName() {
return name;
}
/**
* Check if price of order is lesser than the balance
* of customer to add it to customer orders
* @param order order to add to Arraylist
*/
public void submitOrder(Order order){
if (order.calculateOrderPrice() > balance)
return;
if (order.getStatus().equals("submitted"))
return;
order.setPendingToSubmitted();
this.balance -= order.calculateOrderPrice();
ArrayList <Seat> help = order.getSeats();
ArrayList <Seat> help2 = order.getFlight().getAirplane().getSeats();
for (int i = 0; i < help.size(); i++) {
for (int j = 0; j < help2.size(); j++) {
if (help2.get(j).getSeatNum() == help.get(i).getSeatNum()){
help2.get(j).setPendingToSubmitted();
break;
}
}
}
}
}
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class CustomerTest {
static Customer customer;
static Customer customer2;
@BeforeAll
public static void createCustomer(){
customer = new Customer("Milad" , "9731007" , 12000);
customer2 = new Customer("Ali" , "9731092" , 4000);
}
@Test
public void testCustomerGetName(){
assertEquals("Milad", customer.getName());
assertEquals("Ali", customer2.getName());
}
@Test
public void testCustomerAddOrder(){
Seat seat1 = new Seat(1 , "businessclass" , 2000);
Seat seat2 = new Seat(2 , "businessclass" , 2000);
Seat seat3 = new Seat(14 , "normalclass" , 500);
AirPlane airPlane = new AirPlane("airbus","businessClass");
airPlane.addSeat(seat1);
airPlane.addSeat(seat2);
airPlane.addSeat(seat3);
Flight flight = new Flight("Tomorrow" , "00:00" , "Home" , "Tehran" ,"airbus" , airPlane , 45623);
Order order = new Order(flight , 465132);
customer.addOrder(order);
customer2.addOrder(order);
assertEquals(customer.getOrders().get(0) , order);
assertEquals(customer2.getOrders().get(0) , order);
}
}
\ No newline at end of file
/**
*Get details of a trip
* @author Milad & Ali
* @version 1.0
*/
public class Flight {
private String Date;
private String Time;
private String maghsad;
private String mabda;
private AirPlane airplane;
private int numberOfFlight;
/**
* @param date date of Flight
* @param time time of Flight
* @param maghsad the Destination of flight
* @param mabda the Departure of Flight
* @param company agency of Flight
* @param airplaneKind kind of Airplane
* @param numberOfFlight the ID of Flight
*/
public Flight (String date , String time , String maghsad , String mabda , String company , AirPlane airplaneKind , int numberOfFlight){}
/**
* @return Date date of Flight
*/
public String getDate() {
return Date;
}
/**
* @return number of flight
*/
public int getNumberOfFlight() {
return numberOfFlight;
}
/**
* @return the airplane for the Flight
*/
public AirPlane getAirplane() {
return airplane;
}
/**
* @return Departure of flight
*/
public String getMabda() {
return mabda;
}
/**
* @return Destination of flight
*/
public String getMaghsad() {
return maghsad;
}
/**
* @return time of flight
*/
public String getTime() {
return Time;
}
}
import java.util.ArrayList;
/**
* Getting the details of order
* @author Milad & Ali
* @version 1.0
*/
public class Order {
private Flight flight;
private int serialNumber;
private String status;
private ArrayList<Seat> seats ;
/**
* @param flight the flight for booking
* @param serialNumber the serialNumber of order
*/
public Order (Flight flight , int serialNumber){
this.flight = flight;
this.serialNumber = serialNumber;
seats = new ArrayList<>();
status = "pending";
}
/**
* check if the seatNum given is free in flight to book
* @param seatNum the ID of seat
*/
public void addSeat (int seatNum){
for (int i = 0; i < flight.getAirplane().getSeats().size(); i++) {
if(flight.getAirplane().getSeats().get(i).getSeatNum() == seatNum){
this.seats.add(flight.getAirplane().getSeats().get(i));
}
}
}
/**
* @return the status of order
*/
public String getStatus()
{
return status;
}
/**
* @return the seats of order
*/
public ArrayList<Seat> getSeats()
{
return seats;
}
/**
* @return the flight of order
*/
public Flight getFlight() {
return flight;
}
/**
* @return serial number of seat
*/
public int getSerialNumber() {
return serialNumber;
}
/**
* changing the status of order
*/
public void setPendingToSubmitted(){
this.status = "submitted";
}
/**
* @return the price of order
*/
public int calculateOrderPrice(){
int sum = 0;
for (int i = 0; i < seats.size(); i++) {
sum += seats.get(i).getPrice();
}
return sum;
}
}
#this is the readme of lab7
#This was written and modified by Milad Only and a little Ali
\ No newline at end of file
/**
* Getting the details of seats
* @author Milad & Ali
* @version 1.0
*/
public class Seat {
private int seatNum;
private String kind;
private String status;
private int price;
/**
* @param seatNum the serial number of seat
* @param kind the kind of seat
* @param price the price of seat
*/
public Seat (int seatNum , String kind , int price){
this.seatNum = seatNum;
this.kind = kind;
this.price = price;
this.status = "pending";
}
public String getPendingToSubmitted()
{
return status;
}
public int getSeatNum() {
return seatNum;
}
public String getKind() {
return kind;
}
public String getStatus()
{
return status;
}
public int getPrice()
{
return price;
}
/**
* Change the status to submitted
*/
public void setPendingToSubmitted()
{
this.status = "submitted";
}
}
import java.util.ArrayList;
/**
* The system for managing the Flights
*/
public class System {
ArrayList<Flight> totalFlights = new ArrayList<>();
/**
* @param flight the flight for adding to flight list
*/
public void addFlight(Flight flight){
totalFlights.add(flight);
}
/**
* @param flight check if the flight is available to remove
* @return if the flight was removed or not
*/
public boolean removeFlight(Flight flight){
if(totalFlights.contains(flight)){
totalFlights.remove(flight);
return true;
}else {
return false;
}
}
/**
* @return the list of flight
*/
public ArrayList<Flight> getTotalFlights() {
return totalFlights;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment