Question
Homework 2 - 25 points Problem 1 J-Unit review 3 points Based on the class BankAccount provided, write a JUnit test class called BankAccountTest that
Homework 2 - 25 points
Problem 1 J-Unit review 3 points
Based on the class BankAccount provided, write a JUnit test class called BankAccountTest that fully tests each method in the BankAccount class.
Problem 2 Tracing Code through inheritance 1 point
Using the SavingsAccount class that is provided, examine the constructor which takes in a double called interestRate. When the SavingsAccount class is correctly instantiated using the mentioned constructor and an interest rate of 5, what would be the balance of the savingsAccount variable below:
SavingsAccount savingsAccount = new SavingsAccount(5);
savingsAccount.deposit(2500);
savingsAccount.withdraw( savingsAccount.getBalance() * 0.10);
savingsAccount.addInterest();
Problem 3 -- Casting and Converting 4 points
Consider the following statement and answer the following questions. A superclass Person has a name and age. A subclass of Person called Student has a major.
Can a Person be cast as a Student? Indicate how this might happen using code snippets, and identify if this can be done with an implicit cast or must be done with an explicit cast? If not possible, simply state This is not possible.
Can a Student be cast as a Person? Indicate how this might happen using code snippets, and identify if this can be done with an implicit cast or must be done with an explicit cast? If not possible, simply state This is not possible.
Problem 4 -- UML and coding with Inheritance 7 points
Consider the following statement and answer the following questions. A superclass Person has a name and age. A subclass of Person called Student has a major. Another subclass of Person called Instructor has a salary.
Draw a UML diagram that correctly models the system as described (hint: it might be easier to build the solution in BlueJ and paste a screenshot of the system here) [2 points]:
Write the class definitions here, including constructors, properties, and the toString() method for all classes. Use inheritance as much as possible. Write a J-Unit test for each of the classes, and supply a test program that creates one of each type and correctly prints a valid representation of the class using the toString() method. For example, a valid output would include:
Instructor: John Doe, age 42, has a salary of $76500.
Student: Jane Doe, age 22, has a major of Computer Science.
Problem 5 Weekly learning and reflection - 5 points.
In two to three paragraphs of prose (i.e. sentences, not bullet lists) using APA style citations if needed, summarize and interact with the content that was covered in the introductory videos provided for this course. In your summary, you should highlight the major topics, theories, practices, and knowledge that were covered. Your summary should also interact with the material through personal observations, reflections, and applications to the field of study. In particular, highlight what surprised, enlightened, or otherwise engaged you. Make sure to include at least one thing that youre still confused about. In other words, you should think and write critically not just about what was presented but also what you have learned through the session. Feel free to ask questions in this as well since it will be returned to you with answers.
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