Question: [Note: For this section create a second project and call it Section-2-OOO ] Create a public class Product with the following Fields: Code as string

[Note: For this section create a second project and call it Section-2-OOO ]

  1. Create a public class Product with the following

  1. Fields:

  1. Code as string

  1. Description as string

  1. Price as decimal

  1. Constructor

  1. An empty constructor

  1. An overload constructor with the fields as parameters (Object initializer)

  1. Properties

  1. One for each field

  1. Functions

  1. A public function that returns a string such as

  1. The Product Number + code + is a + description.

  1. A public function that return a string such as

  1. The Price for Product Number + code + is $+ price.

using System;

class Program {

static void Main(string[] args)

{

Product prod = new Product("AE10145", "Motor Cycle", 12.44m);

onsole.WriteLine(prod.prodctNumberDetails()); Console.WriteLine(prod.productPriceDetails());

}

}

class Product

{

private string ring code;

private string description;

private decimal price;

public Product() {

}

public Product(string code, string description, decimal price) {

this.code = code;

this.description = description;

this.price = price; }

public string Code {

get{return code;

}

set{code = value;}

}

public string Description {

get{return description;} set{description = value;

}

}

public decimal Price {

get{return price;

}

set{price = price;

}

}

public string prodctNumberDetails()

{

return "The Product Number " + code + " is a " + description;

}

public string productPriceDetails() {

return "The Price for Product Number " + code + " is $" + price;

}

}

  1. Write the code to create an overload Function for the == Operator in the Product class created in the previous question [Hint: make your type implement the IEquatable]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!