Questions
Shapes2D Write the following four classes to practice using an abstract class and polymorphism. Submit all...

Shapes2D

Write the following four classes to practice using an abstract class and polymorphism. Submit all four classes.


Shape2D class

For this class, include just an abstract method name get2DArea() that returns a double.


Rectangle2D class

Make this class inherit from the Shape2D class. Have it store a length and a width as fields. Provide a constructor that takes two double arguments and uses them to set the fields. Note, the area of a rectangle is the length times the width.


Circle2D class

Also make this class inherit from the Shape2D class. Have it store a radius as a field. Provide a constructor that takes a double argument and uses it to set the field. Note, the area of a circle is PI times it's radius times it's radius.


Shape2DDriver class

Have this class provide a method named displayArea() that takes an object from just any of the above three classes (you can't use an Object type parameter). Have the method display the area of the object, rounded to one decimal place.


Also the code should Enforce an abstract get2DArea() method and the right parameter type for displayArea()


Executes the following code:


Shape2DDriver tester = new Shape2DDriver();


Rectangle2D r = new Rectangle2D( 2, 3 );

Circle2D c = new Circle2D( 4 );


tester.displayArea( r );

tester.displayArea( c );

In: Computer Science

Shapes2D Write the following four classes to practice using an abstract class and polymorphism. Submit all...

Shapes2D

Write the following four classes to practice using an abstract class and polymorphism. Submit all four classes.

Shape2D class

For this class, include just an abstract method name get2DArea() that returns a double.

Rectangle2D class

Make this class inherit from the Shape2D class. Have it store a length and a width as fields. Provide a constructor that takes two double arguments and uses them to set the fields. Note, the area of a rectangle is the length times the width.

Circle2D class

Also make this class inherit from the Shape2D class. Have it store a radius as a field. Provide a constructor that takes a double argument and uses it to set the field. Note, the area of a circle is PI times it's radius times it's radius.

Shape2DDriver class

Have this class provide a method named displayArea() that takes an object from just any of the above three classes (you can't use an Object type parameter). Have the method display the area of the object, rounded to one decimal place.

Also the code should Enforce an abstract get2DArea() method and the right parameter type for displayArea()

Executes the following code:

Shape2DDriver tester = new Shape2DDriver();

Rectangle2D r = new Rectangle2D( 2, 3 );

Circle2D c = new Circle2D( 4 );

tester.displayArea( r );

tester.displayArea( c );

In: Computer Science

Write an abstract section for a research paper in 400 words or more on the following...

Write an abstract section for a research paper in 400 words or more on the following topic:

Analyze how an organization/ industry utilizes Information Technology and the strategy and rationale behind it, including the development of such systems for existing companies. Provide examples.

In: Operations Management

Describe the conceptual peg hypothesis. As examples, use the experimental results from the presentation of concrete...

Describe the conceptual peg hypothesis. As examples, use the experimental results from the presentation of concrete vs. abstract noun pairs. Explain the paired-associate learning task, and provide examples of stimuli that had high recall in the task.

In: Psychology

[Design Pattern] Think of a scenario that can be solved using all of these 3 patterns...

[Design Pattern] Think of a scenario that can be solved using all of these 3 patterns - Strategy, Factory and Abstract Factory patterns.

1. Write the Scenario

2. Write the code for the 3 patterns

3. Create the UML diagram

In: Computer Science

Using Netbeans update the Sales project so the input and the output are done through a...

Using Netbeans update the Sales project so the input and the output are done through a GUI of your choice.

The classes design should not be changed, only the code in the test class.

public abstract class Account {

private int accountId;

public Account(int id){
this.accountId=id;
}
//getters
public int getAccountId() {
return accountId;
}

//setters
public void setAccountId(int accountId) {
}

//abstract method to calculate sales
public abstract double calculateSales();
  
//to string method
@Override
public String toString() {
return("Account ID:"+getAccountId());
}
  
}

public class Services extends Account {

private int numberOfHours;
private double ratePerHour;

public Services(int id, int numberOfHours, double ratePerHours){
super(id);
this.numberOfHours=numberOfHours;
this.ratePerHour=ratePerHours;
}
  
//getters
public int getNumberOfHours() {
return numberOfHours;
}

public double getRatePerHour() {
return ratePerHour;
}

//setters
public void setNumberOfHours() {
this.numberOfHours=numberOfHours;
}

public void setRatePerHour() {
this.ratePerHour=ratePerHour;
}

//using the abstract method from Account
public double calculateSales() {
return getNumberOfHours() * getRatePerHour();
}

//toString method to put info in a readable format
@Override
public String toString() {
return super.toString()+", Rate per Hour: $"+getRatePerHour()+", Hours worked: "+ getNumberOfHours()+", Total Sales: $"+calculateSales();
}
}

public class Supplies extends Account {

private int numberOfItems;
private double pricePerItem;

public Supplies(int id, int numberOfItems, double pricePerItem){
super(id);
this.numberOfItems=numberOfItems;
this.pricePerItem=pricePerItem;
}
  
  
//getters
public int getNumberOfItems() {
return numberOfItems;
}

public double getPricePerItem() {
return pricePerItem;
}

//setters
public void setNumberOfItems() {
this.numberOfItems=numberOfItems;
}

public void setPricePerItem() {
this.pricePerItem=pricePerItem;
}

//using the abstract method from Account
public double calculateSales() {
return getNumberOfItems() * getPricePerItem();
}

//toString method to put info in a readable format
@Override
public String toString() {
return super.toString()+", Item Price: $"+getPricePerItem()+", Number of Items: "+ getNumberOfItems()+", Total Sales: $"+calculateSales();
}
}

TEST CLASS

public class companySales {
  
public static void main(String[] args) {
  
Account[] accounts;
accounts = new Account[100];
  
accounts[0] = new Supplies(1, 50, 4.50);
accounts[1] = new Services(2, 5, 25.50);

for(int x=0;x<2;++x){
System.out.println(accounts[x].toString());
}
}
}

In: Computer Science

1) Look up an online article on economics published anytime within the last year. The article...

1) Look up an online article on economics published anytime within the last year. The article must be mostly related to microeconomics, and must refer to something covered in this course (e.g. supply and demand; market structure; production costs; economies of scale; government interventions in particular markets; or other topics).
2) Write a brief summary of the article in your own words and mention where and in what way(s) the article relates to the topics covered in this course.

In: Economics

Discuss Glycolysis process and mention the sequence of enzyme-catalyzed reactions by which glucose is converted into...

Discuss Glycolysis process and mention the sequence of enzyme-catalyzed reactions by which glucose is converted into pyruvate.

In: Biology

Study case about asbestos pollution and treatment by encapsulation please mention study region and everything .

Study case about asbestos pollution and treatment by encapsulation please mention study region and everything .

In: Civil Engineering

5.4. Briefly list the type of patients that endotracheal anaesthetic can be used on. Mention 6...

5.4. Briefly list the type of patients that endotracheal anaesthetic can be used on. Mention 6 (6)

In: Nursing