Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C# Create a class called CrewMember that has the following properties: string Name, string Role, double Salary, double CurrentCash Create a CrewMember constructor that takes

C#

Create a class called CrewMember that has the following properties: string Name, string Role, double Salary, double CurrentCash

Create a CrewMember constructor that takes in four parameters that will initialize the four properties of Name, Role, Salary, and CurrentCash.

In CrewMember create a method called IsPaid() which returns a bool. If the CurrentCash property is greater than or equal to Salary return true. Else, return false.

Create a class called SpaceShuttle that has the following properties: int Fuel, List Team

Create a constructor that takes no parameters. Set fuel to 0.

In the constructor, initialize Team with the following members:

"Gina" whose role is "Captain", and Salary is 10000

"John" whose role is "Navigator" and Salary is 5000

"Diddy" whose role is "Chimp" and Salary is 20

On all crew members, set their CurrentCash to 0.

Create a method within SpaceShuttle called DistributePay(). It will have one parameter, a total amount of pay to distribute to the crew as much as possible. If you run out of money, give the current crew member as much as you can and stop the loop. For each crew member:

If the pay variable has enough money, subtract their salary from pay and add their Salary to CurrentCash.

If there isnt enough money left, assign the current crew member whatever is left in the pay to CurrentCash and end the loop. (Yes, this wouldn't be fair in real life but just embrace that this is a contrived example. Think of it this way whoever is more senior in the crew gets paid first.)

In the SpaceShuttle, create a public method named Launch() that returns a bool. This method will only launch the space shuttle if the following are true:

Fuel is greater than 5.

Team Count is exactly 3.

IsPaid() returns true for each member of the crew.

If all conditions are true, your team can go to space! Return true. Otherwise, return false.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions