Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For each pair of specifications below, state whether the extending class is a true subtype of its superclass or not. Explain your answer. 1. class
For each pair of specifications below, state whether the extending class is a true subtype of its superclass or not. Explain your answer.
1. class Bicycle { int cadence; int speed; int gear; // effects: creates a new Bicycle Bicycle(int startCadence, int startSpeed, int startGear); // modifies: this // effects: this_post.cadence=newCadence, this_post.speed=newSpeed, this_post.gear=newGear void setParameters(int newCadence, int newSpeed, int newGear); } class MountainBike extends Bicycle { int height; // effects: creates a new MountainBike MountainBike(int startCadence, int startSpeed, int startGear, int startHeight); // modifies: this // effects: this_post.height=newHeight void setHeight(int newHeight); }
2. class Account { // modifies: this // effects: this_post.amount = this_pre.amount + d; void deposit(int d); } /* An account that works safely when multiple transactions attempt deposits simultaneously */ class ConcurrentAccount extends Account { // modifies: this // effects: this_post.amount = this_pre.amount + d; // throws: AbortException if another transaction is in the process of depositing money void deposit(int d); }
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