Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment Description: The goal of this assignment is to create the Stock class and utilize the provided method to test the class results. The Stock

Assignment Description:

The goal of this assignment is to create the Stock class and utilize the provided method to test the class results.

The Stock class should:

Maintain the state of the stock symbol, the stock name, the previous closing price, and the current price. All data should be protected and inaccessible outside the method if an accessor is not explicitly called for.

It should provide a no argument constructor.

It should provide a constructor for the symbol and stock name ONLY.

Accessor methods should provide access to only the previous closing price and current price fields from outside the object.

Mutator methods should only allow the previous closing price and current price fields to be changed from outside the object.

A method should be provided that returns the percent of change between the current price and the previous closing price.

Step 1: Provide a UML Class diagram of the stock class. There are various online tools that can be used for free or just use Microsoft Word to create the diagram. Save a screenshot of your UML diagram in a docs directory in your project folder structure.

Step 2: Code the Class and Document with JavaDoc comment blocks before the class, before each class field and each constructor, accessor, mutator and method.

Step 3: Test your code using the following code to test your class:

public class Main { public static void main(String[] args) { Stock stock = new Stock("MSFT", "Microsoft Corporation"); stock.setPreviousClosingPrice(254.77); // Set current price stock.setCurrentPrice(249.22); // Display stock info System.out.println("Previous Closing Price: " + stock.getPreviousClosingPrice()); System.out.println("Current Price: " + stock.getCurrentPrice()); System.out.printf("Price Change: %s", String.format("%.2f", stock.getChangePercent() * 100) + "%"); } }

Your Assignment deliverable: Upload your Java Project which includes your UML Class diagram image as a zip file.

no need to append uml or comment thank you

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

More Books

Students also viewed these Databases questions

Question

How would you define brand attitude?

Answered: 1 week ago

Question

=+1. Give the balance sheet to Melissa.

Answered: 1 week ago