Constructors in Object-Oriented Programming Assignments

Download Solution Order New Solution

Assignment Task

This assignment is mainly about association, but also covers constructors and overloading. You will define multiple classes for objects that can draw themselves on a GraphicsContext. All the objects will be related to one another through the relationship of association. Then you will create a simple graphical app to display the objects.

The World of “Two Villages”

The world contains two villages and the emperor’s house – these three objects are the model. The view for this assignment is a class created using the FXGraphicsTemplate which creates and draws the model.

A village has a name and contains 3 houses, all the same color, each with one or more occupants. A house has a door and a window. The emperor’s house is the biggest in the world. It’s a different color and is not part of one of the two villages.

Here’s an example of what the output of your program might look like. Yours doesn’t have to look exactly like this. The king’s house is the orange one. Your colors, house sizes, village names, sizes and populations can be different.

20240614081408AM-1324689494-1452995855.jpg

Code Structure

The UML class diagram below shows which classes you are to develop and how they relate to one another. Here are some notes on each of the classes.

20240614081408AM-1783753515-1030114226.jpg

Door

A door is a white rectangle that is half as wide as it is high. Its location is its top left corner.

Window

A window is a white circle. Its location is its center.

House

A house is a square. Its location is the top left corner, and it contains a window and door, appropriately sized, somewhere within that square. The second constructor in the class diagram below is used to

create the king’s house (it sets the number of occupants to 1, the size to be extra-large, and the color to the king’s color). The House constructor creates the Window and Door with appropriate sizes and placement based on its own location and size. The draw method first draws the square for the house, then calls the Door and Window draw methods so that they draw themselves.

Village

A village is a collection of houses that are all the same color. The houses in a village are in a straight line from left to right, spaced out nicely. The location of a village corresponds to the bottom left corner of the first house. The village constructor creates the three houses. The houses should have different positions and random numbers of occupants. When a village draws itself, it calls the House draw methods, then it draws text underneath with the name of the village, its size (the sum of house widths and the widths of the spaces between the houses, where 1 pixel = 20 cm) and its population (determined by adding up the number of occupants of each house).

Two Villages

Finally, you should create a TwoVillages class (not shown above). This will be based on FXGraphicsTemplate. It should create two villages and a King’s house and draw them. If done correctly, this should only take 6 lines of code (to create and draw each object).

When your program is tested, it will be run using the TwoVillages class you handed in, then again using another standard TwoVillages class to make sure your Village and House classes conform to the interface shown in the UML diagram.

This It Computer Science have been solved by our PhD Experts at My Uni Paper. Our Assignment Writing Experts are efficient in providing a fresh solution to this question. We are serving more than 10000+ Students in Australia, the UK, and the US by helping them to score HD in their academics. Our Experts are well-trained to follow all marking rubrics and referencing styles.

Be it a used or new solution, the quality of the work submitted by our assignment experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turnitin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.

Get It Done! Today

Country
Applicable Time Zone is AEST [Sydney, NSW] (GMT+11)
+

Every Assignment. Every Solution. Instantly. Deadline Ahead? Grab Your Sample Now.