Tugas Array dan Enhiretance Kelompok 03


No 3 BAB 8

Define two derived classes of the abstract class ShapeBase in Listing 8.19. Your two classes will be called RightArrow and LeftArrow. These classes will be like the classes Rectangle and Triangle, but they 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. (The width is the length of the vertical base.) The arrow shown here has a length of 16 and a width of 7. 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 the methods in the class. You can assume that the width of the base of the arrowhead is at least 3.

Penjelasan soal :

Jadi dalam kasus tersebut, kita diperintahkan untuk membuat sebuah program yang menggambarkan panah ke kanan maupun ke kiri. Terdapat 3 class ( Class RightArrow, LeftArrow, dan ShapeBase(sebagai kelas abstrak)) dan 1 main class. Dalam program tersebut, gambar panah ditentukan dengan panjang ekor dan panjang kepala. Panjang ekor bisa dengan angka berapa saja, namun untuk panjang kepala haruslah ganjil. Apabila menginputkan angka genap maka statement yang muncul “ERROR”.

Class RightArrow


Class LeftArrow


Kelas Abstrak ShapeBase



Main Class


Output


KELOMPOK3
SI 40-02

1. Rizka Fadhilah (1202160050)

2. Kurnia Dwi (1202164122)

3. Firdha Utami (1202160277)


Leave a Reply