Draw and implement abstract base class

Assignment Help Programming Languages
Reference no: EM1371831

1. Design and implement an abstract base class ArithmeticExpression that represent any binary (having two arguments) arithmetic expression. In this coursework you will be implementing various subclasses of this class. The abstract class should include at least two methods called evaluate and display which are described below.

2. Design and implement concrete (non-abstract) classes which are subclasses of the class ArithmeticExpression and represent some simple arithmetic expression. The operations that you should implement for each subclass should include the binary (i.e. accepting exactly two arguments) operations of addition, subtraction, multiplication and division (all of them accepting double type arguments). Using the classes you should be able to represent for example an expression like "(5.0+8.1)*(2.0)" (not in this format but represent the overall expression in an equivalent way). To design your classes you should think what common functionality and di erences ( elds and methods) these classes share and place such functionality at the appropriate place of the class hierarchy.
Implement methods evaluate and display. Method evaluate evaluates the arithmetic expression that the object represents and returns the result as a double. For example, calling it in an object representing expression "(5.0+8.1)*(2.0)" should return 26.2. Method display prints the raw (unevaluated) expression on the screen. For example, calling it in an object representing expression "(5.0+8.1)*(2.0)" should display the string
"(5.0+8.1)*(2.0)" (without the quotes). You shoud NOT use static methods!

3. Implement a test class CalculatorTest which tests the functionality of your classes (the methods of your classes should be called and make sure that they do what they are supposed to do).

4. Implement a class RandomCalculations which creates a random number of random expressions and uses your classes above to evaluate and display them. Test its functionality by calling its methods in the CalculatorTest class above.

Reference no: EM1371831

Questions Cloud

Determine the best course of action : A European consortium has spent a considerable value of time and money making a new supersonic aircraft. The aircraft gets high marks on all performance measures except noise.
Fast food restaurant production function : I believe that fast food restaurants show short run production function because of the one fixed input, capital. But, I need to elaborate more and produce the production function equation Q=F (L,K,M...) Can you please help?
Explain llc and mac : Explain two layers: LLC & MAC, and how are they different from what is available in TCP/IP protocol? Why do we require these two extra layers for LAN?
Calculate firm profit : Suppose you are the manager of a company that produces products X and Y at zero cost. You know that different types of consumers value your two products differently,
Draw and implement abstract base class : Draw and implement the abstract base class ArithmeticExpression which represent any binary (having two arguments) arithmetic expression.
Determine the optimal package price : The American Baker's Association reports that yearly sales of bakery goods last year rose 15%, driven by a 50% increase in the demand for bran muffins
Determining fixed-marginal and average costs : Consider a firm with total short-run cost function C=a+b.Q. New legislation means that it should pay an environmental tax which is the fixed sum, independent of whether it produces any output.
Calculate time weighted rate of return : A portfolio manager is being evaluated based on the time-weighted average rate of return. If the manager had achieved annual returns for the past three years of 2.5 percent, 14.5 percent and 9 percent on one initial investment of $500,000,
Draw an erd for initial entity list : Draw an ERD for initial entity list. Recognize a primary key for each entity and establish relationships as appropriate. Entity list for this purpose is as follows.

Reviews

Write a Review

Programming Languages Questions & Answers

  Explain multiprogrammed system available in user mode

CPU voltage and frequency or put it to sleep altogether. In a multiprogrammed system should this functionality be available in user mode or only accessible via system call. why or why not?

  Create application which simulates functionality of gas pump

Create application which simulates functionality of gas pump. The user enters number of gallons to buy and clicks desired grade.

  Create method to calculate value of product purchase

In addition, the receipt should display the value of the entire purchases. Create a method to calculate the value of the product purchases.

  Machine language used by sim virtual computer simulator

Write a program in machine language used by the SIM virtual computer simulator package to calculate the sum of the four numbers stored in memory addresses A1, A2, A3 and A4.

  Program to multiply two integers

What occurs when you multiply two integers whose product is larger than largest int value? Try out example and report your findings.

  Program-calculate power loss-transmitted-power generating

Write a program to calculate power loss in transmission line with resistance of 0.05 ohms/mile. Calculate power loss if 500 kW of power is transmitted from power generating station.

  Pseudocode to create thread-safe countdownevent by locks

Write pseudocode to implement a thread-safe CountdownEvent using locks and condition variables by implementing the following methods (lists 4 methods) and then "implement a Barrier using a CountdownEvent.

  Write program that inputs single integer in digital river

A digital river is sequence of number where number following is n+ sum of its digits for example 12345=12345+15=12360. Write a program that inputs single integer n (1

  Create a function that takes a one dimentional array

Create a function that takes a one dimentional array us a argument the function should return only these members from the array which are divisible by 4.

  Program to create three identical list

Write a program to create three identical list, list1, list2, and list3, of 5000 elements. The program then sorts list1using quick sort, list 2 using insertion sort.

  Program to compute pearson correlation coefficient

Write down a program to compute Pearson correlation coefficient by using parallel loop templates from Intel Threading Building Blocks library (TBB).

  Write program to input number of hours worked

Write a program that allows the user to input the number of hours worked and hourly pay rate for employees and outputs their total pay.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd