/*
 * Copyright 2012 s_wolff.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.aegee.runanddine.pathfinder.optimizers;

/**
 * Group wrapper for optimization
 * @author s_wolff
 */
public class AbstractGroup {

    public static final int COURSE_STARTER = 0, COURSE_MAIN = 1, COURSE_DESSERT = 2;
    private int id;
    private int guest1;
    private int guest2;
    private int course;

    @Override
    public String toString() {
        return String.format("[%s:%s]-[%s,%s]", id, course, guest1, guest2);
    }

    public AbstractGroup(int id, int guest1, int guest2, int course) {
        this.id = id;
        this.guest1 = guest1;
        this.guest2 = guest2;
        this.course = course;
    }

    /**
     * Get ID of AbstractGroup
     * @return ID of AbstractGroup
     */
    public int getId() {
        return id;
    }

    /**
     * Get id of first group that visits this group
     * @return ID of first guest group
     */
    public int getGuest1() {
        return guest1;
    }

    /**
     * Get id of second group that visits this group
     * @return ID of second guest group
     */
    public int getGuest2() {
        return guest2;
    }

    /**
     * Check whether group identified by given ID is guest of this group
     * @param id ID of group to be checked
     * @return Group is guest
     */
    public boolean hasGuest(int id) {
        return this.guest1 == id || this.guest2 == id;
    }

    
    /**
     * Get number of course this group prepares
     * @return Number of course
     */
    public int getCourse() {
        return course;
    }

    /**
     * Check whether this group prepares starter
     * @return Group prepares starter
     */
    public boolean isStarterChef() {
        return this.course == COURSE_STARTER;

    }

    /**
     * Check whether this group prepares main
     * @return Group prepares main
     */
    public boolean isMainChef() {
        return this.course == COURSE_MAIN;

    }

    /**
     * Check whether group prepares dessert
     * @return Group prepares dessert
     */
    public boolean isDessertChef() {
        return this.course == COURSE_DESSERT;
    }
}
