Tugas Algoritma dan Pemrograman Array dan inheritance Kelompok 07


Tugas Algoritma dan Pemrograman Array dan inheritance

1. Write a static method removeDuplicates (Characters [] in ) that returns new array of the characters in the given array, but without any duplicate characters. Always keep the first copy of the characters and remove subsequent ones. For example, if in contains b, d, a, b, f, a, g, a, a and f, the method will return an array containing b, d, a, f, and g (in one way to solve this problem is to create a Boolean array of the same size as the given array in and use it to keep track of which characters to keep. The values in the new Boolean array will determine the size of the array to return).

Soalnya adalah bagaimana kita menghapus karakter yang sudah ada sebelumnya, jadi ketika di printout hasil yang keluar hanya sekali. Seperti screenshoot diatas, jika huruf yang dimasukin adalah (‘a’,’a’,’b’,’b’,’c’,’d’,’c’) maka yang ada dioutput nanti hanyalah a, b, c, d karena tidak boleh ada ganda karakter yang sama.

2. Create the classes RightTriangle and Rectangle, each of which is derived from the abstract class ShapeBasein Listening 8.19.Then derive a class Square from the class Rectangle. Each of these three derived classes will have two additional methods to calculate area and circumference, as well as the inherited methods. Do not forget to override the method drawHere. Give your classes a reasonable complement of constructors and accessor methods. The Square class should include only one dimension, the side, and should automatically set the height and width to the length of the side. You can use dimensions in terms of the character width and line spacing even though they are undoubtedly unequal, so a square will not look square (just as a Rectangle object, as discussed in this chapter, won’t look square). Write a driver program that tests all your methods.

Soalnya adalah untuk membuat segitiga siku siku dan persegi panjang dengan menggunakan konsep inheritance dan menggunakan method shapeBasic. Disini kami membuat dengan konsep oop, membuat method-method baru yang bisa digunakan oleh main class dalam membuat bentuk segitiga dan persegi panjangnya.Terdapat 5 class dalam pembuatan nya , ada class interface untuk segitiga dan persegi panjang, lalu ada class untuk menentukan ukuran dari keduanya, dan juga class main, class main lah yang nantinya memanggil method method dari semua class tersebut.

Kelompok 7

Sylvia (1202164390)

Rizky Rahmat Hakiki (1202164146)

Muhammad Rafidan (1202160074)


Leave a Reply