Question
Suppose we have a set of sports teams in a league L, and a set of games G among those teams. Each game has a
Suppose we have a set of sports teams in a league L, and a set of games G among those teams. Each game has a home team and a visiting team, who are two different teams in the league. We have predicates H(g, t) meaning team t was the home team in game g and V(g, t) meaning team t was the visiting team in game g.
(a) Consider the predicate P(s, t) meaning team s played a game against team t. Can you express this predicate in terms of the predicates H and V, along with boolean operators? Either do it or explain (informally) why you cannot.
(b) If I have a list of the games played, and access to the H and V predicates, how could I compute the value of P(s, t) given two teams s and t?
(c) (uses Java) Assume that you have a Java class Game that includes instance methods boolean home(Team t) and boolean visitor (Team t). Write a static method boolean played(Team s, Team t, Game[ ] season) that will input two teams and an array of games, and return true if and only if P(s, t) is true for the set of games in the array.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started