Skip to content

Commit

Permalink
Make MeanShareAndBalanceModel.ts abstract, see: #45
Browse files Browse the repository at this point in the history
  • Loading branch information
marlitas committed Jul 1, 2022
1 parent b6cffa3 commit 54b7875
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
16 changes: 5 additions & 11 deletions js/common/model/MeanShareAndBalanceModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,24 @@ type SelfOptions = EmptyObjectType;

export type MeanShareAndBalanceModelOptions = SelfOptions & PickRequired<PhetioObjectOptions, 'tandem'>;

export default class MeanShareAndBalanceModel {
export default abstract class MeanShareAndBalanceModel {

public constructor( providedOptions: MeanShareAndBalanceModelOptions ) {
protected constructor( providedOptions: MeanShareAndBalanceModelOptions ) {
// Here for potential future use.
}

public syncData(): void {
// See subclass for implementation
}
public abstract syncData(): void

/**
* Resets the model.
*/
public reset(): void {
// See subclass for implementation
}
public abstract reset(): void

/**
* Steps the model.
* @param dt - time step, in seconds
*/
public step( dt: number ): void {
// See subclass for implementation
}
public abstract step( dt: number ): void
}

meanShareAndBalance.register( 'MeanShareAndBalanceModel', MeanShareAndBalanceModel );
9 changes: 3 additions & 6 deletions js/intro/model/IntroModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,7 @@ export default class IntroModel extends MeanShareAndBalanceModel {
* Will close all open pipe valves
* Called when the syncDataRectangularButton is pressed.
*/
public override syncData(): void {
super.syncData();
public syncData(): void {
this.assertConsistentState();
this.isAutoSharingProperty.set( false );
this.pipeGroup.forEach( pipe => pipe.isOpenProperty.set( false ) );
Expand All @@ -277,11 +276,10 @@ export default class IntroModel extends MeanShareAndBalanceModel {
/**
* @param dt - in seconds
*/
public override step( dt: number ): void {
public step( dt: number ): void {

this.assertConsistentState();

super.step( dt );
this.stepWaterLevels( dt );

assert && assert( !phet.joist.sim.isSettingPhetioStateProperty.value, 'Cannot step while setting state' );
Expand Down Expand Up @@ -309,8 +307,7 @@ export default class IntroModel extends MeanShareAndBalanceModel {
assert && assert( this.waterCup3DGroup.count - 1 === this.pipeGroup.count, `The length of pipes is: ${this.pipeGroup.count}, but should be one less the length of water cups or: ${this.waterCup3DGroup.count - 1}.` );
}

public override reset(): void {
super.reset();
public reset(): void {
this.isShowingPredictMeanProperty.reset();
this.isShowingMeanProperty.reset();
this.isShowingTickMarksProperty.reset();
Expand Down
13 changes: 13 additions & 0 deletions js/leveling-out/model/LevelingOutModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,19 @@ export default class LevelingOutModel extends MeanShareAndBalanceModel {
}
}

public override reset(): void {
this.isMeanAccordionExpandedProperty.reset();
this.numberOfPeopleProperty.reset();
}

public syncData(): void {
// future implementation
}

public step( dt: number ): void {
// future implementation
}

}

meanShareAndBalance.register( 'LevelingOutModel', LevelingOutModel );

0 comments on commit 54b7875

Please sign in to comment.