Question

In: Computer Science

Start by creating a new Visual Studio solution, but chose a “class library .Net Core” as...

Start by creating a new Visual Studio solution, but chose a “class library .Net Core” as the project type.

It will create a file and a class definition in that file.  Rename the file to be ToDo.cs  and accept the suggestion which will also rename that class to be

Class Todo

{

}

In that class, create

            - a string property called Title

            - an int property called  Priority

            - a bool property called Complete

Also, define one Constructor that takes in one string and one int.

In the constructor, use the passed in string to set the Title property and the passed in int to set the Priority property.

Also, set the Complete property to be false.

You are done with that class definition.

Now click on the Solution and add a new project, a .Net Core console project.

In the Main method,

[1]   Define an array of type ToDo and size 3. The compiler will complain it does not know what a ToDo is.  You need to add a reference from the Console Project to the Class Library.  (see any of those 3 descriptions I listed above for how to do this.  Don’t try going further until the compiler is happy with your array definition.)

[2]  Ask the user to enter a ToDo title (like ”wash the car” or “buy groceries”

And also ask them for a priority which should be a 1, 2, or a 3.

Create a new ToDo object by calling the constructor and passing in these 2 user values.

Add this new ToDo object into your array at [0].

Repeat that code 2 more times so that the array has 3 ToDo objects in it.

Now build a for loop that writes out one line for each array element, using the 3 properties that each item has.

Your output should look something like

Wash the car  Priorty:2  Completed: false

Buy groceries: Priorty 3 Completed: false

Do Prog120 Homework: Priority 1 Completed: false

Make sure the “false” comes from the property, don’t just hard code it in your for loop.

Solutions

Expert Solution

//Code in visual Studio using c#

=> Create a .net core console project => todo_project1

=> Create following code after renaming class Program to ToDo

using System;

namespace todo_project1
{
    public class ToDo
    {
        public string Title { get; set; }
        public int Priority { get; set; }
        public bool Complete { get; set; }
        //Constructor
        public ToDo(string title, int priority)
        {
            Title = title;
            Priority = priority;
            Complete = false;
        }
        public static void Main(string[]args)
        {

        }

    }
}

//Now go to Solution Explorer and Add another Solution => todo_project2

=> Add the project dependencies

=> right click on second project => Add=> Project Reference

//Now Write the following code

using System;
using todo_project1;
namespace todo_project2
{
    class Program
    {
        static void Main(string[] args)
        {
            // Define an array of type ToDo and size 3
            ToDo[] toDos = new ToDo[3];

            for (int i = 0; i < toDos.Length; i++)
            {

                Console.Write("Enter a ToDo title: ");
                string title = Console.ReadLine();
                Console.Write("Enter the priority: ");
                int priority = int.Parse(Console.ReadLine());
                ToDo todo = new ToDo(title, priority);
                toDos[i] = todo;
                Console.WriteLine();
            }
            //output

            for (int i = 0; i < toDos.Length; i++)
            {
                Console.WriteLine("{0} Priority: {1} Completed: {2}", toDos[i].Title, toDos[i].Priority, toDos[i].Complete);
            }

            //pause
            Console.WriteLine("Enter any key to terminate....");
            Console.ReadLine();
        }
    }
}

//Right Click => Select Property

// Output

//If you need any help regarding this solution...... please leave a comment..... thanks


Related Solutions

Create a C# .NET Core Console project in Visual Studio. (This is the same kind of...
Create a C# .NET Core Console project in Visual Studio. (This is the same kind of project we have been doing all semester.) Do all of the following in the Program class. You do not need to add any other classes to this project. 2. If it exists, remove the Console.WriteLine(“Hello World!”); line that Visual Studio created in the Program class. 3. At the very top of the Program.cs page you should see using System; On the empty line below...
1. Make a Console App (.NET Core) in Visual Studio and name it as A1YourFirstnameLastname. 2....
1. Make a Console App (.NET Core) in Visual Studio and name it as A1YourFirstnameLastname. 2. Implement a vehicle rental management system which is capable of doing the following: • View all, available and reserved vehicles. • Reserve vehicle or cancel a reservation. 3. The application must be menu-based app: 1 - View all vehicles 2 - View available vehicles 3 - View reserved vehicles 4 - Reserve a vehicle 5 - Cancel reservation 6 - Exit 4. NOTE: At...
1. Start a new Visual Studio project and name it GradeAppa. Make sure your project...
1. Start a new Visual Studio project and name it GradeAppa. Make sure your project is a web projectb. Make sure it is using C#2. Add a new folder and name it Grades_Logic3. Inside this new folder create a new web form called “Grades”4. Add a label to hold text “Enter Grade”5. Add a text field in front of the label to receive the grade6. Add another label in a new line to display the text “Participation”7. Place a drop-down...
Begin by creating a Java project with one class – Addition. Start with the class Addition...
Begin by creating a Java project with one class – Addition. Start with the class Addition as shown in Figure 12.2. This program uses dialog boxes for I/O to get two integers and display the result of adding them together. The program should run “as is”. Change the program so that it gets and adds two doubles instead of integers. When that is working get a third double using a dialog box. Add the three doubles together, and display the...
All of these programs need IO. So you must use appropriate Visual Studio solution as the...
All of these programs need IO. So you must use appropriate Visual Studio solution as the template (windows32 has been provided in the book’s website and you supposed to know how to use it as it was required in the previous assignment) Write an assembly language program to calculate the following. (((((20 + 21) × 22) + 23)×24)+25 : : :) + 2n Hint: Note that when n is even, carrying result is multiplied by 2n. When n is odd,...
how can i make in visual studio a farm wide solution for SP 2013. a marquee...
how can i make in visual studio a farm wide solution for SP 2013. a marquee that conects to the announcement list amd shows this message in my whole farm (or similar). Thank You in advance
C++ PROGRAM Using the attached C++ code (Visual Studio project), 1) implement a CoffeeMakerFactory class that...
C++ PROGRAM Using the attached C++ code (Visual Studio project), 1) implement a CoffeeMakerFactory class that prompts the user to select a type of coffee she likes and 2) returns the object of what she selected to the console. #include "stdafx.h" #include <iostream> using namespace std; // Product from which the concrete products will inherit from class Coffee { protected:    char _type[15]; public:    Coffee()    {    }    char *getType()    {        return _type;   ...
The solution has to be written on C++ Visual Studio Thank you (Package Inheritance Hierarchy) Package-delivery...
The solution has to be written on C++ Visual Studio Thank you (Package Inheritance Hierarchy) Package-delivery services, such as FedEx®, DHL® and UPS®, offer a number of different shipping options, each with specific costs associated. Create an inheritance hierarchy to represent various types of packages. Use class Package as the base class of the hierarchy, then include classes TwoDayPackage and OvernightPackage that derive from Package. Base class Package should include data members representing the name, address, city, state and ZIP...
C# 1.Visual Studio .NET’s ___________ feature displays all the members in a class a.real-time error checking...
C# 1.Visual Studio .NET’s ___________ feature displays all the members in a class a.real-time error checking b.Quick Info c.outlined code d.Intellisense 2.An algorithm specifies the actions to be executed. True False 3.A(n) _________ occurs when an executed statement does not directly follow the previously executed statement in the written application. a.unordered execution b.transfer of control c.action state d.jump 4.The declarations and statements that compose the method definition are called the __________.    a.method body b.method header c.parameter list d.method name...
Create a new Visual Studio console project named assignment042, and translate the algorithm you developed in...
Create a new Visual Studio console project named assignment042, and translate the algorithm you developed in Assignment 04.1 to C++ code inside the main() function. Your program should prompt for a single 9-digit routing number without spaces between digits as follows: Enter a 9-digit routing number without any spaces: The program should output one of: Routing number is valid Routing number is invalid A C++ loop and integer array could be used to extract the routing number's 9 digits. However...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT