Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Adapt Your Plan

00:00 After finishing this, my next idea was to create two methods here, .enter() and .exit().

00:14 Let me take another look at the plan. Okay, and then I’d be able to allow animals to enter and exit the farm locations. And I would have to hook that up with the .move() method on the Animal class.

00:30 Hmm. So now when I look at this again, being that far ahead in my code, I have the feeling that this would mean some sort of duplication.

00:37 I’d be able to enter animals from the perspective of a location and also from the perspective of an animal, which means interconnecting. These two might get a little tricky and maybe also unnecessary. So my idea is, I think I’m going to stick with the .move() method on the Animal class.

00:55 The animals are kind of the main objects in my farm that do all the things. They’re the ones that are going to move or not move. And I think I’m going to get rid of, like I’m not going to implement, .enter() and .exit() on the FarmLocation objects.

01:09 I’m just going to stick with having this space for animals to go and a measure of how many spaces are in there. I think these two make sense on the FarmLocation.

01:18 .enter() and .exit() could make sense, and it’s definitely where you could go, but I think I’m just going to move that logic and keep it inside of the .move() method. Alright, and so I’m revisiting my draft that I had here.

01:31 I already didn’t implement everything the way that I was kind of like drafting that out here, but that’s what it is. It’s just a draft that helps me think through the idea of what I want to do here.

01:41 And you don’t need to strictly stick to it. Instead, if I implement this in the .move() method, I’m probably going to need some way to also keep track of the location of an animal on the Animal class.

01:53 So I’ll have to add another attribute to Animal that’ll hold what location it currently is at. All right, this is my revised plan, kicking out .enter() and .exit() and moving the functionality to .move() and also drafting up a new instance attribute in Animal that’ll refer to a location object. Let’s try to in the next lesson.

Become a Member to join the conversation.