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...
Make a Program in Visual Studio / Console App (.NET Framework) # language Visual Basic You...
Make a Program in Visual Studio / Console App (.NET Framework) # language Visual Basic You will be simulating an ATM machine as much as possible Pretend you have an initial deposit of 1000.00. You will Prompt the user with a Main menu: Enter 1 to deposit Enter 2 to Withdraw Enter 3 to Print Balance Enter 4 to quit When the user enters 1 in the main menu, your program will prompt the user to enter the deposit amount....
Programming Language: C# CheckingAccount class You will implement the CheckingAccount Class in Visual Studio. This is...
Programming Language: C# CheckingAccount class You will implement the CheckingAccount Class in Visual Studio. This is a sub class is derived from the Account class and implements the ITransaction interface. There are two class variables i.e. variables that are shared but all the objects of this class. A short description of the class members is given below: CheckingAccount Class Fields $- COST_PER_TRANSACTION = 0.05 : double $- INTEREST_RATE = 0.005 : double - hasOverdraft: bool Methods + «Constructor» CheckingAccount(balance =...
Create a new “Area” project. Create a new Visual Studio Project and call it “Area”. This...
Create a new “Area” project. Create a new Visual Studio Project and call it “Area”. This project will be used to calculate the area of certain figures, like circles, squares and rectangles. So add a title to the Form. The Form Title should say “Area”. Also add 3 labels, 3 Buttons, 3 Textboxes and 3 RadioButtons. The 3 Buttons should be near the bottom of the Form and say “Calc Area”, “Clear” and “Exit”. Make sure to give all your...
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;   ...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT