Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Javeria Aamir C# Programming

Assignment 4
(Total marks: 20, weight: 5%)

A Real Estate Agency needs Management System that records the details about their offers: houses and apartments
In this project, you will be using object-oriented programming concepts and design in total four classes:

In this assignment 3, you will implement two classes named Residence and Address
In the next assignment, you will design two other classes: House, and Apartment.

The following diagram shows the relationships between these classes you are required to implement.

In this assignment, you will implement Address and Residence classes. The Residence class is the parent
class of apartment and House classes.
Consider the following UML class diagram:

Create a new C# project.

Question 1 [10 marks]:

A. Implementation details of Address class:


Add and implement a class named Address according to specifications in the UML class diagram.
Javeria Aamir C# Programming

- Data fields (private): city, street_name and postal_code.


- Properties: street, municipality, region and postal_code
- Constructors:
 A no-arg constructor that creates a default Address.
 A constructor that creates an address with the specified street, municipality, region,
and zipCode
- ToString() to print out all available information about the current object

B. A test program for the Address class


To demonstrates the Address class, in main method write a program that:

1. Prompts the user to enter the street name


2. Prompts the user to enter municipality name
3. Prompts the user to enter the region name
4. Prompts the user to enter the postal code
5. Creates an instance called stringAddress of type Address with the entered data
6. Displays this information using ToString().

Example of data:
 Street: 265 Yorkland Blvd.
 City: Toronto
 State: Ontario
 zipCode: M2J 1S5

Question 2 [10 marks]:


A. Implementation details of Residence class:
Add and implement a class named Residence according the instruction in the UML diagram
- Data fields: price, squareFeet, yearBuilt and address.
- Properties: Price, SquareFeet, YearBuilt and Address
- Constructors:
 A no-arg constructor that creates a default Residence.
 A constructor that creates a Residence with the specified price, squareFeet, yearBuilt
and address.

- CalculateCommission() that returns the commission amount. The commission rate is set up at
2.8%.
- ToString() that returns the information about the current object( price, yearBuilt, etc.).

B. A test program for the Residence class

In main method, you already created an instance of Address class called Address and prompted the
user to enter the address details.

1. Now prompt the user to enter the price, square Feet and year built.
Javeria Aamir C# Programming

2. Create an instance of the residence class with the entered data (including the address data).
3. Display the information about the residence using ToString().

You might also like