0% found this document useful (1 vote)
97 views1 page

CSE 215: Programming Language II Lab: Lab - 12: Abstract Class & Interface

This lab covers abstract classes and interfaces in Java. Students will implement an abstract Polygon class with concrete Triangle subclass to calculate area and perimeter. They will also implement the Discountable interface in a BestForCustomer class to get the best discounted price considering percentage and threshold discounts.

Uploaded by

Kamal Hossain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
97 views1 page

CSE 215: Programming Language II Lab: Lab - 12: Abstract Class & Interface

This lab covers abstract classes and interfaces in Java. Students will implement an abstract Polygon class with concrete Triangle subclass to calculate area and perimeter. They will also implement the Discountable interface in a BestForCustomer class to get the best discounted price considering percentage and threshold discounts.

Uploaded by

Kamal Hossain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

CSE 215: Programming Language II Lab

Lab – 12: Abstract Class & Interface

Objective:
● To understand abstract class
● To understand interface

Task:
1. Implement the following classes and invoke area(), perimeter() for object of Triangle:

Polygon Triangle extends Polygon

- numSide: int - sideA: double


- sideB: double
/* constructor */ - sideC: double
/* accessor-mutator */
+ area(): double /* constructor */
+ perimeter(): double /* accessor-mutator */
+ area(): double
+ perimeter(): double

2. Implement the following class and invoke discountedPrice():

<<interface>> BestForCustomer
Discountable
- percentage: double
discountedPrice(price: double): double - threshold: double
- discount: double

/* constructor, accessor, mutator */


+ discountedPrice(price:
double): double

discountedPrice() from BestForCustomer class will consider both percentage and


threshold discount and give the customer the best possible sales price.

You might also like