comp.lang.ada
 help / color / mirror / Atom feed
From: Anh Vo <anhvofrcaus@gmail.com>
Subject: Re: Help with tasks
Date: Sat, 7 May 2016 11:50:56 -0700 (PDT)
Date: 2016-05-07T11:50:56-07:00	[thread overview]
Message-ID: <952fe73b-6e0e-4101-a61a-dc6359442d1d@googlegroups.com> (raw)
In-Reply-To: <410b222c-9443-46b7-8a18-2fc3d05772a9@googlegroups.com>

On Saturday, May 7, 2016 at 7:53:29 AM UTC-7, danif...@gmail.com wrote:
> Hi! i'm a student, and got stucked with an ada home project, and i need a lot of help sadly, i can't even ask a specific question, because i have a lot, but it's about tasks and protected objects.
> 
> The project: There's a garden with 10 plots, and a locust gets in 1 of the plots, so the gardener wants to kill it with poison. The locust randomly changes plots in a time, and the gardener can spray 1 plot/day (either randomly), which gets clean from poison after that day has passed. The locust dies if it jumps into the sprayed plot, or is in it already. The simulation goes until the locust dies. For the random number generation and the console output use a common protected object. (Monitor)
> 
> I've tried all day to implement it with no luck, and feel that i need a complete solution to analyze and learn from its code lines, but any help is appreciated.
> Thanks!

I am glad with your honesty.

I suggest to create three tasks, gardener task, locust task and monitor task. In addition, these tasks will operate on an array of data structure (you should design it) through protected object. Task monitor will monitor to see if the gardener task and locust task operate at the same plot at the same time. If it does, mark the plot as completed and check for the remaining plots. When all 10 plots are reached, the work is done. 

Anh Vo


  parent reply	other threads:[~2016-05-07 18:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-07 14:53 Help with tasks danifreecs
2016-05-07 17:43 ` Dennis Lee Bieber
2016-05-07 18:50 ` Anh Vo [this message]
2016-05-07 20:44 ` Jeffrey R. Carter
2016-05-08 12:23 ` danifreecs
2016-05-08 18:28   ` Anh Vo
2016-05-09  2:24 ` rieachus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox