Question

C# P-9 Programming PLO-2 Measured: Design, implement, and evaluate computer solutions utilizing structured and object-oriented programming...

C# P-9 Programming PLO-2 Measured: Design, implement, and evaluate computer solutions utilizing structured and object-oriented programming methodologies. Design a class named Contractor. The class should keep the following information: • Contractor name • Contractor number • Contractor start date Write one or more constructors, and the appropriate accessor and mutator functions for the class. For this assignment and P-10 you will have to include an algorithm for you program. This will be a word document attached to the dropbox. Submit your REPL.it link to the written submission section of the assignment dropbox. This code will be used in P-10

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/*
C # proram that prompts user to enter the contractor name, contractor numer and day , month and year as input values from keybaord.The create a constructor object and then display the contructor details on consple output.
*/

//Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ContractorApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            string contractorName;
            int contractorNumber;
            int day, month, year;
            DateTime startDate;

            Console.Write("Enter contractor Name : ");
            contractorName =Console.ReadLine();

            Console.Write("Enter contractor Number : ");
            int.TryParse(Console.ReadLine(), out contractorNumber);

            Console.Write("Start Date: ");
            Console.Write("Enter day : ");
            int.TryParse(Console.ReadLine(), out day);
            Console.Write("Enter month : ");
            int.TryParse(Console.ReadLine(), out month);
            Console.Write("Enter year : ");
            int.TryParse(Console.ReadLine(), out year);
            /*create a DateTime object with yea,month and day values*/
            startDate = new DateTime(year, month, day);

            /*Create constructor object */
            Contractor contractor = new Contractor(contractorName, contractorNumber, startDate);

            Console.WriteLine("\n\nContractor Details ");
            Console.WriteLine("Name : {0}", contractor.getName());
            Console.WriteLine("Number : {0}", contractor.getNumber());
            Console.WriteLine("Srart Date : {0}", contractor.getStartDate());
            Console.ReadLine();
        }
    }
}

------------------------------------------------------------------------------------------------------------------

/*
Constructor class that contains the name, number and start date as instance variables. The class contains the constructors and setter and getter methods
*/

//Contractor.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ContractorApplication
{
    class Contractor
    {
        private string name;
        private int number;
        private DateTime startDate;

        /*default constructor*/
        public Contractor()
        {
            this.name = "n/a";
            this.number = 0;
            this.startDate = new DateTime();
        }
        /*parameterized constructor*/
        public Contractor(string name, int number, DateTime startDate)
        {
            this.name = name;
            this.number = number;
            this.startDate = startDate;
        }

        /*Getter methods*/
        public string getName()
        {
            return name;
        }
        public int getNumber()
        {
            return number;
        }
        public DateTime getStartDate()
        {
            return startDate;
        }
        /*Setter methods*/
        public void setName(string name)
        {
            this.name = name;
        }
        public void setNumber(int number)
        {
            this.number = number;
        }
        public void setStartDate(DateTime startDate)
        {
            this.startDate = startDate;
        }
    }
}

------------------------------------------------------------------------------------------------------------------

Sample Output:

Enter contractor Name : Radha Constructions Enter contractor Number : 4 Start Date: Enter day : 1 Enter month : 11 Enter year

Add a comment
Know the answer?
Add Answer to:
C# P-9 Programming PLO-2 Measured: Design, implement, and evaluate computer solutions utilizing structured and object-oriented programming...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Programming Assignment 6: Object Oriented Programming Due date: Check Syllabus and Canvas Objectives: After successfully completing...

    Programming Assignment 6: Object Oriented Programming Due date: Check Syllabus and Canvas Objectives: After successfully completing this assignment, students will practice Object Oriented design and programming by creating a Java program that will implement Object Oriented basic concepts. RetailItem Class: Part 1: Write a class named RetailItem that holds data about an item in a retail store. The class should have the following fields: • description. The description field references a String object that holds a brief description of the...

  • Project 1 – Classes and Top-down Design Overview Software development projects using the object-oriented approach involve...

    Project 1 – Classes and Top-down Design Overview Software development projects using the object-oriented approach involve breaking the problem down into multiple classes that can be tied together into a single solution. In this project, you are given the task of writing some classes that would work together for providing a solution to a problem involving some basic computations. Learning Objectives The focus of this assignment is on the following learning objectives: • Be able to identify the contents of...

  • java Object Oriented Programming The assignment can be done individually or in teams of two. Submit one as...

    java Object Oriented Programming The assignment can be done individually or in teams of two. Submit one assignment per team of two via Omnivox and NOT MIO.Assignments sent via MIO will be deducted marks. Assignments must be done alone or in groups and collaboration between individuals or groups is strictly forbidden. There will be a in class demo on June 1 make sure you are prepared, a doodle will be created to pick your timeslot. If you submit late, there...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT