Engineering Problem Solving
Lab 7 – Object-Oriented Programming
Implement Object-Oriented Programming Classes
About the labs:
1.Lab sessions are 50 minutes long. During the first 20 minutes students are supposed to work on a simple class project. The last 30 minutes should be used for the class quiz.
2.Matlab, class-notes and any for of web browsing (Even submitting files on canvas) are not allowed during the quiz time.
3.Students can submit their class project files within 24 hours.
4.Students only get one chance to submit their quiz answers at the end of each lab session.
A friendly advice: If you are out of time for the class project, you can Email yourself the work you have done so to work on it later from your own computer.
This lab is worth 50 points.
Problem 1: Dog
Create a class named “dog” to manage a dog training business including the following properties: name, breed, age, weight, tricks, and number of visits the dog has had to the training school. For the class implement the following tasks:
-Create a dog example object with the information: Fido, Australian Shepard, 2 years old, 50 lbs of weight, knows tricks ‘sit’ and ‘shake’, and has had 10 visits to the training school.
-After a year, Fido had 20 visits to dog training, weights 55 lbs, and knows additional trick ‘roll over’. Write a MATLAB scripts to update the information of Fido. Your code should include methods to update each property separately by adding changes to original data.
Problem 2: Bank Account
Create an object oriented programing account class for a bank. Each account class contains the following information (properties): name on the account, account type, balance, interest accrual rate, account number, pin number, and whether or not the account was locked by entering the incorrect pin. Also include an account number private property which cannot be changed and a pin property that can be reset but can’t
be viewed publicly.
As an example create an object: A bank customer with name ‘A. Smith’, account type – checking, balance $5,000, yearly interest rate 1%, pin number 0101, account number 1234567, and account not locked (locked flag set to 0).
Your class must include methods that do the following:
-When a customer makes a deposit of $5000 at the bank, add the deposit amount to the existing balance and show the updated balance and the information (non-private information) of the account.
-Calculate the interest made on the account this year if the interest is the balance*yearly interest rate. Add this to the existing balance and display “The interest accrued this year is ____ and the new balance is ___ “ with the correct values shown.
-When a customer wants to view the account balance, prompt the user for the pin number. If a customer enters the correct pin, show the account balance and account number. If a customer enters the incorrect display ‘account locked’ and set the locked flag to 1.
-When a customer is locked out of their account, prompt them to enter the account number. If the account number is correct, prompt the user to set a new pin number and clear the locked flag by setting it to 0. If the customer enters the wrong account number, display ‘Wrong account number, please try again later’.