Define two derived classes of the abstract class

Assignment Help C/C++ Programming
Reference no: EM13162450

Define two derived classes of the abstract class ShapeBase below. Your two classes will be called RightArrow and LeftArrow. These classes will draw arrows that point right and left, respectively. The size of the arrow is determined by two numbers, one for the length of the tail and one for the width of the arrowhead. These values are 16 and 7 in the above display. The width of the arrowhead cannot be an even number, so your constructors and mutator methods should check to make sure that it is always odd. Write a test program for each class that tests all methods in the class. You can assume the width of the base of the arrowhead is at least 3.

 

*

* *

* *

**************** *

* *

* *

*

 

 

// Base class (ShapeBase)

public abstract class ShapeBase implements ShapeInterface{

protected int offset;

// I made offset protected so that the subclasses can refrence it directly

public void setOffset(int newOffset)

{

offset = newOffset;

}

public int getOffset()

{

return offset;

}

public abstract void drawHere();

public void drawAt(int lineNumber)

{

for(int i=0; i<lineNumber; i++)

System.out.println();

drawHere();

}

}

// Shape Interface

public interface ShapeInterface{

public void setOffset(int offset);

public int getOffset();

public void drawAt(int lineNumber);

public void drawHere();

}

 

 

 

Reference no: EM13162450

Questions Cloud

Find evidence that the hydroxyl radical is formed in flames : In combustion studies of H2 as an alternative fuel, you find evidence that the hydroxyl radical (HO) is formed in flames by the following reaction
What is the total pressure in torr of a gas : What is the total pressure in torr of a gas in a sealed flask that contains oxygen at a partial pres. of 0.41atm and water vapor at a partial pres. of 358mmHg?
Calculate the maximum percent yield of product : The solubility of the K3[Fe(C2O4)3].3H2O product at 00C is 4.7 g per 100 g water. Given this, calculate the maximum percent yield of product for your own reactant quantities.
State what is the concentration of f2 over a bath : Na3AlF6(l) 3 Na(l) + Al(l) + 3 F2(g) What is the concentration of F2 over a bath of molten cryolite at this temperature? a) 3 10-35 M b) 5 10102 M c) 6 10-74 M d) 8 10-312 M e) 8 1017 M
Define two derived classes of the abstract class : Define two derived classes of the abstract class ShapeBase below. Your two classes will be called RightArrow and LeftArrow. These classes will draw arrows that point right and left,
What is the rate constant for the reaction : What is the rate constant for the reaction at 85°C?
What was the concentration of the hcl solution : A 479-mL sample of unknown HCl solution reacts completely with Na2CO3 to form 12.1 g CO2. What was the concentration of the HCl solution?
Predict the effect of decreasing the container volume : Predict the effect of decreasing the container volume on the amounts of each reactant and product in the following reactions. (NOTE: Only ONE submission is allowed for this question.)
What is wrong with this description : 420 g of butane reacts with 1510 g of oxygen to produce 1390 g of carbon dioxide and 652 g of water.What is wrong with this description?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  What constructors do and when they are executed

Explain what constructors do and when they are executed. Explain the two types of constructors. Provide an example class that includes both types of constructor functions and demonstrate how an object would be instantiated using both types of constru..

  Write a method named negative sum

Write a method named negativeSum that accepts a Scanner as a parameter reading input from a file containing a series of integers, and determine whether the sum starting from the first number is ever negative

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Write c++ program that reads in the average monthly rainfall

Write a C++ program that reads in the average monthly rainfall for a city for each month of the year and then reads in the actual monthly rainfall for each of the previous 12 months

  Prepare a linear support vector machine svm

Write a computer program to prepare a Linear Support Vector Machine SVM

  Asks the user for the name of an input file and translates

Write a C++ program that asks the user for the name of an input file and translates the contents of that input file using ROT13. Your  main  function should be responsible for reading the input file and coordinating calls to a value-returning functio..

  Const int num_years

How do you get this program to get both player input and then display results(As described on bottom) #include  const int NUM_YEARS=15;//The number of years const int NAME_SIZE=32;//The max size of the player name string

  Create a c++ console application

Objective: Create a C++ console application that will model the characteristics of a resistor. Create a multifile project. Create and add to the project an h file containing the resistor-class definition. Create and add to the project a cpp file cont..

  Three or more dimensions

What kind of program, or problem, might necessitate arrays of three or more dimensions?

  Design a class named employeerecord

Design a class named EmployeeRecord that holds an employee's ID number, name, and payrate. Include mutator methods to set the values for each data field and output the values for each data field. Create the class diagram and write the code that

  Write main function to compute stress-strain in steel rod

Write a main function and the following functions to compute the stress and strain in a steel rod of diameter D (inches) and length L (inches) subject to the compression loads.

  Create a program that maintains the required book catalog

Create a program that maintains the required book catalog for the circulation desk of a library.

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