Commit e4e4cfd8 authored by mrsl2000's avatar mrsl2000

I dont no why we most writh javadoc i,m dead now

parent 73890f6c
Pipeline #698 failed with stages
package Alibaba;
import java.util.ArrayList;
/**
* System of airport
* @author mohammadreza
* @version
*/
public class System {
private ArrayList<Flight> flights;
private ArrayList<Ticket> tickets;
/**
* This is a getter method!
* @author mohammadreza
* @return the flights
*/
public ArrayList<Flight> getFlights() {
return flights;
}
/**
* This is a getter method!
* @author mohammadreza
* @return the tickets
*/
public ArrayList<Ticket> getTickets() {
return tickets;
}
/**
* for add a flight to users flight list
* @author mohammadreza
* @param Flight add to flight list
*/
public void addFlight(Flight f){
flights.add(f);
}
/**
* for remove a flight from users flight list
* @author mohammadreza
* @param Flight remove from flight list
*/
public void removeFlight(Flight f){
flights.remove(f);
}
public void addTicket(Ticket t){
tickets.add(t);
}
public void showFlightsDetails(){
for(Flight f: flights){
java.lang.System.out.println(f.getCompany()+","+f.getDay()+","+f.getHour()+","+f.getI()+","+f.getF()+","+f.getNumber() );
}
}
}
package Alibaba;
/**
* Ticket class modeling the airplane ticket
* @author mohammadreza
* @version 1.0
*/
public class Ticket {
private int id;
private int flightNum;
private int cargo;
private boolean food;
/**
* This is a getter method!
* @author mohammadreza
* @return the id
*/
public int getId() {
return id;
}
/**
* this is a setter method
* @author mohammadreza
* @param id the id to set
*/
public void setId(int id) {
this.id = id;
}
/**
* This is a getter method!
* @author mohammadreza
* @return the flightNum
*/
public int getFlightNum() {
return flightNum;
}
/**
* this is a setter method
* @author mohammadreza
* @param flightNum the flightNum to set
*/
public void setFlightNum(int flightNum) {
this.flightNum = flightNum;
}
/**
* This is a getter method!
* @author mohammadreza
* @return the cargo
*/
public int getCargo() {
return cargo;
}
/**
* this is a setter method
* @author mohammadreza
* @param cargo the cargo to set
*/
public void setCargo(int cargo) {
this.cargo = cargo;
}
/**
* This is a getter method!
* @author mohammadreza
* @return the food
*/
public boolean isFood() {
return food;
}
/**
* this is a setter method
* @author mohammadreza
* @param food the food to set
*/
public void setFood(boolean food) {
this.food = food;
}
}
package Alibaba;
/**
* This class implements the user system
* @author mohammadreza
* @version 1.0
*/
public class User {
private String name;
private int ID;
/**
* @author mohammadreza
* @param name the name of user
* @param iD the id of user
*/
public User(String name, int iD) {
this.name = name;
ID = iD;
}
/**
* This is a getter method!
* @author mohammadreza
* @return the name
*/
public String getName() {
return name;
}
/**
* this is a setter method
* @author mohammadreza
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* This is a getter method!
* @author mohammadreza
* @return the iD
*/
public int getID() {
return ID;
}
/**
* this is a setter method
* @author mohammadreza
* @param iD the iD to set
*/
public void setID(int iD) {
ID = iD;
}
/**
* this method reserve seats
* @author mohammadreza
* @param seatNum and plane for reserve the seat for user
*/
public Ticket reserveSeat (int seatNum , Plane plane){
if (!plane.getSeats().get(seatNum).getDiscription()) {
plane.getSeats().get(seatNum).setDiscription(true);
// system must add this reservation
Ticket t = new Ticket();
return t;
}else return null;
}
}
package Test;
import Alibaba.*;
import Alibaba.System;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeAll;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
public class Testing {
static System system;
static User user1;
static User user2;
static Plane p1;
static Plane p2;
static Flight f1;
@BeforeAll
public static void PreStarts() {
system = new System();
user1 = new User("pasha", 1);
user2 = new User("mamad", 2);
p1 = new Plane("Airbus", 10, 12, 15);
p2 = new Plane("Topolof", 15, 5, 5);
f1 = new Flight("monday", 13, "Tehran", "Berlin", "QeshmAir", p1, 123);
}
@Test
public void testReservation(){
Ticket t1 = user1.reserveSeat(12 , p1);
assertNotNull(t1);
Ticket t2 = user2.reserveSeat(12 , p1);
assertNull(t2);
t2 = user2.reserveSeat(15 , p1);
assertNotNull(t2);
}
}
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