%%%% File: ccm_programming_challenge.pro %%%% Line: New York State Professional Sports Teams %>>>>>>>>>>>>>> FACTS ... <<<<<<<<<<<<<<% %_______________________________________% %******************** Teams ********************% % team(N, L) :: N is a team in league L. team('New York Rangers', 'NHL'). team('New York Islanders', 'NHL'). team('New York Yankees', 'MLB'). team('New York Mets', 'MLB'). team('New York Giants', 'NFL'). team('New York Jets', 'NFL'). team('New York Knicks', 'NBA'). team('Brooklyn Nets', 'NBA'). team('Buffalo Sabres', 'NHL'). %******************** Team Location ********************% % location(T,P,city(C),state(S), capacity(Cap)) :: team T plays in place P in city C in state S with capacity Cap. location('New York Rangers', 'Madison Square Garden',city('New York'), state('New York'), capacity(18006)). location('New York Islanders', 'Barclays Center',city('Brooklyn'), state('New York'), capacity(15795)). location('New York Yankees', 'Yankee Stadium',city('Bronx'), state('New York'),capacity(47422)). location('New York Mets','Citi Field' ,city('Queens'), state('New York'),capacity(41800)). location('New York Giants', 'Met Life Stadium',city('East Rutherford'), state('New Jersey'),capacity(82500)). location('New York Jets', 'Met Life Stadium',city('East Rutherford'), state('New Jersey'),capacity(82500)). location('New York Knicks', 'Madison Square Garden',city('New York'), state('New York'),capacity(19812)). location('Brooklyn Nets', 'Barclays Center',city('Brooklyn'), state('New York'),capacity(17732)). location('Buffalo Sabres', 'Key Bank Center',city('Buffalo'), state('New York'),capacity(19070)). %******************** Team History ********************% % history(name(N),date(D)) :: N is the name of a team in history founded in year D. history('New York Rangers', date(1926)). history('New York Islanders', date(1972)). history('New York Yankees', date(1913)). history('New York Mets',date(1962)). history('New York Giants', date(1925)). history('New York Jets', date(1959)). history('New York Knicks', date(1946)). history('Brooklyn Nets', date(1967)). history('Buffalo Sabres', date(1970)). %******************** League ********************% % league(L,NT,date(D)) :: League L has NT number of teams and founded in date D league('NHL', 31, date(1917)). league('NBA', 30, date(1946)). league('MLB', 30, date(1903)). league('NFL', 30, date(1920)). %>>>>>>>>>>>>>> RULES... <<<<<<<<<<<<<<% %______________________________________% %*******************************************% %********** List all Hockey Teams **********% % hockey :- team(T, nhl). hockey :- team(T, 'NHL'), write(T),nl,fail. hockey. %***********************************************% %********** List all Basketball Teams **********% % basketball :- team(T, nba). basketball :- team(T, 'NBA'), write(T),nl,fail. basketball. %*********************************************% %********** List all Baseball Teams **********% % baseball :- team(T, mlb). baseball :- team(T, 'MLB'), write(T),nl,fail. baseball. %*********************************************% %********** List all Football Teams **********% % football :- team(T, nfl). football :- team(T, 'NFL'), write(T),nl,fail. football. %********************************************************% %********** List all Teams Founded Prior to 1950 **********% % older :- history(T, date(D)), D < 1950. older :- history(T, date(D)), D < 1950,write(T), nl, fail. older. %*******************************************************% %********** List all Teams Founded After 1950 **********% % younger :- history(T, date(D)), D >= 1950. younger :- history(T, date(D)), D >= 1950,write(T), nl, fail. younger. %************************************************************% %********** List all Leagues Founded Prior to 1920 **********% % oldleague :- league(L, date(D)), D < 1920. olderleague :- league(L, _, date(D)), D < 1920,write(L), nl, fail. olderleague. %********************************************************% %********** List all Leagues Founded From 1920 **********% % youngerleague :- league(L, date(D)), D >= 1920. youngerleague :- league(L, _, date(D)), D >= 1920,write(L), nl, fail. youngerleague. %**************************************************************% %********** List All Locations Seating Capacity **********% % seating(T,L,C) :- location(T,L,_,_,capacity(C)),write(T),nl,write(L),nl,write(C),nl,nl,fail. seating(T,L,C) :- location(T,L,_,_,capacity(C)). %********************************************************% %********** List All Locations with Seating Capacity >= 20000 **********% % bigseating(Team,Location,Capacity) bigcap :- seating(T,L,C),C>=20000,write(T),nl,write(L),nl,write(C),nl,nl,fail. bigcap. %********************************************************% %********** List All Locations with Seating Capacity < 20000 **********% % lowcap(Team,Location,Capacity) lowcap :- seating(T,L,C),C<20000,write(T),nl,write(L),nl,write(C),nl,nl,fail. lowcap.