Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7191065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:39:00+00:00 2026-05-28T19:39:00+00:00

I’m designing a Monopoly game while also reading up more on OO principles. I

  • 0

I’m designing a Monopoly game while also reading up more on OO principles. I was reading about the LSP (Liskov Substitution Principle) and found that either I’m not fully understanding it or am violating it and should change my design.

(Just a note: this project is personal and just for fun, so I don’t actually care how maintainable the code is, but I’m just asking for personal education and understanding of LSP)

Let me begin with what I’ve designed thus far:

Class BoardSpace is an abstract base class, and there is one subclass per “kind” of space on the board. So I have PropertySpace, TaxSpace, GoSpace, etc.

BoardSpace has info about where the space is on the board, and also an abstract void Land() method, so that each different space can do something different when landed on, as it should. That way when I’m calling Land() on the current BoardSpace object, it doesn’t need to care or think about anything else and just does what the space should do. To me this makes sense and sounds like a workable solution.

But it seems to go against LSP in that all these different Land() overridden methods will do entirely different things, as I’ve designed them to do.

Or am I misunderstanding LSP? Does it have more to do with the way Land() is “expected” or “described” to work? Which in this case is completely different per space so that’s okay? Or is it certainly a violation and I should redesign it?

Side question: would this be considered an “abuse” of inheritance or a good use of it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:39:01+00:00Added an answer on May 28, 2026 at 7:39 pm

    Under LSP it is fine for subclass methods to do completely different things from the superclass ones as long as they do not violate the contract of the superclass. So really it all depends on how broad you make that contract.

    If BoardSpace.Land() was only allowed to change the state of the player, then you would have a problem if landing a subclass allowed the player to buy it (changing the state of the space). If however Land() is allowed to change the state of the landing player and the owning player, the state of the space, and the state of the card decks, then there is no violation of LSP.

    Still, it might be good practice to break things up into smaller methods that you can reason about more exactly. For example, the space might have a special action taken on it when you land (like drawing a card), followed by a transaction between the player and the owner of the space (other player or bank), with the constraint that the action can only affect the cash and cards of the player and the card decks, and the transaction can only affect the money of the two involved parties and the ownership of the space.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
In my XML file chapters tag has more chapter tag.i need to display chapters
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.