18.9k views
15 votes
A circle is represented as a set of x and y coordinates of the screen pixel, where the shape of the circle is drawn, and an integer represent the diameter of the circle. Please design and implement the Circle class with. A constructor that take in parameter to initialize the member data fields of the class A method to set the coordinates of the Circle to a different location Give code to create a Circle object

1 Answer

2 votes

Answer:

Answered below

Step-by-step explanation:

//Program is written in Kotlin programming language

Class Circle(xCoordinate: Double, yCoordinate: Double, diameter: Int){

var coordinateX = xCoordinate

var coordinateY = yCoordinate

var circleDiameter = diameter

fun diffLocation(x1: Double, y1: Double){

coordinateX = x1

coordinateY = y1

print (coordinateX, coordinateY)

}

}

//Tester class

Class Main{

fun main( ){

val circle = Circle(2.34, 4.56, 10)

print(circle.coordinateX)

print (circle.coordinateY)

circle.diffLocation( 3.4, 2.8)

}

}

User SeattleOrBayArea
by
3.2k points