❔ Trouble with modifiers
Working with modifiers/getters and setters now, and unfortunately I'm having trouble with my modifiers returning the right input once I make a change with a setter via the driver class.
7 Replies
The bools aren't changing despite the occupancy changing
Your first problem is making the class mutable in the first place
you only set
fullyOccupied
inside the constructor
you either want to re-evaluate it when 'Occupancy' is set or have FullyOccupied
s getter as return occupancy == 1.0f;
to evaluate it any time FullyOccupied
is accessed, i guess 😉Or just create a static method that returns a new BuildingBlueprint class with the desired values upon change
So you dont have to mutate at all
BuildingBlueprint.Create(blueprint1.Stories, blueprint1.Apartments, [newVal])
public static BuildingBlueprint Create(int stories, int apartments, float occupancy) => new BuildingBlueprint(stories,apartments,occupancy);
Privatize ur ctorsah
thank you guys
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.