Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is nothing stopping you having a reference in the CarCustomer to the CustomCar object as well. This would then give you a one to one reference between the object. Were you instaiate this object is up to you in the Constructor of the CustomCar</p> <pre><code>public CustomCar(arguments) { this.Customer.CustomCar = this; } </code></pre> <p>Or you could set it in the sets on the property accessors up to you. Try this </p> <pre><code>public class CustomCar { private string name; private string plateno; private double cost; private CarCustomer _customer = new CarCustomer(); public string Name { get { return name; } set { name = value; } } public double Cost { get { return cost; } set { cost = value; } } public string PlateNo { get { return plateno; } set { plateno = value; } } public CarCustomer Customer { get { return _customer; } set { _customer = value; } } public CustomCar() { Console.WriteLine("I am in custom car"); } public CustomCar(string name, string pno, double c, string customerName, double n, double bc) { this.Name = name; this.PlateNo = pno; this.Cost = c; this.Customer.Name1 = customerName; this.Customer.Nic1 = n; this.Customer.BargainCost = bc; this.Customer.Car = this; } public double finalCost() { if (this.Customer.BargainCost &lt; 10000) { double FinalCost = (this.Cost - this.Customer.BargainCost); return FinalCost; } else { return this.Cost; } } public void show() { Console.WriteLine(this.name + this.PlateNo + this.Customer.Name1 + this.Customer.Nic1); } } public class CarCustomer { private string name1; private double Nic; private double bargainCost; private CustomCar customer; public double BargainCost { get { return bargainCost; } set { bargainCost = value; } } public double Nic1 { get { return Nic; } set { Nic = value; } } public string Name1 { get { return name1; } set { name1 = value; } } public CustomCar Car { get{return customer;} set{customer = value;} } public CarCustomer() { Console.WriteLine("I have a customer"); } public CarCustomer(string n1, double i1, double bc) { this.Name1 = n1; this.Nic = i1; this.BargainCost = bc; } public void showCustomer() { Console.WriteLine("Customer name: " + Name1); Console.WriteLine("Customer NIC: " + Nic1); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload