C# drawing app | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

C# drawing app

Problem Drawing Application You are creating a drawing application and currently have only 1 tool - a pencil. You want to add brush and spray to the drawing toolbar. The program you are given declares an IDraw interface with the StartDraw() method, and class Draw, which performs pencil drawing by implementing the IDraw interface. It outputs "Using pencil". Complete the given Brush and Spray classes by - inheriting them from class Draw - implementing the StartDraw() method for each tool, in order to output "Using brush" for Brush, or "Using spray" for Spray. The Draw objects and their method calls are provided in Main(). using System; using System.Collections.Generic; namespace Code_Coach_Challenge { class Program { static void Main(string[] args) { Draw pencil = new Draw(); Draw brush = new Brush(); Draw spray = new Spray(); pencil.StartDraw(); brush.StartDraw(); spray.StartDraw(); } } /* Draw => "Using pencil" Brush => "Using brush" Spray => "Using spray" */ public interface IDraw { void StartDraw(); } class Draw : IDraw { public virtual void StartDraw() { Console.WriteLine("Using pencil"); } } //inherit this class from the class Draw class Brush { //implement the StartDraw() method } //inherit this class from the class Draw class Spray { //implement the StartDraw() method } }

10th Mar 2021, 2:54 PM
Bonn Cabello
Bonn Cabello - avatar
5 Answers
+ 6
using System; using System.Collections.Generic; namespace Code_Coach_Challenge { class Program { static void Main(string[] args) { Draw pencil = new Draw(); Draw brush = new Brush(); Draw spray = new Spray(); pencil.StartDraw(); brush.StartDraw(); spray.StartDraw(); } } /* Draw => "Using pencil" Brush => "Using brush" Spray => "Using spray" */ public interface IDraw { void StartDraw(); } class Draw : IDraw { public virtual void StartDraw() { Console.WriteLine("Using pencil"); } } //inherit this class from the class Draw class Brush : Draw { //implement the StartDraw() method public override void StartDraw() { Console.WriteLine("Using brush"); } } //inherit this class from the class Draw class Spray : Draw { //implement the StartDraw() method public override void StartDraw() { Console.WriteLine("Using spray"); } } }
21st Mar 2021, 12:58 AM
Melhem Kheireddine
Melhem Kheireddine - avatar
+ 4
Please, share your code attempt that you have tried to solve What you shared is problem & it's description.. & the hints to solve which is already given including comments Here, we cannot see your attempt for solving. So, share your code first.
10th Mar 2021, 4:04 PM
Shivani 📚✍
Shivani 📚✍ - avatar
0
using System; using System.Collections.Generic; namespace Code_Coach_Challenge { class Program { static void Main(string[] args) { Draw pencil = new Draw(); Draw brush = new Brush(); Draw spray = new Spray(); pencil.StartDraw(); brush.StartDraw(); spray.StartDraw(); } } /* Draw => "Using pencil" Brush => "Using brush" Spray => "Using spray" */ public interface IDraw { void StartDraw(); } class Draw : IDraw { public virtual void StartDraw() { Console.WriteLine("Using pencil"); } } //inherit this class from the class Draw class Brush:Draw { //implement the StartDraw() method public override void StartDraw() { Console.WriteLine("Using brush"); } //inherit this class from the class Draw class Spray:Draw { //imple
29th Dec 2021, 3:36 PM
callum matti
callum matti - avatar
0
Hope this help ==========**THE CODE**====================== using System; using System.Collections.Generic; namespace Code_Coach_Challenge { class Program { static void Main(string[] args) { Draw pencil = new Draw(); Draw brush = new Brush(); Draw spray = new Spray(); pencil.StartDraw(); brush.StartDraw(); spray.StartDraw(); } } /* Draw => "Using pencil" Brush => "Using brush" Spray => "Using spray" */ public interface IDraw { void StartDraw(); } class Draw : IDraw { public virtual void StartDraw() { Console.WriteLine("Using pencil"); } } //inherit this class from the class Draw class Brush : Draw { //implement the StartDraw() method public override void StartDraw() { Console.WriteLine("Using brush"); } } //inherit this class from the class Draw class Spray : Draw { //implement the StartDraw() method public override void StartDraw() { Console.WriteLine("Using spray"); } } }
27th Jun 2022, 4:21 AM
HiepTD3
0
using System; using System.Collections.Generic; namespace Code_Coach_Challenge { class Program { static void Main(string[] args) { Draw pencil = new Draw(); Draw brush = new Brush(); Draw spray = new Spray(); pencil.StartDraw(); brush.StartDraw(); spray.StartDraw(); } } /* Draw => "Using pencil" Brush => "Using brush" Spray => "Using spray" */ public interface IDraw { void StartDraw(); } class Draw : IDraw { public virtual void StartDraw() { Console.WriteLine("Using pencil"); } } //inherit this class from the class Draw class Brush : Draw { //implement the StartDraw() method public override void StartDraw() { Console.WriteLine("Using brush"); } } //inherit this class from the class Draw class Spray : Draw { //implement the StartDraw() method public override void StartDraw() { Console.WriteLine("Using spray"); } } }
12th Jul 2022, 8:08 AM
soheil ghambari
soheil ghambari - avatar